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/

    live broker with ccxt - next() not called

    General Code/Help
    1
    3
    98
    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.
    • Stacy Bingeback
      Stacy Bingeback last edited by

      I'm using the bt-ccxt-store library to connect backtrader to ccxt. Tested it with the binance crypto exchange and it worked alright.
      Now I wanted to switch to the FTX exchange. Using ccxt in isolation works alright so I know that my keys work. I get ohlcv data. But when I plug it into backtrader the way I did with binance, for some reason the next() method is not being called.

      My questions are:

      • how do I go about debugging this?
      • what are the typical reasons why next() wouldn't be called?
      • could something wrong with my ohlcv data be a reason? and if yes, why are there no error messages?

      thanks for reading!

      1 Reply Last reply Reply Quote 0
      • Stacy Bingeback
        Stacy Bingeback last edited by

        After reading some more about the strategy lifecycle I want to add that the longest period in my indicators is 420 bars and I'm getting 450 minutes worth of ohlcv data with "Minutes" timeframe:

            history_length_in_minutes = 450
            hist_start_date = dt.datetime.utcnow() - dt.timedelta(minutes=history_length_in_minutes)
            data = store.getdata(
                dataname='SOL/USD',
                name="SOL/USD",
                timeframe=bt.TimeFrame.Minutes,
                fromdate=hist_start_date,
                compression=1,
                ohlcv_limit=history_length_in_minutes,
                drop_newest=True
            )
        

        I see that prenext is being called but nextstart and next never are. It would seem that my strategy hasn't seen enough data yet but like I wrote above, 420 bars should have been enough.

        Stacy Bingeback 1 Reply Last reply Reply Quote 0
        • Stacy Bingeback
          Stacy Bingeback @Stacy Bingeback last edited by

          Guess I should've played around with that 450 limit some more before posting... It turns out that i need to retrieve 571 or more ticks before my strategy can run. I have no clue why but right now i'm just happy it's working.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors