QuantConnect/Lean · error · RegressionTestException

_customNotWarmUp indicator wasn't expected to be warmed up

Error message

_customNotWarmUp indicator wasn't expected to be warmed up

What it means

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.

Source

Thrown at Algorithm.CSharp/CustomWarmUpPeriodIndicatorAlgorithm.cs:76

            // Check _customWarmUp indicator has already been warmed up with the requested data
            if (!_customWarmUp.IsReady)
            {
                throw new RegressionTestException("_customWarmUp indicator was expected to be ready");
            }
            if (_customWarmUp.Samples != 60)
            {
                throw new RegressionTestException("_customWarmUp indicator was expected to have processed 60 datapoints already");
            }

            // Try to warm up _customNotWarmUp indicator. It's expected from LEAN to skip the warm up process
            // because this indicator doesn't implement IIndicatorWarmUpPeriodProvider
            WarmUpIndicator("SPY", _customNotWarmUp, Resolution.Minute);

            // Check _customNotWarmUp indicator is not ready, because the warm up process was skipped
            if (_customNotWarmUp.IsReady)
            {
                throw new RegressionTestException("_customNotWarmUp indicator wasn't expected to be warmed up");
            }

            WarmUpIndicator("SPY", _customNotInherit, Resolution.Minute);
            // Check _customWarmUp indicator has already been warmed up with the requested data
            if (!_customNotInherit.IsReady)
            {
                throw new RegressionTestException("_customNotInherit indicator was expected to be ready");
            }
            if (_customNotInherit.Samples != 60)
            {
                throw new RegressionTestException("_customNotInherit indicator was expected to have processed 60 datapoints already");
            }

            WarmUpIndicator("SPY", _duplicateSMA, Resolution.Minute);
            // Check _customWarmUp indicator has already been warmed up with the requested data
            if (!_duplicateSMA.IsReady)
            {
                throw new RegressionTestException("_duplicateSMA indicator was expected to be ready");

View on GitHub (pinned to d2c3659f87)

Solutions

  1. Confirm CSMANotWarmUp does not implement IIndicatorWarmUpPeriodProvider (only CSMAWithWarmUp does).
  2. Trace WarmUpIndicator to verify it checks for IIndicatorWarmUpPeriodProvider and skips indicators that don't implement it.
  3. Check that no default warm-up period is applied when the interface is absent.
  4. If testing engine changes, ensure the type-check `is IIndicatorWarmUpPeriodProvider` gates the warm-up feeding loop.

Example fix

// before — engine warms up all indicators regardless of interface
public void WarmUpIndicator(Symbol symbol, IndicatorBase indicator, Resolution res)
{
    var history = History(symbol, 60, res); // always 60, ignores interface
    foreach (var bar in history) indicator.Update(bar);
}

// after — skip warm-up for indicators without IIndicatorWarmUpPeriodProvider
public void WarmUpIndicator(Symbol symbol, IndicatorBase indicator, Resolution res)
{
    if (indicator is not IIndicatorWarmUpPeriodProvider warmUpProvider)
        return; // skip — no warm-up period declared
    var history = History(symbol, warmUpProvider.WarmUpPeriod, res);
    foreach (var bar in history) indicator.Update(bar);
}
Defensive patterns

Strategy: type-guard

Validate before calling

// Before warm-up, check if the indicator implements the interface
if (_customNotWarmUp is IIndicatorWarmUpPeriodProvider)
    WarmUpIndicator("SPY", _customNotWarmUp, Resolution.Minute);
else
    Log("Skipping warm-up: indicator does not implement IIndicatorWarmUpPeriodProvider");

Type guard

bool ShouldSkipWarmUp(IndicatorBase indicator) => indicator is not IIndicatorWarmUpPeriodProvider;

Prevention

When it happens

Trigger: _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.

Common situations: 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.

Related errors


AI-assisted analysis of QuantConnect/Lean@d2c3659f87 (2026-08-13). Data as JSON: /api/errors/a4029844e3260a6f. Report an issue: GitHub.