vladisld last edited by
The documentation mentions that the StrategySkipError exception could be raised during the 'birth' to avoid backtesting the strategy, quoting:
Note A strategy can be interrupted during birth by raising a StrategySkipError exception from the module backtrader.errors This will avoid going through the strategy during a backtesting. See the section Exceptions
where the 'birth' phase is represented by the 'start' method:
Birth: start The world (cerebro) tells the strategy is time to start kicking. A default empty method exists.
However, looking at the code, the StrategySkipError is only handled during the strategy construction (i.e. Conception stage) in cerebro.py
for stratcls, sargs, skwargs in iterstrat: sargs = self.datas + list(sargs) try: strat = stratcls(*sargs, **skwargs) except bt.errors.StrategySkipError: continue # do not add strategy to the mix
Am I wrong?
IMHO it could be beneficial to support raising the StrategySkipError during the 'start' method or even during 'next' method call.
One scenario is where the live strategy may check if its cached state is in sync with the actual broker's position on startup.
Another scenario is if strategy would like to be skipped in case it was started on non-trading days ( in order to save the machine up time for example, or save some CPU or log burden in multi strategy scenarios).
That's the specific documentation for the exception and it clearly shows it is done during
Am I wrong?
No, it is shown in the docs.