QuantConnect/Lean · warning · RegressionTestException

{Time} unexpected symbol changed event {changedEvent}!

Error message

{Time} unexpected symbol changed event {changedEvent}!

What it means

The daily-resolution futures regression asserts SymbolChangedEvents (rollovers) occur only at midnight (Time.TimeOfDay == TimeSpan.Zero). At daily resolution a remap must align with the day boundary; an event at another time-of-day is unexpected and signals mapping fired at the wrong instant for a daily feed.

Source

Thrown at Algorithm.CSharp/BasicTemplateFuturesDailyAlgorithm.cs:102

                    // Also check if exchange is open for regular or extended hours. Since daily data comes at 8PM, this allows us prevent the
                    // algorithm from trading on friday when there is not after-market.
                    if (contract != null)
                    {
                        MarketOrder(contract.Symbol, 1);
                    }
                }
            }
            // Same as above, check for cases like trading on a friday night.
            else if (Securities.Values.Where(x => x.Invested).All(x => x.Exchange.Hours.IsOpen(Time, true)))
            {
                Liquidate();
            }

            foreach (var changedEvent in slice.SymbolChangedEvents.Values)
            {
                if (Time.TimeOfDay != TimeSpan.Zero)
                {
                    throw new RegressionTestException($"{Time} unexpected symbol changed event {changedEvent}!");
                }
            }
        }

        public override void OnSecuritiesChanged(SecurityChanges changes)
        {
            if (changes.RemovedSecurities.Count > 0 &&
                Portfolio.Invested &&
                Securities.Values.Where(x => x.Invested).All(x => x.Exchange.Hours.IsOpen(Time, true)))
            {
                Liquidate();
            }
        }

        /// <summary>
        /// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
        /// </summary>
        public virtual bool CanRunLocally { get; } = true;

View on GitHub (pinned to d2c3659f87)

Solutions

  1. Confirm the algorithm runs at the expected daily resolution so Time aligns to midnight on mapping.
  2. Verify DataMappingMode produces day-boundary rollovers for the daily feed.
  3. Check that no intraday subscription shifts the slice Time away from midnight.
  4. If a custom daily feed emits off-boundary mappings, relax the assertion to your feed's rollover time.

Example fix

// before
if (Time.TimeOfDay != TimeSpan.Zero) { throw ...; }

// after
if (Time.TimeOfDay != TimeSpan.Zero) { Log($"Rollover at {Time}, investigating feed timing."); }
Defensive patterns

Strategy: validation

Validate before calling

foreach (var changedEvent in slice.SymbolChangedEvents.Values)
{
    if (Time.TimeOfDay != TimeSpan.Zero)
    {
        Log($"{Time} - Off-boundary daily rollover: {changedEvent}.");
    }
}

Prevention

When it happens

Trigger: A SymbolChangedEvent arrives in OnData while Time.TimeOfDay != TimeSpan.Zero in a daily-resolution futures algorithm — the continuous contract remapped off the midnight boundary.

Common situations: Daily-resolution data feed emitted a mapping at a non-midnight timestamp; DataMappingMode timing changed; mixed-resolution subscriptions caused the mapping clock to read an intraday time; engine version altered daily mapping emission.

Related errors


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