{"record":{"id":"05c06851f10e0dd1","repo":"StockSharp/StockSharp","slug":"candlesseries-05c068","errorCode":null,"errorMessage":"candlesSeries","messagePattern":"candlesSeries","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"Algo.Gpu/Indicators/GpuLinearRegSlopeCalculator.cs","lineNumber":62,"sourceCode":"\t/// Initializes a new instance of the <see cref=\"GpuLinearRegSlopeCalculator\"/> class.\n\t/// </summary>\n\t/// <param name=\"context\">ILGPU context.</param>\n\t/// <param name=\"accelerator\">ILGPU accelerator.</param>\n\tpublic GpuLinearRegSlopeCalculator(Context context, Accelerator accelerator)\n\t: base(context, accelerator)\n\t{\n\t\t_kernel = Accelerator.LoadAutoGroupedStreamKernel\n\t\t\t<Index2D, ArrayView<GpuCandle>, ArrayView<GpuIndicatorResult>, ArrayView<int>, ArrayView<int>, ArrayView<GpuLinearRegSlopeParams>>(LinearRegSlopeParamsSeriesKernel);\n\t}\n\n\t/// <inheritdoc />\n\tpublic override GpuIndicatorResult[][][] Calculate(GpuCandle[][] candlesSeries, GpuLinearRegSlopeParams[] parameters)\n\t{\n\t\tArgumentNullException.ThrowIfNull(candlesSeries);\n\t\tArgumentNullException.ThrowIfNull(parameters);\n\n\t\tif (candlesSeries.Length == 0)\n\t\t\tthrow new ArgumentOutOfRangeException(nameof(candlesSeries));\n\n\t\tif (parameters.Length == 0)\n\t\t\tthrow new ArgumentOutOfRangeException(nameof(parameters));\n\n\t\tvar seriesCount = candlesSeries.Length;\n\n\t\tvar totalSize = 0;\n\t\tvar seriesOffsets = new int[seriesCount];\n\t\tvar seriesLengths = new int[seriesCount];\n\n\t\tfor (var s = 0; s < seriesCount; s++)\n\t\t{\n\t\t\tseriesOffsets[s] = totalSize;\n\t\t\tvar len = candlesSeries[s]?.Length ?? 0;\n\t\t\tseriesLengths[s] = len;\n\t\t\ttotalSize += len;\n\t\t}\n","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/StockSharp/StockSharp/blob/601a191de678bff83da28b14828f8885214ca71c/Algo.Gpu/Indicators/GpuLinearRegSlopeCalculator.cs#L44-L80","documentation":"ArgumentOutOfRangeException with ParamName=\"candlesSeries\", thrown by GpuLinearRegSlopeCalculator.Calculate at the empty-array guard (Algo.Gpu/Indicators/GpuLinearRegSlopeCalculator.cs:62). The linear-regression slope kernel is launched over an Index2D grid whose dimensions depend on the candle series count; an empty outer array gives a degenerate zero-length launch and an undefined result[][][] shape, so it is rejected up front.","triggerScenarios":"Calling Calculate with candlesSeries.Length == 0 — an empty GpuCandle[][] produced by a filtering step that removed all series, or an explicit Array.Empty<GpuCandle[]>() payload.","commonSituations":"Symbol/date filters in a backtester that exclude everything; pipeline stages that pass through an empty batch without short-circuiting; empty-input edge-case tests.","solutions":["Short-circuit the caller when candlesSeries is empty (return an empty/identity result instead of calling Calculate).","Tighten the upstream filter so the batch always contains at least one series.","Add a batch-boundary assertion that fails fast with a domain-specific message rather than relying on the GPU guard."],"exampleFix":"// before\nvar results = calc.Calculate(candlesSeries, parameters);\n\n// after\nif (candlesSeries is null || candlesSeries.Length == 0)\n    return Array.Empty<GpuIndicatorResult[][]>();\nvar results = calc.Calculate(candlesSeries, parameters);","handlingStrategy":"validation","validationCode":"if (candlesSeries is null || candlesSeries.Length == 0)\n    return Array.Empty<GpuIndicatorResult[][]>();\nvar results = calc.Calculate(candlesSeries, parameters);","typeGuard":"static bool IsValidSeries(GpuCandle[][] s) => s is not null && s.Length > 0;","tryCatchPattern":"try { var r = calc.Calculate(candlesSeries, parameters); }\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == \"candlesSeries\")\n{ /* empty batch: return empty result */ }","preventionTips":["Short-circuit empty batches at the caller, not inside the GPU method.","Test the symbol/date filter for the zero-series edge case.","Log empty batches as a data-quality signal upstream."],"tags":["gpu","argumentoutofrange","argument-validation","ilgpu","linearreg-slope","indicators"],"backgroundTag":null,"analyzedSha":"601a191de678bff83da28b14828f8885214ca71c","analyzedAt":"2026-08-13T20:43:24.460Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}