Sleep
Sleep function, used to pause program execution for a specified time.
Sleep(millisecond)Examples
javascript
function main() {
Sleep(1000 * 10) // Wait for 10 seconds
Log("Waited for 10 seconds")
}
python
def main():
Sleep(1000 * 10)
Log("Waited for 10 seconds")
c++
void main() {
Sleep(1000 * 10);
Log("Waited for 10 seconds");
}Arguments
| Name | Type | Required | Description |
millisecond | number | Yes | The |
Remarks
For example, when executing Sleep(1000) function, the program will sleep for 1 second. Sleep times less than 1 millisecond are supported, such as setting Sleep(0.1). The minimum supported parameter value is 0.000001, which is nanosecond-level sleep, where 1 nanosecond equals 1e-6 milliseconds.
When writing strategies in Python, the Sleep(millisecond) function should be used for operations such as polling intervals and time waiting. It is not recommended to use the time.sleep(second) function from Python's time library. This is because using time.sleep(second) in a strategy will cause the strategy program to actually wait for the corresponding time during backtesting (rather than skipping ahead in the backtest system's time sequence), resulting in extremely slow strategy backtesting.