For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Multiple data sources using replay data
-
I noticed, that when using replaydata from a live data source, which is not added, will use the first data clock for other data sources.
So for example, if you have tick data, which is not added to cerebro, then you replaydata to some timeframe using the data and then adding another data source the same way, the second data source will only be updated, if the first replayed data source forwards.
some code to visualize this:
# create some data feed with live data data = DataFeed() # add replayed data cerebro.replaydata(data, timeframe=bt.TimeFrame.Minutes, compression=1, name="primary") cerebro.replaydata(data, timeframe=bt.TimeFrame.Minutes, compression=30, name="secondary")
This will go this way:
- data source primary will work as expected and will be updated every tick that comes in
- data source secondary will be updated when primary moves one candle forward (in the example above every 1 minute)
When adding data this way:
# create some data feed with live data data = DataFeed() # add live data cerebro.adddata(data) # add replayed data cerebro.replaydata(data, timeframe=bt.TimeFrame.Minutes, compression=1, name="primary") cerebro.replaydata(data, timeframe=bt.TimeFrame.Minutes, compression=30, name="secondary")
This will go this way:
- data source primary will work as expected and will be updated every tick that comes in
- data source secondary will work as expected and will be updated every tick that comes in
Just in case anyone comes into that situation when using replaydata