def on_bot_crash¶
This lifecycle method runs when the strategy crashes. By default, if not overloaded, it calls on_abrupt_closing.
class MyStrategy(Strategy):
def on_bot_crash(self, error):
self.on_abrupt_closing()
Reference¶
- strategies.strategy.Strategy.on_bot_crash(self, error)¶
Use this lifecycle event to execute code when an exception is raised and the bot crashes
- Parameters
error (Exception) – The exception that was raised.
- Returns
- Return type
None
Example
>>> def on_bot_crash(self, error): >>> self.log_message(error)
>>> # Sell all assets on crash >>> def on_bot_crash(self, error): >>> self.sell_all()