Slow backtesting with FixedSize filler
bfruergaard last edited by
I'm adding a filler to the broker with
in order to only partially fill orders when the order size exceeds the traded volume.
However, I experience that the performance of backtesting drops almost to a crawl, compared to running without the filler.
I'm backtesting a strategy on tick data (approx. 150k ticks over ~2 years) and the strategy is, at most, entering and closing a position once a week. I would have assumed that the filler overhead would only kick in, when the strategy enters or exits positions, but that does not seem to be the case. Instead I experience backtesting takes at least 10x longer, if not more, than without the filler.
I'm running backtrader with regular Python (3.7.4), not PyPy, on Windows.
Has anyone else experienced this, are there any known fixes, or does anyone know the cause of the drop in performance?
If I'm pointed in the right direction in the backtrader source, I'm happy to help out making a fix, if that's in any way possible.
The filler is ONLY called in two situations:
- Order execution
- Order submission (when checking if there are enough reserves to let an order into the system)
The 2nd is actually an oversight, given the functionality was added later, because it may let some orders into the system which shouldn't go in.
Submission check can be disabled with the parameter:
checksubmitof the broker, setting it to
False(or calling the method
set_checksubmit(checksubmit)of the broker)
In any case submission only happens once, so it won't affect each iteration.