returning dict and assigning it...
This commit is contained in:
parent
2d5214d34d
commit
a8e3206584
@ -12,12 +12,13 @@ TAKER_FEE = 0.2
|
|||||||
MAKER_FEE = 0.1
|
MAKER_FEE = 0.1
|
||||||
|
|
||||||
|
|
||||||
def __add_to_dict_list__(dict: Dict[int, List], k, v):
|
def __add_to_dict_list__(dictionary: Dict[int, List], k, v) -> Dict[int, List]:
|
||||||
if k not in dict:
|
if k not in dictionary:
|
||||||
dict[k] = [v]
|
dictionary[k] = [v]
|
||||||
return
|
else:
|
||||||
|
dictionary[k].append(v)
|
||||||
|
|
||||||
dict[k].append(v)
|
return dictionary
|
||||||
|
|
||||||
|
|
||||||
class EventKind(Enum):
|
class EventKind(Enum):
|
||||||
@ -133,17 +134,16 @@ class SymbolStatus:
|
|||||||
def add_order(self, order: Order):
|
def add_order(self, order: Order):
|
||||||
if self.strategy:
|
if self.strategy:
|
||||||
self.strategy.order_on_new_tick(order, self)
|
self.strategy.order_on_new_tick(order, self)
|
||||||
__add_to_dict_list__(self.orders, self.current_tick, order)
|
self.orders = __add_to_dict_list__(self.orders, self.current_tick, order)
|
||||||
|
|
||||||
# Applies strategy and adds position to list
|
# Applies strategy and adds position to list
|
||||||
async def add_position(self, position: Position):
|
async def add_position(self, position: Position):
|
||||||
# if a strategy is defined then the strategy takes care of creating a PW for us
|
# if a strategy is defined then the strategy takes care of creating a PW for us
|
||||||
|
|
||||||
if not self.strategy:
|
if not self.strategy:
|
||||||
pw = PositionWrapper(position)
|
pw = PositionWrapper(position)
|
||||||
else:
|
else:
|
||||||
pw = await self.__apply_strategy_to_position__(position)
|
pw = await self.__apply_strategy_to_position__(position)
|
||||||
__add_to_dict_list__(self.positions, self.current_tick, pw)
|
self.positions = __add_to_dict_list__(self.positions, self.current_tick, pw)
|
||||||
|
|
||||||
def all_prices(self) -> List[float]:
|
def all_prices(self) -> List[float]:
|
||||||
return list(map(lambda x: self.prices[x], range(1, self.current_tick + 1)))
|
return list(map(lambda x: self.prices[x], range(1, self.current_tick + 1)))
|
||||||
|
Loading…
Reference in New Issue
Block a user