StockSharp/StockSharp · error · ArgumentOutOfRangeException
parameters
Error message
parameters
What it means
GpuTemaCalculator.Calculate throws ArgumentOutOfRangeException(nameof(parameters)) at line 65 when the GpuTemaParams[] array is empty. The params array sizes the kernel grid and output buffer (totalSize * parameters.Length); an empty array produces a degenerate zero-extent launch, so it is rejected before flattening and GPU allocation.
Source
Thrown at Algo.Gpu/Indicators/GpuTemaCalculator.cs:65
/// <param name="accelerator">ILGPU accelerator.</param>
public GpuTemaCalculator(Context context, Accelerator accelerator)
: base(context, accelerator)
{
_kernel = Accelerator.LoadAutoGroupedStreamKernel
<Index2D, ArrayView<GpuCandle>, ArrayView<GpuIndicatorResult>, ArrayView<int>, ArrayView<int>, ArrayView<GpuTemaParams>>(TemaParamsSeriesKernel);
}
/// <inheritdoc />
public override GpuIndicatorResult[][][] Calculate(GpuCandle[][] candlesSeries, GpuTemaParams[] 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;
}
var flatCandles = new GpuCandle[totalSize];
var offset = 0;View on GitHub (pinned to 601a191de6)
Solutions
- Pass a GpuTemaParams[] with at least one element.
- Short-circuit upstream when the params list is empty.
- Validate parameter generation/config so empty results are explicit.
- Caller guard: if (parameters.Length == 0) return empty;
Example fix
// before calc.Calculate(candlesSeries, Array.Empty<GpuTemaParams>()); // after if (parameters.Length == 0) return Array.Empty<GpuIndicatorResult[][]>(); calc.Calculate(candlesSeries, parameters);
Defensive patterns
Strategy: validation
Validate before calling
if (parameters is null || parameters.Length == 0)
throw new ArgumentException("At least one GpuTemaParams is required.", nameof(parameters)); Type guard
static bool HasParameters<T>(T[] parameters) => parameters is { Length: > 0 }; Try / catch
try { result = calc.Calculate(candlesSeries, parameters); }
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == "parameters")
{ /* log empty params; skip or default */ } Prevention
- Validate parameters.Length > 0 before calling Calculate.
- Make param generation surface empty results explicitly.
- Unit-test the empty-params throw contract.
- Never forward a swept params array without a count check.
When it happens
Trigger: Calling Calculate with parameters = Array.Empty<GpuTemaParams>(). Occurs when TEMA parameter generation yields nothing or a config list is empty.
Common situations: Empty parameters config; parameter sweep with no combos; deserialized empty JSON array; UI flow removing all TEMA parameter sets.
Related errors
AI-assisted analysis of StockSharp/StockSharp@601a191de6 (2026-08-13).
Data as JSON: /api/errors/2603dc4e0c3da60f.
Report an issue: GitHub.