Skip to content

Possible deviation in backtest results because of timeshift usage #763

@majdzadeh

Description

@majdzadeh

Problem description

The backtesting broker includes a process_pending_orders() method which looks at previous day's data (according to the commented code) when the data source is PANDAS. I have noticed a couple of issues when backtesting with minute-level data:

  • The timeshift parameter for get_historical_prices() has been set to -2 however, the returned data is 2 days ahead of the current bar's timestamp.
  • The code comment says; This is a hack to get around the fact that we need to get the previous day's date to prevent lookahead bias. whereas, at least with minute-level data, the data is already available and there would be no lookahead bias.
  • The use of timeshift causes unexpected backtest results (at least with minute-level data). For example, the price that's used to fill orders with is different from the price that's seen during the trading iteration for the asset.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions