self.sleep

lumibot.strategies.strategy.Strategy.sleep(self, sleeptime: float, process_pending_orders: bool = True)

Sleep for sleeptime seconds.

Use to pause the execution of the program. This should be used instead of time.sleep within the strategy. Also processes pending orders in the meantime.

Parameters:
  • sleeptime (float) – Time in seconds the program will be paused.

  • process_pending_orders (bool) – If True, process pending broker fills around the sleep. In backtesting this calls broker.process_pending_orders before and after advancing the simulation clock. Required for agent tools such as orders_wait_for_terminal so market orders can fill without waiting for the next strategy bar.

Return type:

None

Example

>>> # Sleep for 5 seconds
>>> self.sleep(5)