How to get underlying timeframe when using replaydata
I have created a custom feed for coinbase data using their websocket interface and am trying to get the replaydata to work. The feed supports both historic and realtime data so if I want to replay ticks on minute bars for example I would do the following
# Start with 255 mins of historic data before going to LIVE hist_start_date = datetime.utcnow() - timedelta(seconds=60*255) # Get a tick data feed as the underlying data data = CoinbaseProFeed(symbol="BTC-USD", name="btc_usd_tick", fromdate=hist_start_date, timeframe=bt.TimeFrame.Ticks) # replay the tick feed as minute bars cerebro.replaydata(data, timeframe=bt.TimeFrame.Minutes, compression=1)
However, the feed only sees the timeframe of Minutes (
self._timeframe) which is what the strategy would expect, but the feed needs to know that the underlying data is ticks because that's what cerebro is expecting in order to do the minute bar construction over the top.
I see that there is a
self.replayingflag to check that the data is being replayed but I don't see anywhere to fetch the underlying timeframe from.
Nevermind, I had taken the idea of using the
self._timeframefrom the ccxt feed when instead I should have been using
self.p.timeframewhich doesn't get modified by the replaydata. Works perfectly now.