StockSharp/StockSharp · error · ArgumentOutOfRangeException

candlesSeries

Error message

candlesSeries

What it means

Thrown by GpuEaseOfMovementCalculator.Calculate as ArgumentOutOfRangeException(nameof(candlesSeries)) when the outer GpuCandle[][] has Length 0. With seriesCount 0 the Index2D(parameters.Length, seriesCount) kernel dispatch is degenerate and output buffers would be shapeless, so the empty outer array is rejected before flattening.

Source

Thrown at Algo.Gpu/Indicators/GpuEaseOfMovementCalculator.cs:54

	/// Initializes a new instance of the <see cref="GpuEaseOfMovementCalculator"/> class.
	/// </summary>
	/// <param name="context">ILGPU context.</param>
	/// <param name="accelerator">ILGPU accelerator.</param>
	public GpuEaseOfMovementCalculator(Context context, Accelerator accelerator)
		: base(context, accelerator)
	{
		_kernel = Accelerator.LoadAutoGroupedStreamKernel
				<Index2D, ArrayView<GpuCandle>, ArrayView<GpuIndicatorResult>, ArrayView<float>, ArrayView<int>, ArrayView<int>, ArrayView<GpuEaseOfMovementParams>>(EaseOfMovementParamsSeriesKernel);
	}

	/// <inheritdoc />
	public override GpuIndicatorResult[][][] Calculate(GpuCandle[][] candlesSeries, GpuEaseOfMovementParams[] 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

  1. Guard candlesSeries.Length > 0 before the call and skip empty batches.
  2. Ensure the upstream loader/filter never yields a zero-length outer array.
  3. Handle 'no data' as a no-op earlier in the pipeline.
  4. Verify the data source returned bars for the requested symbols/dates.

Example fix

// before
calc.Calculate(candlesSeries, parameters);

// after
if (candlesSeries is null || candlesSeries.Length == 0)
    return Array.Empty<GpuIndicatorResult[][]>();
calc.Calculate(candlesSeries, parameters);
Defensive patterns

Strategy: validation

Validate before calling

// C#
if (candlesSeries is null || candlesSeries.Length == 0)
{
    return Array.Empty<GpuIndicatorResult[][]>();
}
// safe to call: calculator.Calculate(candlesSeries, parameters);

Type guard

// C#
static bool HasAnySeries(GpuCandle[][] candlesSeries)
    => candlesSeries is { Length: > 0 };

Try / catch

try
{
    result = calculator.Calculate(candlesSeries, parameters);
}
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == "candlesSeries")
{
    _logger.LogWarning("Empty candlesSeries passed to {Calc}", calculator.GetType().Name);
    result = Array.Empty<GpuIndicatorResult[][]>();
}

Prevention

When it happens

Trigger: Calling GpuEaseOfMovementCalculator.Calculate(Array.Empty<GpuCandle[]>(), parameters) or passing a GpuCandle[][] whose outer length is 0.

Common situations: Empty symbol universe after filtering, date window with no candles, weekend/holiday query, or loader returning an empty batch.

Related errors


AI-assisted analysis of StockSharp/StockSharp@601a191de6 (2026-08-13). Data as JSON: /api/errors/f64f337f94fa8718. Report an issue: GitHub.