From a8e3206584e82f76c8f771ede09eaf4256439339 Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Thu, 17 Dec 2020 09:56:27 +0000 Subject: [PATCH] returning dict and assigning it... --- bfxbot/models.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bfxbot/models.py b/bfxbot/models.py index 2df428e..0a8d897 100644 --- a/bfxbot/models.py +++ b/bfxbot/models.py @@ -12,12 +12,13 @@ TAKER_FEE = 0.2 MAKER_FEE = 0.1 -def __add_to_dict_list__(dict: Dict[int, List], k, v): - if k not in dict: - dict[k] = [v] - return +def __add_to_dict_list__(dictionary: Dict[int, List], k, v) -> Dict[int, List]: + if k not in dictionary: + dictionary[k] = [v] + else: + dictionary[k].append(v) - dict[k].append(v) + return dictionary class EventKind(Enum): @@ -133,17 +134,16 @@ class SymbolStatus: def add_order(self, order: Order): if self.strategy: 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 async def add_position(self, position: Position): # if a strategy is defined then the strategy takes care of creating a PW for us - if not self.strategy: pw = PositionWrapper(position) else: 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]: return list(map(lambda x: self.prices[x], range(1, self.current_tick + 1)))