{"record":{"id":"a4029844e3260a6f","repo":"QuantConnect/Lean","slug":"customnotwarmup-indicator-wasn-t-expected-to-be-w","errorCode":null,"errorMessage":"_customNotWarmUp indicator wasn't expected to be warmed up","messagePattern":"_customNotWarmUp indicator wasn't expected to be warmed up","errorType":"exception","errorClass":"RegressionTestException","httpStatus":null,"severity":"error","filePath":"Algorithm.CSharp/CustomWarmUpPeriodIndicatorAlgorithm.cs","lineNumber":76,"sourceCode":"\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\n            if (!_customNotInherit.IsReady)\n            {\n                throw new RegressionTestException(\"_customNotInherit indicator was expected to be ready\");\n            }\n            if (_customNotInherit.Samples != 60)\n            {\n                throw new RegressionTestException(\"_customNotInherit indicator was expected to have processed 60 datapoints already\");\n            }\n\n            WarmUpIndicator(\"SPY\", _duplicateSMA, Resolution.Minute);\n            // Check _customWarmUp indicator has already been warmed up with the requested data\n            if (!_duplicateSMA.IsReady)\n            {\n                throw new RegressionTestException(\"_duplicateSMA indicator was expected to be ready\");","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.CSharp/CustomWarmUpPeriodIndicatorAlgorithm.cs#L58-L94","documentation":"This RegressionTestException is thrown in Initialize after WarmUpIndicator(\"SPY\", _customNotWarmUp, Resolution.Minute). It asserts that _customNotWarmUp (CSMANotWarmUp, which does NOT implement IIndicatorWarmUpPeriodProvider) is NOT ready. LEAN throws it to verify that WarmUpIndicator correctly skips warm-up for indicators that don't declare a WarmUpPeriod — they should remain un-ready until live data accumulates.","triggerScenarios":"_customNotWarmUp.IsReady is true after WarmUpIndicator. This means the warm-up process fed data to an indicator that shouldn't receive warm-up because it lacks IIndicatorWarmUpPeriodProvider. The engine incorrectly warmed up an indicator without a declared warm-up period.","commonSituations":"A LEAN version change to WarmUpIndicator made it warm up ALL indicators regardless of IIndicatorWarmUpPeriodProvider implementation, or the interface check was inverted/removed. Also occurs if the warm-up logic falls back to a default period instead of skipping.","solutions":["Confirm CSMANotWarmUp does not implement IIndicatorWarmUpPeriodProvider (only CSMAWithWarmUp does).","Trace WarmUpIndicator to verify it checks for IIndicatorWarmUpPeriodProvider and skips indicators that don't implement it.","Check that no default warm-up period is applied when the interface is absent.","If testing engine changes, ensure the type-check `is IIndicatorWarmUpPeriodProvider` gates the warm-up feeding loop."],"exampleFix":"// before — engine warms up all indicators regardless of interface\npublic void WarmUpIndicator(Symbol symbol, IndicatorBase indicator, Resolution res)\n{\n    var history = History(symbol, 60, res); // always 60, ignores interface\n    foreach (var bar in history) indicator.Update(bar);\n}\n\n// after — skip warm-up for indicators without IIndicatorWarmUpPeriodProvider\npublic void WarmUpIndicator(Symbol symbol, IndicatorBase indicator, Resolution res)\n{\n    if (indicator is not IIndicatorWarmUpPeriodProvider warmUpProvider)\n        return; // skip — no warm-up period declared\n    var history = History(symbol, warmUpProvider.WarmUpPeriod, res);\n    foreach (var bar in history) indicator.Update(bar);\n}","handlingStrategy":"type-guard","validationCode":"// Before warm-up, check if the indicator implements the interface\nif (_customNotWarmUp is IIndicatorWarmUpPeriodProvider)\n    WarmUpIndicator(\"SPY\", _customNotWarmUp, Resolution.Minute);\nelse\n    Log(\"Skipping warm-up: indicator does not implement IIndicatorWarmUpPeriodProvider\");","typeGuard":"bool ShouldSkipWarmUp(IndicatorBase indicator) => indicator is not IIndicatorWarmUpPeriodProvider;","tryCatchPattern":null,"preventionTips":["Understand that WarmUpIndicator intentionally skips indicators without IIndicatorWarmUpPeriodProvider — this is correct behavior.","If you want warm-up for a custom indicator, implement the interface and set WarmUpPeriod.","Don't manually feed history to indicators that lack the interface — let live data accumulate naturally."],"tags":["quantconnect","lean","indicator","warmup","interface-check","regression-test"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}