first commit

This commit is contained in:
David Brazda
2023-04-12 21:00:03 +02:00
commit af9e944928
158 changed files with 19422 additions and 0 deletions

70
testy/changeiterable.py Normal file
View File

@ -0,0 +1,70 @@
from uuid import UUID, uuid4
from alpaca.trading.enums import OrderSide, OrderStatus, TradeEvent, OrderClass, OrderType, TimeInForce
#from utils import AttributeDict
from rich import print
from typing import Any, Optional, List, Union
from datetime import datetime, date
from pydantic import BaseModel
from common.model import Order
# to test change iterable (adding items) while iterating
class Notif:
def __init__(self,time):
self.time = time
open_orders: list(Order) = []
for i in range(1,10):
open_orders.append(Order(id=uuid4()),
submitted_at = datetime.utcnow(),
symbol = "BAC",
status = OrderStatus.ACCEPTED,
side = OrderSide.BUY)
print("cele pole objektu",open_orders)
# Here, 'reversed' returns a lazy iterator, so it's performant! reversed(l):
#musi fungovat removing stare a pridavani novych
#this list contains all not processed notification, that we try to process during this iteration
#if time is not right we leave the message for next iter
#if time is right we process the message (- note it can trigger additional open_orders, that are added to queue)
def process_message(notif: Notif):
global open_orders
pass
# if notif.time % 2 == 0 and notif.time < 300:
# open_orders.append(Notif(notif.time+50))
todel = []
for i in open_orders:
#print("*******start iterace polozky", i.time)
process_message(i.id)
print("removing element",i.id)
todel.append(i)
print("*****konec iterace", i.id)
print()
print("to del", todel)
#removing processed from the list
for i in todel:
open_orders.remove(i)
print("cely list po skonceni vseho")
for i in open_orders: print(i.id)
""""
pred iteraci se zavola synchroné
EXECUTE open orders(time)
- pokusi se vytvorit vsechny otevrene ordery do daneho casu (casu dalsi iterace)
- podporuje i volani callbacku a to vcetne pokynu vytvoreneho z pokynu
- tento novy pokyn muze byt i take exekuovan pokud se vcetne roundtripu vejde do daneho casu
pripadne soucasne vytvoreni i exekuci pokynu
"""