self.sleeptime#
- property Strategy.sleeptime#
Get or set the current sleep time for the strategy.
Sleep time is the time the program will pause between executions of on_trading_iteration and trace_stats. This is used to control the speed of the program.
By default, equals 1 minute. You can set the sleep time as an integer which will be interpreted as minutes. eg: sleeptime = 50 would be 50 minutes. Conversely, you can enter the time as a string with the duration numbers first, followed by the time units: ‘M’ for minutes, ‘S’ for seconds eg: ‘”300S”’ is 300 seconds, ‘”10M”’ is 10 minutes.
- Returns:
sleeptime – Sleep time in minutes or a string with the duration numbers first, followed by the time units: S for seconds, M for minutes, H for hours’ or D for days.
- Return type:
int or str
Example
>>> # This is usually used in the initialize method
>>> # Set the sleep time to 5 minutes in the initialize method >>> def initialize(self): # Your initialize lifecycle method >>> self.sleeptime = '5M'
>>> # Set the sleep time to 10 seconds in the initialize method >>> def initialize(self): # Your initialize lifecycle method >>> self.sleeptime = '10S'
>>> # Set the sleeptime to 10 minutes >>> self.sleeptime = 10
>>> # Set the sleeptime to 300 seconds >>> self.sleeptime = "300S"
>>> # Set the sleep time to 5 minutes >>> self.sleeptime = 5
>>> # Set the sleep time to 5 seconds >>> self.sleeptime = "5S"
>>> # Set the sleep time to 2 hours >>> self.sleeptime = "2H"
>>> # Set the sleep time to 2 days >>> self.sleeptime = "2D"