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 does live mode reference old candle data?

    General Code/Help
    3
    5
    306
    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.
    • Wayne Filkins
      Wayne Filkins last edited by

      If I have something like close[-50] and i'm running live mode, does it go back and reference the old data from before the live test started? Or do you have to actually run live test for 50 candles first? I know this is a dumb question I just wanted to make sure it uses data from before the live test.

      1 Reply Last reply Reply Quote 1
      • vladisld
        vladisld last edited by

        For live broker like IB, the backfill_start should be specified in order to request some historical data from the broker. In this case close[-50] will indeed reference the close position 50 bars back ( if enough historical data was loaded).

        1 Reply Last reply Reply Quote 1
        • Wayne Filkins
          Wayne Filkins last edited by

          Sorry I asked this question in backtrader community but it was for the alpaca-backtrader-api. It lets you set backtest or live mode and I was just trying to figure out how it references old data if you set it to live because it has you put "historical" as false. Sorry though this question doesn't really apply to these forums I don't think!

          D 1 Reply Last reply Reply Quote 0
          • D
            dasch @Wayne Filkins last edited by

            @Wayne-Filkins I checked the code for alpaca data. the data feeds support backfill. Check out the params:

            
                  - ``backfill_start`` (default: ``True``)
                    Perform backfilling at the start. The maximum possible historical data
                    will be fetched in a single request.
                  - ``backfill`` (default: ``True``)
                    Perform backfilling after a disconnection/reconnection cycle. The gap
                    duration will be used to download the smallest possible amount of data
                  - ``backfill_from`` (default: ``None``)
                    An additional data source can be passed to do an initial layer of
                    backfilling. Once the data source is depleted and if requested,
                    backfilling from IB will take place. This is ideally meant to backfill
                    from already stored sources like a file on disk, but not limited to.
            
            

            I did not look up what the size of max possible historical data per request is.

            But it will backfill by default on live trading. You should check out their api description to see, what size it will be (how many historical candles it will prefill on start).

            1 Reply Last reply Reply Quote 2
            • D
              dasch last edited by

              https://github.com/alpacahq/alpaca-backtrader-api/blob/master/alpaca_backtrader_api/alpacadata.py

              Here is the relevant code for the alpaca data source.

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