Why Historical Bar Loading Differs Between Live Trading and Backtests
Summary
This discussion asks why a request to load ten days of bars appears to cover ten trading days during strategy initialization in backtesting but ten calendar days in live trading. It compares the two implementations: the live engine calculates a start timestamp by subtracting the requested number of days from the current time, then queries a gateway, data feed, or database. The backtesting engine instead subtracts the same calendar duration from the backtest start and ends the initialization interval just before that start, using the interval-specific time adjustment.
The code shown explains the date boundaries each implementation passes to its data source, but the document does not include a response resolving the question or evidence about how many bars are ultimately returned. The actual coverage can depend on available data and the history source’s handling of trading sessions. Users should distinguish the requested calendar range from the number of trading sessions represented in the returned bars.
Key ideas
- Both implementations derive the initialization start by subtracting a calendar-day duration.
- Live loading queries history from the current time through a selected source such as a gateway or database.
- Backtesting loads data ending immediately before the configured backtest start.
- The code excerpt does not establish that the request returns the same number of trading sessions in each mode.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.