BacktestingProcess.Terminate
method · BacktestingProcess · cAlgo.API
DesktopCLICloud
Terminates the backtesting process.
Environment behaviour
CLI — not supported. Available to plugins only, and plugins cannot run in the CLI.
Cloud — not supported. Available to plugins only, and plugins cannot run in the cloud.
Definition
void Terminate()
backtestingProcess.Terminate() -> None
Examples
private BacktestingProcess _process;
protected override void OnStart()
{
if (AlgoRegistry.Get("Sample Trend cBot", AlgoKind.Robot) is not RobotType robotType)
return;
var settings = new BacktestingSettings { StartTimeUtc = new DateTime(2025, 1, 1), EndTimeUtc = new DateTime(2025, 2, 1), Balance = 10000 };
_process = Backtesting.Start(robotType, "EURUSD", TimeFrame.Hour, settings);
}
protected override void OnStop()
{
if (_process != null && !_process.IsCompleted)
_process.Terminate();
}
from System import DateTime
def on_start(self):
self.process = None
algoType = api.AlgoRegistry.Get("Sample Trend cBot", AlgoKind.Robot)
if algoType is None:
return
settings = BacktestingSettings()
settings.StartTimeUtc = DateTime(2025, 1, 1)
settings.EndTimeUtc = DateTime(2025, 2, 1)
settings.Balance = 10000
self.process = api.Backtesting.Start(RobotType(algoType), "EURUSD", TimeFrame.Hour, settings)
def on_stop(self):
if self.process is not None and not self.process.IsCompleted:
self.process.Terminate()