StockSharp/StockSharp · warning · ArgumentOutOfRangeException
nameof(parameters)
Error message
nameof(parameters)
What it means
The GpuRelativeVigorIndexSignalCalculator.Calculate method throws ArgumentOutOfRangeException(nameof(parameters)) when the parameters array is empty. This is the wrong exception type for empty-collection validation — ArgumentOutOfRangeException is designed for scalar values outside an allowed range. The idiomatic choice is ArgumentException with a message. The single-argument constructor omits any descriptive error text.
Source
Thrown at Algo.Gpu/Indicators/GpuRelativeVigorIndexSignalCalculator.cs:65
/// <param name="accelerator">ILGPU accelerator.</param>
public GpuRelativeVigorIndexSignalCalculator(Context context, Accelerator accelerator)
: base(context, accelerator)
{
_kernel = Accelerator.LoadAutoGroupedStreamKernel
<Index3D, ArrayView<GpuCandle>, ArrayView<GpuIndicatorResult>, ArrayView<int>, ArrayView<int>, ArrayView<GpuRelativeVigorIndexSignalParams>>(RelativeVigorIndexSignalKernel);
}
/// <inheritdoc />
public override GpuIndicatorResult[][][] Calculate(GpuCandle[][] candlesSeries, GpuRelativeVigorIndexSignalParams[] 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;
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 maxLen = 0;
var offset = 0;View on GitHub (pinned to 601a191de6)
Solutions
- Replace ArgumentOutOfRangeException with ArgumentException and a descriptive message: throw new ArgumentException("Parameters array must not be empty.", nameof(parameters));
- Validate the params collection upstream and skip the call when empty.
- Document the non-empty contract on the base class method.
Example fix
// before
if (parameters.Length == 0)
throw new ArgumentOutOfRangeException(nameof(parameters));
// after
if (parameters.Length == 0)
throw new ArgumentException("Parameters array must not be empty.", nameof(parameters)); Defensive patterns
Strategy: validation
Validate before calling
// Validate before calling Calculate to avoid the exception entirely
if (parameters is null || parameters.Length == 0)
{
return Array.Empty<GpuIndicatorResult[][]>();
}
var results = calculator.Calculate(candlesSeries, parameters); Type guard
static bool IsValidParams<TParam>(TParam[] parameters) where TParam : struct
=> parameters is { Length: > 0 }; Prevention
- Always check parameters.Length > 0 before calling Calculate.
- Skip the call when no parameter sets are selected.
- Unit-test the empty-params boundary case.
When it happens
Trigger: Calling GpuRelativeVigorIndexSignalCalculator.Calculate(candlesSeries, parameters) where parameters is Array.Empty<GpuRelativeVigorIndexSignalParams>(). Null guard passes; parameters.Length == 0 throws at line 65.
Common situations: Dynamic param-set builders filtering to zero entries. Deserialization producing empty arrays. Test edge cases. Config-driven selection with no RVGI signal variant active.
Related errors
AI-assisted analysis of StockSharp/StockSharp@601a191de6 (2026-08-13).
Data as JSON: /api/errors/020f769b2cac9043.
Report an issue: GitHub.