{"record":{"id":"51485a33bb68045a","repo":"QuantConnect/Lean","slug":"customwarmup-indicator-was-expected-to-be-ready","errorCode":null,"errorMessage":"_customWarmUp indicator was expected to be ready","messagePattern":"_customWarmUp indicator was expected to be ready","errorType":"exception","errorClass":"RegressionTestException","httpStatus":null,"severity":"error","filePath":"Algorithm.CSharp/CustomWarmUpPeriodIndicatorAlgorithm.cs","lineNumber":62,"sourceCode":"            _customWarmUp = new CSMAWithWarmUp(\"_customWarmUp\", 60);\n            _customNotInherit = new SimpleMovingAverage(\"_customNotInherit\", 60);\n            // using 2nd SMA to match counterpart python algorithm ( CustomSMA + csharpIndicator )\n            // so that AlgorithmHistoryDataPoints are the same in both\n            _duplicateSMA = new SimpleMovingAverage(\"_duplicateSMA\", 60);\n\n            // Register the daily data of \"SPY\" to automatically update both indicators\n            RegisterIndicator(\"SPY\", _customWarmUp, Resolution.Minute);\n            RegisterIndicator(\"SPY\", _customNotWarmUp, Resolution.Minute);\n            RegisterIndicator(\"SPY\", _customNotInherit, Resolution.Minute);\n            RegisterIndicator(\"SPY\", _duplicateSMA, Resolution.Minute);\n\n            // Warm up _customWarmUp indicator\n            WarmUpIndicator(\"SPY\", _customWarmUp, Resolution.Minute);\n\n            // Check _customWarmUp indicator has already been warmed up with the requested data\n            if (!_customWarmUp.IsReady)\n            {\n                throw new RegressionTestException(\"_customWarmUp indicator was expected to be ready\");\n            }\n            if (_customWarmUp.Samples != 60)\n            {\n                throw new RegressionTestException(\"_customWarmUp indicator was expected to have processed 60 datapoints already\");\n            }\n\n            // Try to warm up _customNotWarmUp indicator. It's expected from LEAN to skip the warm up process\n            // because this indicator doesn't implement IIndicatorWarmUpPeriodProvider\n            WarmUpIndicator(\"SPY\", _customNotWarmUp, Resolution.Minute);\n\n            // Check _customNotWarmUp indicator is not ready, because the warm up process was skipped\n            if (_customNotWarmUp.IsReady)\n            {\n                throw new RegressionTestException(\"_customNotWarmUp indicator wasn't expected to be warmed up\");\n            }\n\n            WarmUpIndicator(\"SPY\", _customNotInherit, Resolution.Minute);\n            // Check _customWarmUp indicator has already been warmed up with the requested data","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.CSharp/CustomWarmUpPeriodIndicatorAlgorithm.cs#L44-L80","documentation":"This RegressionTestException is thrown in Initialize after WarmUpIndicator(\"SPY\", _customWarmUp, Resolution.Minute). It asserts that the custom indicator _customWarmUp (a CSMAWithWarmUp implementing IIndicatorWarmUpPeriodProvider) is ready. LEAN throws it to verify that WarmUpIndicator successfully feeds historical data to indicators that declare a WarmUpPeriod, bringing them to IsReady == true before live data begins.","triggerScenarios":"_customWarmUp.IsReady is false after WarmUpIndicator. This means the warm-up process did not feed enough data points (60) to the indicator. Causes include: history data unavailable, WarmUpPeriod not read correctly, or the warm-up loop not executing the expected number of iterations.","commonSituations":"History data for SPY minute bars is missing or insufficient for the warm-up window (60 minutes before StartDate), a LEAN version change to WarmUpIndicator or history retrieval broke the data feeding, or IIndicatorWarmUpPeriodProvider.WarmUpPeriod is not being read by the warm-up engine.","solutions":["Verify that minute-resolution history data exists for at least 60 bars before SetStartDate for SPY.","Check that CSMAWithWarmUp.WarmUpPeriod returns 60 and IIndicatorWarmUpPeriodProvider is properly implemented.","Trace WarmUpIndicator execution to confirm it retrieves history and feeds each bar to the indicator.","If testing engine changes, verify the history provider delivers the correct number of bars for the warm-up period."],"exampleFix":"// before — custom indicator must implement IIndicatorWarmUpPeriodProvider for WarmUpIndicator to work\nprivate class CSMANotWarmUp : IndicatorBase<IBaseData>\n{\n    public override bool IsReady => _queue.Count == _period;\n    // no WarmUpPeriod — WarmUpIndicator skips this\n}\n\n// after — implement the interface\nprivate class CSMAWithWarmUp : CSMANotWarmUp, IIndicatorWarmUpPeriodProvider\n{\n    public CSMAWithWarmUp(string name, int period) : base(name, period)\n    {\n        WarmUpPeriod = period; // 60\n    }\n    public int WarmUpPeriod { get; }\n}","handlingStrategy":"validation","validationCode":"// Validate warm-up readiness before asserting\nWarmUpIndicator(\"SPY\", _customWarmUp, Resolution.Minute);\nif (!_customWarmUp.IsReady)\n    Log($\"_customWarmUp not ready after warm-up. Samples: {_customWarmUp.Samples}, WarmUpPeriod: {((IIndicatorWarmUpPeriodProvider)_customWarmUp).WarmUpPeriod}\");","typeGuard":"// Check if an indicator supports warm-up before calling WarmUpIndicator\nbool SupportsWarmUp(IndicatorBase indicator) => indicator is IIndicatorWarmUpPeriodProvider;","tryCatchPattern":null,"preventionTips":["Ensure custom indicators implement IIndicatorWarmUpPeriodProvider with WarmUpPeriod set to the indicator period.","Verify history data exists for at least WarmUpPeriod bars before StartDate.","Register the indicator with RegisterIndicator before calling WarmUpIndicator so the symbol resolution is known."],"tags":["quantconnect","lean","indicator","warmup","history","regression-test"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}