Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    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

    General Code/Help
    1
    1
    70
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      dasch last edited by

      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

      1 Reply Last reply Reply Quote 2
      • 1 / 1
      • First post
        Last post
      Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
      $(document).ready(function () { app.coldLoad(); }); }