StockSharp/StockSharp · error · ArgumentOutOfRangeException
candlesSeries
Error message
candlesSeries
What it means
GpuSumCalculator.Calculate throws ArgumentOutOfRangeException(nameof(candlesSeries)) at line 62 when the GpuCandle[][] array is empty. Before flattening input and allocating ILGPU buffers, the method requires at least one candle series; an empty universe produces a zero-extent kernel and meaningless output, so it is rejected as a precondition violation.
Source
Thrown at Algo.Gpu/Indicators/GpuSumCalculator.cs:62
/// Initializes a new instance of the <see cref="GpuSumCalculator"/> class.
/// </summary>
/// <param name="context">ILGPU context.</param>
/// <param name="accelerator">ILGPU accelerator.</param>
public GpuSumCalculator(Context context, Accelerator accelerator)
: base(context, accelerator)
{
_paramsSeriesKernel = Accelerator.LoadAutoGroupedStreamKernel
<Index3D, ArrayView<GpuCandle>, ArrayView<GpuIndicatorResult>, ArrayView<int>, ArrayView<int>, ArrayView<GpuSumParams>>(SumParamsSeriesKernel);
}
/// <inheritdoc />
public override GpuIndicatorResult[][][] Calculate(GpuCandle[][] candlesSeries, GpuSumParams[] parameters)
{
ArgumentNullException.ThrowIfNull(candlesSeries);
ArgumentNullException.ThrowIfNull(parameters);
if (candlesSeries.Length == 0)
throw new ArgumentOutOfRangeException(nameof(candlesSeries));
if (parameters.Length == 0)
throw new ArgumentOutOfRangeException(nameof(parameters));
var seriesCount = candlesSeries.Length;
// Flatten input
var totalSize = 0;
var seriesOffsets = new int[seriesCount];
var seriesLengths = new int[seriesCount];
for (var s = 0; s < seriesCount; s++)
{
seriesOffsets[s] = totalSize;
var len = candlesSeries[s]?.Length ?? 0;
seriesLengths[s] = len;
totalSize += len;
}View on GitHub (pinned to 601a191de6)
Solutions
- Ensure at least one GpuCandle[] sub-array is passed.
- Short-circuit in the caller when the universe is empty.
- Validate data-fetch and symbol resolution to surface empty universes upstream.
- Caller guard: if (candlesSeries.Length == 0) return empty;
Example fix
// before calc.Calculate(Array.Empty<GpuCandle[]>(), parameters); // after if (candlesSeries.Length == 0) return Array.Empty<GpuIndicatorResult[][]>(); calc.Calculate(candlesSeries, parameters);
Defensive patterns
Strategy: validation
Validate before calling
if (candlesSeries is null || candlesSeries.Length == 0)
throw new ArgumentException("At least one candle series is required.", nameof(candlesSeries)); Type guard
static bool HasSeries(GpuCandle[][] series) => series is { Length: > 0 }; Try / catch
try { result = calc.Calculate(candlesSeries, parameters); }
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == "candlesSeries")
{ /* log empty universe; abort batch */ } Prevention
- Check candlesSeries.Length > 0 after the data-fetch step.
- Treat empty universe as a pipeline-stopping condition.
- Log symbol counts at each filter stage.
- Seed tests with at least one non-empty series.
When it happens
Trigger: Calling Calculate with candlesSeries = Array.Empty<GpuCandle[]>(). Triggered by empty symbol universes from filters or data fetches returning no series.
Common situations: Symbol selection step yields zero instruments; market-data fetch returns empty for the requested date range; holiday/weekend no-data; empty backtest universe config; test lacking candle data.
Related errors
AI-assisted analysis of StockSharp/StockSharp@601a191de6 (2026-08-13).
Data as JSON: /api/errors/17fa3ecba6d0adef.
Report an issue: GitHub.