def before_market_closes#
This lifecycle method is executed self.minutes_before_closing minutes before the market closes. Use this lifecycle method to execute business logic like selling shares and closing open orders.
class MyStrategy(Strategy):
def before_market_closes(self):
self.sell_all()
Reference#
- lumibot.strategies.strategy.Strategy.before_market_closes(self)#
Use this lifecycle method to execude code before the market closes. You can use self.minutes_before_closing to set the number of minutes before closing
- Parameters:
None –
- Return type:
None
Example
>>> # Execute code before market closes >>> def before_market_closes(self): >>> self.sell_all()