From 13a6fb087e7ef461d90704e6555ff07840f77392 Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Sat, 19 Dec 2020 21:46:15 +0000 Subject: [PATCH] return none if no position in previous tick --- bfxbot/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bfxbot/models.py b/bfxbot/models.py index 0cce18d..ff6cc94 100644 --- a/bfxbot/models.py +++ b/bfxbot/models.py @@ -172,6 +172,9 @@ class SymbolStatus: if self.current_tick == 1: return None + if not self.positions[self.current_tick - 1]: + return None + return next(filter(lambda x: x.position.id == pid, self.positions[self.current_tick - 1])) def active_position_wrapper_from_id(self, position_id: int) -> Optional[PositionWrapper]: