How does live mode reference old candle data?
-
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.
-
For live broker like IB, the
backfill_start
should be specified in order to request some historical data from the broker. In this caseclose[-50]
will indeed reference the close position 50 bars back ( if enough historical data was loaded). -
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!
-
@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).
-
https://github.com/alpacahq/alpaca-backtrader-api/blob/master/alpaca_backtrader_api/alpacadata.py
Here is the relevant code for the alpaca data source.