Working around Backtrader limitations for backtesting derivatives
nash_hk last edited by
Wanted to check with the community if they have some work around when using backtrader with derivatives products.
The main issue with derivatives based strategies is if you back test over few years for let's say monthly options, you end up with a lot too many data feeds where most are only used during a small part of the back test. This makes running a back test very time consuming.
So I guess any of these options can help speed things up:
- Being able to persist (save) last run, then when new data is available, load last run, append new data and resume the run.
- Tweaking the lines are updated in every iteration, so that no time is wasted on products that already expired, or products that do not exist yet.
- Using the add_order_history capability in cerebro to just add all orders resulting from last run, and then run the strategy logic only on new data.
- Document and make it easy to customize "store" to mimic live trading.
- Run multiple strategies in a one strategy per derivative fashion, and have an efficient way to calculate performance in Cerebro, so that each strategy only runs on the period the derivative is defined on, but the global strategy has performance analytics for the whole period.
I'm sure the community faced these issues before, as you can see any of these capabilities can significantly improve backtest run time, and combining all these would be extremely efficient.