QuantConnect/Lean · error · RegressionTestException
_duplicateSMA indicator was expected to be ready
Error message
_duplicateSMA indicator was expected to be ready
What it means
This RegressionTestException is thrown in Initialize after WarmUpIndicator("SPY", _duplicateSMA, Resolution.Minute). _duplicateSMA is a second SimpleMovingAverage(60) added to match a Python counterpart algorithm. It asserts _duplicateSMA.IsReady == true, verifying that multiple built-in indicators can be warmed up independently in the same Initialize call.
Source
Thrown at Algorithm.CSharp/CustomWarmUpPeriodIndicatorAlgorithm.cs:94
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");
}
if (_duplicateSMA.Samples != 60)
{
throw new RegressionTestException("_duplicateSMA indicator was expected to have processed 60 datapoints already");
}
}
public override void OnData(Slice slice)
{
if (!Portfolio.Invested)
{
SetHoldings("SPY", 1);
}
if (Time.Second == 0)
{
// Compute the difference between the indicators values
var diff = Math.Abs(_customNotWarmUp.Current.Value - _customWarmUp.Current.Value);View on GitHub (pinned to d2c3659f87)
Solutions
- Verify _duplicateSMA is a distinct instance (not a reference to _customNotInherit).
- Trace WarmUpIndicator to confirm it doesn't skip subsequent indicators on the same symbol due to a cache hit.
- Check that _duplicateSMA.WarmUpPeriod is correctly set (60) and the interface is detected.
- If testing engine changes, ensure warm-up history is re-fetched or re-delivered for each indicator, not cached per symbol.
Example fix
// before — warm-up caches history per symbol, second indicator misses out
private readonly Dictionary<Symbol, List<IBaseData>> _warmupCache = new();
public void WarmUpIndicator(Symbol symbol, IndicatorBase indicator, Resolution res)
{
if (_warmupCache.ContainsKey(symbol)) return; // BUG: skips second indicator
// ...
}
// after — warm up each indicator independently
public void WarmUpIndicator(Symbol symbol, IndicatorBase indicator, Resolution res)
{
if (indicator is not IIndicatorWarmUpPeriodProvider provider) return;
var history = History<IBaseData>(symbol, provider.WarmUpPeriod, res);
foreach (var bar in history) indicator.Update(bar);
} Defensive patterns
Strategy: validation
Validate before calling
// Validate each indicator independently after warm-up
WarmUpIndicator("SPY", _duplicateSMA, Resolution.Minute);
if (!_duplicateSMA.IsReady)
{
Log($"_duplicateSMA not ready. Samples: {_duplicateSMA.Samples}");
// Check if warm-up history was cached and not re-delivered
var history = History<IBaseData>("SPY", 60, Resolution.Minute);
Log($"History available: {history.Count()} bars");
} Prevention
- Ensure WarmUpIndicator does not cache history per symbol in a way that skips subsequent indicators.
- Verify each indicator instance is distinct (not accidentally aliased to the same reference).
- Warm up each indicator in sequence and check IsReady immediately after each call.
When it happens
Trigger: _duplicateSMA.IsReady is false after WarmUpIndicator. This means the second SMA's warm-up failed even though the first SMA (_customNotInherit) succeeded. Causes: WarmUpIndicator has a per-symbol caching issue that prevents warming up a second indicator on the same symbol, or the second indicator's WarmUpPeriod is not detected.
Common situations: A LEAN version change to WarmUpIndicator added caching that prevents re-warming a second indicator on the same symbol within one Initialize, the history data was consumed/cached and not re-delivered, or the warm-up loop only processes the first registered indicator per symbol.
Related errors
- _customNotInherit indicator was expected to be ready
- _customNotInherit indicator was expected to have processed 6
- _customWarmUp indicator was expected to be ready
- _customWarmUp indicator was expected to have processed 60 da
- _customNotWarmUp indicator wasn't expected to be warmed up
AI-assisted analysis of QuantConnect/Lean@d2c3659f87 (2026-08-13).
Data as JSON: /api/errors/b02ee90c54076770.
Report an issue: GitHub.