def on_strategy_end¶
This lifecycle method runs once when a strategy finishes executing (at the end of a backtest or clean live shutdown). Use it to flush custom logs, summarize metrics, or release external resources.
class MyStrategy(Strategy):
def on_strategy_end(self):
self.log_message("Strategy finished cleanly.")
Reference¶
- lumibot.strategies.strategy.Strategy.on_strategy_end(self)¶
Use this lifecycle method to execute code when strategy reached its end. Used to dump statistics when backtesting finishes
- Parameters:
None
- Return type:
None
Example
>>> # Log end of strategy >>> def on_strategy_end(self): >>> self.log_message("The strategy is complete")