-
First of all, awesome job with this library! I really like backtesting.py and it's great to see that you added multi-asset strategies. I'm trying to create a strategy that relies on a couple of data points. I'm still trying to wrap my head around how multiple conditions can be applied and while doing some tests I noticed that just adding an additional indicator, even without referencing it in the next() method, can change the strategy outcome. here is an example:
even if I keep the line "metric2 >= 7" commented out but add the indicator for Metric2 (in the init) it will change my final results. I don't really understand why though? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I suspect the results returned from two prep_df() calls somehow share the same underlying memory and get messed up when indicators are prepared for next(). To help debugging the issue, can you please try adding .copy() in prep_df()'s return and see if the issue still shows up? Another experiment is to swap the order of the two lines and see if it makes any difference:
|
Beta Was this translation helpful? Give feedback.
-
Thank you for getting back so quickly! I tried the .copy() idea but same output (indicators are also correctly plotted). |
Beta Was this translation helpful? Give feedback.
dce738f should fix the issue. Thanks for reporting!
Please note backtest starts from when all indicators have non-NA values. Adding metric2, even if not used, can still change the outcome since it has a different warmup period, which effectively changes when backtest starts. You can capture and inspect
metric1
innext()
by: