Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# def on_abrupt_closing

This lifecycle method runs when the strategy execution gets interrupted. Use this lifecycle method to execute code to stop trading gracefully like selling all assets

    class MyStrategy(Strategy):
        def on_abrupt_closing(self):
            self.sell_all()

## Reference

strategies.strategy.Strategy.on_abrupt_closing(self)

  Use this lifecycle event to execute code when the main trader was shut down (Keybord Interuption)

  Parameters:

    None –

  Return type:

    None

  Example

      >>> def on_abrupt_closing(self):
      >>>     self.log_message("Abrupt closing")
      >>>     self.sell_all()