I have been developing a strategy and backtesting it extensively. Results looked very promising. But after deploying it live, I was dismayed to see a significant discrepancy in the results. After investigation, it turns out the backtest results were inaccurate and misleading due to orders getting filled at an unrealistic time.
I have a strategy that uses 5-min bars. However, when submitting a limit order, the order is filled at some price within the same bar, which is unrealistic. To reflect real-world results, it should fill in the next 5-min bar (if the limit price happens to be within the bar price range).
More specifically: If I have a 5-min bar that opened at time t, the strategy would have received the bar when it's complete (i.e. at time t+5), so the order should execute from t+6 the earliest. Currently, the order is executed at time t.
I tried to workaround this using the LatencyModel, but that introduced a lot of indeterminism in the backtesting results, so it doesn't work.
Expected Behavior
Market orders are executed at the open of the next bar. Limit orders are executed within the next bar's price range.
Actual Behavior
Market orders are executed at the close of the same bar. Limit orders are executed within the same bar price range.
Specifications
- OS platform: Ubuntu
- Python version: 3.11
nautilus_trader version: 1.88.0
I have been developing a strategy and backtesting it extensively. Results looked very promising. But after deploying it live, I was dismayed to see a significant discrepancy in the results. After investigation, it turns out the backtest results were inaccurate and misleading due to orders getting filled at an unrealistic time.
I have a strategy that uses 5-min bars. However, when submitting a limit order, the order is filled at some price within the same bar, which is unrealistic. To reflect real-world results, it should fill in the next 5-min bar (if the limit price happens to be within the bar price range).
More specifically: If I have a 5-min bar that opened at time
t, the strategy would have received the bar when it's complete (i.e. at timet+5), so the order should execute fromt+6the earliest. Currently, the order is executed at timet.I tried to workaround this using the LatencyModel, but that introduced a lot of indeterminism in the backtesting results, so it doesn't work.
Expected Behavior
Market orders are executed at the open of the next bar. Limit orders are executed within the next bar's price range.
Actual Behavior
Market orders are executed at the close of the same bar. Limit orders are executed within the same bar price range.
Specifications
nautilus_traderversion: 1.88.0