Skip to content

BacktestingDataSourceOptions constructor

constructor · BacktestingDataSourceOptions · cAlgo.API Since 5.3

DesktopCLICloud

Represents options of a backtesting data source, used for creating new data source.

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.

Overloads

BacktestingDataSourceOptions(BacktestingDataSourceDataType SupportedDataTypes, Func<BacktestingDataSourceMinMaxTimeArgs, BacktestingMinMaxTime> MinMaxTimeHandler, Action<BacktestingDataRequest> DataRequestHandler)

Represents options of a backtesting data source, used for creating new data source.

public BacktestingDataSourceOptions(BacktestingDataSourceDataType SupportedDataTypes, Func<BacktestingDataSourceMinMaxTimeArgs, BacktestingMinMaxTime> MinMaxTimeHandler, Action<BacktestingDataRequest> DataRequestHandler)
BacktestingDataSourceOptions(SupportedDataTypes: BacktestingDataSourceDataType, MinMaxTimeHandler: Callable[[BacktestingDataSourceMinMaxTimeArgs], BacktestingMinMaxTime], DataRequestHandler: Callable[[BacktestingDataRequest], None])

Parameters

Name C# type Python type Description
SupportedDataTypes BacktestingDataSourceDataType BacktestingDataSourceDataType Supported data types (ex: BacktestingDataSourceDateType.Tick | BacktestingDataSourceDateType.M1OpenPrices)
MinMaxTimeHandler Func<BacktestingDataSourceMinMaxTimeArgs, BacktestingMinMaxTime> Callable[[BacktestingDataSourceMinMaxTimeArgs], BacktestingMinMaxTime] Handler function for getting minimum and maximum time.
DataRequestHandler Action<BacktestingDataRequest> Callable[[BacktestingDataRequest], None] Handler function for handling data requests.

Examples

protected override void OnStart()
{
    var options = new BacktestingDataSourceOptions(BacktestingDataSourceDataType.Tick | BacktestingDataSourceDataType.M1OpenPrices, OnMinMaxTimeRequested, OnDataRequested);
    Backtesting.DataSources.Add("My Data", options);
    Print("Supported data types: {0}", options.SupportedDataTypes);
}

private BacktestingMinMaxTime OnMinMaxTimeRequested(BacktestingDataSourceMinMaxTimeArgs args) => new(Server.Time.AddMonths(-6), Server.Time);

private void OnDataRequested(BacktestingDataRequest request) => request.Fail("Data is not available yet");
from System import Action, Func

def on_start(self):
    options = BacktestingDataSourceOptions(BacktestingDataSourceDataType.Tick | BacktestingDataSourceDataType.M1OpenPrices, Func[BacktestingDataSourceMinMaxTimeArgs, BacktestingMinMaxTime](self.on_min_max_time_requested), Action[BacktestingDataRequest](self.on_data_requested))
    api.Backtesting.DataSources.Add("My Data", options)
    api.Print(f"Supported data types: {options.SupportedDataTypes}")

def on_min_max_time_requested(self, args):
    return BacktestingMinMaxTime(api.Server.Time.AddMonths(-6), api.Server.Time)

def on_data_requested(self, request):
    request.Fail("Data is not available yet")

See also

BacktestingDataSourceOptions(BacktestingDataSourceOptions original)

public BacktestingDataSourceOptions(BacktestingDataSourceOptions original)
BacktestingDataSourceOptions(original: BacktestingDataSourceOptions)

Parameters

Name C# type Python type Description
original BacktestingDataSourceOptions BacktestingDataSourceOptions