Skip to content

Algo.Sleep

method · Algo · cAlgo.API.Internals

DesktopCLICloud

Suspends the algorithm until the specified timespan elapses.

Overloads

Signature Description
Sleep(TimeSpan timespan) Suspends the algorithm until the specified timespan elapses.
Sleep(int milliseconds) Suspends the algorithm until the specified number of milliseconds elapses.
Sleep(DateTime dateTime) Suspends the algorithm until the specified datetime.

Sleep(TimeSpan timespan)

Suspends the algorithm until the specified timespan elapses.

public void Sleep(TimeSpan timespan)
api.Sleep(timespan: TimeSpan) -> None

Parameters

Name C# type Python type Description
timespan TimeSpan TimeSpan The Timespan during which the algorithm should not react to any events.

Examples

Sleep(TimeSpan.FromSeconds(5));
Print("Resumed at {0}", Server.Time);
from System import TimeSpan
api.Sleep(TimeSpan.FromSeconds(5))
api.Print(f"Resumed at {api.Server.Time}")

Sleep(int milliseconds)

Suspends the algorithm until the specified number of milliseconds elapses.

public void Sleep(int milliseconds)
api.Sleep(milliseconds: int) -> None

Parameters

Name C# type Python type Description
milliseconds int int The number of milliseconds for which the algorithm should be suspended.

Examples

Sleep(500);
Print("Resumed at {0}", Server.Time);
api.Sleep(500)
api.Print(f"Resumed at {api.Server.Time}")

Sleep(DateTime dateTime)

Suspends the algorithm until the specified datetime.

public void Sleep(DateTime dateTime)
api.Sleep(dateTime: DateTime) -> None

Parameters

Name C# type Python type Description
dateTime DateTime DateTime The DateTime until the algorithm should be suspended.

Examples

var wakeUpTime = Server.Time.AddMinutes(1);
Sleep(wakeUpTime);
Print("Resumed at {0}", Server.Time);
wakeUpTime = api.Server.Time.AddMinutes(1)
api.Sleep(wakeUpTime)
api.Print(f"Resumed at {api.Server.Time}")