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/

    How to get underlying timeframe when using replaydata

    General Discussion
    1
    2
    450
    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.
    • S
      sfkiwi last edited by

      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.replaying flag to check that the data is being replayed but I don't see anywhere to fetch the underlying timeframe from.

      1 Reply Last reply Reply Quote 0
      • S
        sfkiwi last edited by

        Nevermind, I had taken the idea of using the self._timeframe from the ccxt feed when instead I should have been using self.p.timeframe which doesn't get modified by the replaydata. Works perfectly now.

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