StockSharp/StockSharp · error · ArgumentOutOfRangeException

parameters

Error message

parameters

What it means

ArgumentOutOfRangeException with ParamName="parameters", thrown by GpuLinearRegressionForecastCalculator.Calculate at `if (parameters.Length == 0) throw new ArgumentOutOfRangeException(nameof(parameters))` (Algo.Gpu/Indicators/GpuLinearRegressionForecastCalculator.cs:64). The Index3D grid's parameter dimension requires at least one GpuLinearRegressionForecastParams set; zero sets means the kernel has nothing to iterate, so the guard rejects it before launch.

Source

Thrown at Algo.Gpu/Indicators/GpuLinearRegressionForecastCalculator.cs:64

	/// <param name="context">ILGPU context.</param>
	/// <param name="accelerator">ILGPU accelerator.</param>
	public GpuLinearRegressionForecastCalculator(Context context, Accelerator accelerator)
		: base(context, accelerator)
	{
		_kernel = Accelerator.LoadAutoGroupedStreamKernel<Index3D, ArrayView<GpuCandle>, ArrayView<GpuIndicatorResult>, ArrayView<int>, ArrayView<int>, ArrayView<GpuLinearRegressionForecastParams>>(LinearRegressionForecastParamsSeriesKernel);
	}

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

  1. Guard the caller: require parameters.Length >= 1 before invoking, else throw a clear domain exception or skip.
  2. Verify the parameter-expansion step yields at least one valid set.
  3. Inject a default forecast-params set when config supplies none.

Example fix

// before
var results = calc.Calculate(candlesSeries, parameters);

// after
if (parameters is null || parameters.Length == 0)
    throw new InvalidOperationException("At least one forecast parameter set is required.");
var results = calc.Calculate(candlesSeries, parameters);
Defensive patterns

Strategy: validation

Validate before calling

if (parameters is null || parameters.Length == 0)
    throw new InvalidOperationException("At least one forecast parameter set is required.");
var results = calc.Calculate(candlesSeries, parameters);

Type guard

static bool IsValidParams(GpuLinearRegressionForecastParams[] p) => p is not null && p.Length > 0;

Try / catch

try { var r = calc.Calculate(candlesSeries, parameters); }
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == "parameters")
{ /* surface config error */ }

Prevention

When it happens

Trigger: Passing an empty GpuLinearRegressionForecastParams[] — e.g. a period sweep that produced no valid combinations, or an empty config block.

Common situations: Optimization grids fully filtered by validation; empty `parameters:` in config; UI with no forecast-period selection; tests omitting params.

Related errors


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