BacktestingBarsData
class cAlgo.API Since 5.3
DesktopCLICloud
Represents a collection of backtesting bars data.
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
public class BacktestingBarsData
Namespace: cAlgo.API · Group: DataSource · Implements: BacktestingData
Examples
private void OnDataRequested(BacktestingDataRequest request)
{
var bars = MarketData.GetBars(request.PriceDataSourceId.TimeFrame, request.PriceDataSourceId.Symbol.Name);
var data = bars.Where(bar => bar.OpenTime >= request.StartTime && bar.OpenTime <= request.EndTime)
.Select(bar => new BacktestingBar(bar.OpenTime, bar.Open, bar.High, bar.Low, bar.Close, (long)bar.TickVolume));
request.Complete(new BacktestingBarsData(data));
}
from System import Array
def on_data_requested(self, request):
bars = api.MarketData.GetBars(request.PriceDataSourceId.TimeFrame, request.PriceDataSourceId.Symbol.Name)
data = [BacktestingBar(bar.OpenTime, bar.Open, bar.High, bar.Low, bar.Close, int(bar.TickVolume)) for bar in bars if bar.OpenTime >= request.StartTime and bar.OpenTime <= request.EndTime]
request.Complete(BacktestingBarsData(Array[BacktestingBar](data)))
Constructors
| Name | Description |
|---|---|
| BacktestingBarsDataDesktopCLICloud | Creates a new instance of BacktestingBarsData with passed data. |