backtrader
backtrader copied to clipboard
Make sure feeds.CCXT._fetch_ohlcv handles empty list of candles
On low-volume assets and short timeframes there can be periods without any trades. Some exchanges will return an empty list of candles for these periods. In feeds.ccxt.CCXT this results in self._last_ts remaining at its initial value of 0, ignoring the initial value of fromdate. On the next run, _fetch_ohlcv will thus start with since = None, trying retrieve years of data.
Not sure if this is the correct way to handle the situation, but at least it works around the initial problem of retrieving the entire history from the exchange. A cleaner solution might be to get the value for both since and _last_ts before the "for ohlcv in.." loop.