From 049c82ef498ee71214034a76e5675d10ffb4c09a Mon Sep 17 00:00:00 2001 From: Dim Norin Date: Tue, 1 Dec 2020 18:35:38 +0200 Subject: [PATCH] fix for incorrect ohlc data fetching during live trade --- ccxtbt/ccxtfeed.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ccxtbt/ccxtfeed.py b/ccxtbt/ccxtfeed.py index eaaa28c..b277c19 100644 --- a/ccxtbt/ccxtfeed.py +++ b/ccxtbt/ccxtfeed.py @@ -86,6 +86,7 @@ def __init__(self, **kwargs): self._data = deque() # data queue for price data self._last_id = '' # last processed trade id for ohlcv self._last_ts = 0 # last processed timestamp for ohlcv + self._last_ohlc = [] # last retrieved ohlc def start(self, ): DataBase.start(self) @@ -182,6 +183,8 @@ def _fetch_ohlcv(self, fromdate=None): if None in ohlcv: continue + if len(self._last_ohlc) == 0: + self._last_ohlc = ohlcv tstamp = ohlcv[0] @@ -191,10 +194,11 @@ def _fetch_ohlcv(self, fromdate=None): if tstamp > self._last_ts: if self.p.debug: - print('Adding: {}'.format(ohlcv)) - self._data.append(ohlcv) + print('Adding: {}'.format(self._last_ohlc)) + self._data.append(self._last_ohlc) self._last_ts = tstamp - + self._last_ohlc = ohlcv + if dlen == len(self._data): break