The sleep function, causing the program to pause for a period of time.
Sleep(millisecond)
The millisecond
parameter is used to set the duration of sleep and the number of milliseconds.
millisecond
true
number
function main() {
Sleep(1000 * 10) // Wait for 10 seconds
Log("Waited for 10 seconds")
}
def main():
Sleep(1000 * 10)
Log("Waited for 10 seconds")
void main() {
Sleep(1000 * 10);
Log("Waited for 10 seconds");
}
For example, when executing the Sleep(1000)
function, the program will sleep for 1 second. It supports operations with sleep time less than 1 millisecond, for example setting Sleep(0.1)
. It supports a minimum parameter of 0.000001
, i.e. nanosecond hibernation, where 1 nanosecond is equal to 1e-6
milliseconds.
When writing strategies in the Python
language, the Sleep(millisecond)
function should be used for polling interval, time-to-wait operations. It is not recommended to use the time.sleep(second)
function of Python
's time
library. This is because using the time.sleep(second)
function in a strategy makes the strategy program wait for a period of time actually when backtesting (not skipping on the time series of the backtesting system), so it causes the strategy to backtest very slowly.