{"record":{"id":"f245b37d839f978a","repo":"QuantConnect/Lean","slug":"time-unexpected-symbol-changed-event-changedeve-f245b3","errorCode":null,"errorMessage":"{Time} unexpected symbol changed event {changedEvent}!","messagePattern":"(.+?) unexpected symbol changed event (.+?)!","errorType":"exception","errorClass":"RegressionTestException","httpStatus":null,"severity":"warning","filePath":"Algorithm.CSharp/BasicTemplateFuturesDailyAlgorithm.cs","lineNumber":102,"sourceCode":"                    // Also check if exchange is open for regular or extended hours. Since daily data comes at 8PM, this allows us prevent the\n                    // algorithm from trading on friday when there is not after-market.\n                    if (contract != null)\n                    {\n                        MarketOrder(contract.Symbol, 1);\n                    }\n                }\n            }\n            // Same as above, check for cases like trading on a friday night.\n            else if (Securities.Values.Where(x => x.Invested).All(x => x.Exchange.Hours.IsOpen(Time, true)))\n            {\n                Liquidate();\n            }\n\n            foreach (var changedEvent in slice.SymbolChangedEvents.Values)\n            {\n                if (Time.TimeOfDay != TimeSpan.Zero)\n                {\n                    throw new RegressionTestException($\"{Time} unexpected symbol changed event {changedEvent}!\");\n                }\n            }\n        }\n\n        public override void OnSecuritiesChanged(SecurityChanges changes)\n        {\n            if (changes.RemovedSecurities.Count > 0 &&\n                Portfolio.Invested &&\n                Securities.Values.Where(x => x.Invested).All(x => x.Exchange.Hours.IsOpen(Time, true)))\n            {\n                Liquidate();\n            }\n        }\n\n        /// <summary>\n        /// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.\n        /// </summary>\n        public virtual bool CanRunLocally { get; } = true;","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.CSharp/BasicTemplateFuturesDailyAlgorithm.cs#L84-L120","documentation":"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.","triggerScenarios":"A SymbolChangedEvent arrives in OnData while Time.TimeOfDay != TimeSpan.Zero in a daily-resolution futures algorithm — the continuous contract remapped off the midnight boundary.","commonSituations":"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.","solutions":["Confirm the algorithm runs at the expected daily resolution so Time aligns to midnight on mapping.","Verify DataMappingMode produces day-boundary rollovers for the daily feed.","Check that no intraday subscription shifts the slice Time away from midnight.","If a custom daily feed emits off-boundary mappings, relax the assertion to your feed's rollover time."],"exampleFix":"// before\nif (Time.TimeOfDay != TimeSpan.Zero) { throw ...; }\n\n// after\nif (Time.TimeOfDay != TimeSpan.Zero) { Log($\"Rollover at {Time}, investigating feed timing.\"); }","handlingStrategy":"validation","validationCode":"foreach (var changedEvent in slice.SymbolChangedEvents.Values)\n{\n    if (Time.TimeOfDay != TimeSpan.Zero)\n    {\n        Log($\"{Time} - Off-boundary daily rollover: {changedEvent}.\");\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm daily resolution so Time aligns to midnight on rollover.","Verify DataMappingMode maps at the day boundary.","Avoid mixing resolutions that shift the slice Time."],"tags":["futures","continuous-contract","symbol-mapping","regression-test","daily-resolution","timing"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}