QuantConnect/Lean · warning · RegressionTestException

{Time} unexpected symbol changed event {changedEvent}!

Error message

{Time} unexpected symbol changed event {changedEvent}!

What it means

The extended-market futures regression asserts SymbolChangedEvents (rollovers) occur only at midnight (Time.TimeOfDay == TimeSpan.Zero). Because this algorithm trades extended market hours, an off-midnight mapping is especially suspect — it suggests the rollover leaked into the extended session rather than the daily boundary.

Source

Thrown at Algorithm.CSharp/BasicTemplateFuturesWithExtendedMarketAlgorithm.cs:82

            var benchmark = AddEquity("SPY");
            SetBenchmark(benchmark.Symbol);

            var seeder = new FuncSecuritySeeder(GetLastKnownPrices);
            SetSecurityInitializer(security => seeder.SeedSecurity(security));
        }

        /// <summary>
        /// Event - v3.0 DATA EVENT HANDLER: (Pattern) Basic template for user to override for receiving all subscription data in a single event
        /// </summary>
        /// <param name="slice">The current slice of data keyed by symbol string</param>
        public override void OnData(Slice slice)
        {
            foreach (var changedEvent in slice.SymbolChangedEvents.Values)
            {
                Debug($"{Time} - SymbolChanged event: {changedEvent}");
                if (Time.TimeOfDay != TimeSpan.Zero)
                {
                    throw new RegressionTestException($"{Time} unexpected symbol changed event {changedEvent}!");
                }
            }

            if (!Portfolio.Invested)
            {
                foreach(var chain in slice.FutureChains)
                {
                    // find the front contract expiring no earlier than in 90 days
                    var contract = (
                        from futuresContract in chain.Value.OrderBy(x => x.Expiry)
                        where futuresContract.Expiry > Time.Date.AddDays(90)
                        select futuresContract
                    ).FirstOrDefault();

                    // if found, trade it
                    if (contract != null)
                    {
                        _contractSymbol = contract.Symbol;

View on GitHub (pinned to d2c3659f87)

Solutions

  1. Confirm extended-hours subscription does not shift the rollover slice Time off midnight.
  2. Verify DataMappingMode maps at the daily boundary for the extended feed.
  3. If extended-session rollovers are legitimate for your feed, relax the midnight assertion.
  4. Ensure the continuous-contract mapping clock aligns with the intended session calendar.

Example fix

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

// after: log and investigate extended-session rollovers
if (Time.TimeOfDay != TimeSpan.Zero) { Log($"Extended-session rollover at {Time}: {changedEvent}"); }
Defensive patterns

Strategy: validation

Validate before calling

foreach (var changedEvent in slice.SymbolChangedEvents.Values)
{
    if (Time.TimeOfDay != TimeSpan.Zero)
    {
        Log($"{Time} - Extended-session rollover: {changedEvent}. Verify feed/mapping.");
    }
}

Prevention

When it happens

Trigger: A SymbolChangedEvent arrives in OnData while Time.TimeOfDay != TimeSpan.Zero in an extended-hours futures algorithm — the continuous contract remapped during the extended or regular session instead of midnight.

Common situations: Extended-hours data shifted the mapping timestamp; DataMappingMode timing changed; an extended-market subscription caused the slice Time to read an intraday value at rollover; engine version altered mapping emission for extended sessions.

Related errors


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