{"record":{"id":"5e8390935e5abec4","repo":"QuantConnect/Lean","slug":"for-the-same-date-expected-data-updates-every-1-mi","errorCode":null,"errorMessage":"For the same date expected data updates every 1 minute","messagePattern":"For the same date expected data updates every 1 minute","errorType":"exception","errorClass":"RegressionTestException","httpStatus":null,"severity":"error","filePath":"Algorithm.CSharp/CustomUniverseWithBenchmarkRegressionAlgorithm.cs","lineNumber":95,"sourceCode":"        /// <param name=\"slice\">Slice object keyed by symbol containing the stock data</param>\n        public override void OnData(Slice slice)\n        {\n            var security = Securities[_spy];\n            _onDataWasCalled = true;\n\n            var bar = slice.Bars.Values.Single();\n            if (_universeSelected)\n            {\n                if (bar.IsFillForward\n                    || bar.Period != TimeSpan.FromMinutes(1))\n                {\n                    // bar should always be the Minute resolution one here\n                    throw new RegressionTestException(\"Unexpected Bar error\");\n                }\n                if (_previousTime.Date == slice.Time.Date\n                    && (slice.Time - _previousTime) != TimeSpan.FromMinutes(1))\n                {\n                    throw new RegressionTestException(\"For the same date expected data updates every 1 minute\");\n                }\n            }\n            else\n            {\n                if (slice.Time.Minute == 0\n                    && _previousSecurityValue == security.Price)\n                {\n                    throw new RegressionTestException($\"Security Price error. Price should change every new hour\");\n                }\n                if (slice.Time.Minute != 0\n                    && _previousSecurityValue != security.Price\n                    && security.IsTradable)\n                {\n                    throw new RegressionTestException($\"Security Price error. Price should not change every minute\");\n                }\n            }\n            _previousSecurityValue = security.Price;\n","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.CSharp/CustomUniverseWithBenchmarkRegressionAlgorithm.cs#L77-L113","documentation":"This RegressionTestException is thrown in OnData when the universe is selected. It asserts that for data on the same calendar date, consecutive slices arrive exactly 1 minute apart. LEAN throws it to verify Minute-resolution data streaming delivers bars at the correct cadence without gaps or duplicates within a trading day.","triggerScenarios":"Two consecutive slices on the same date are not exactly 1 minute apart — either a gap (missing minute bars) or a tighter interval (duplicate or sub-minute data). This indicates the minute data feed has synchronization or fill issues.","commonSituations":"Missing minute data files causing gaps that fill-forward doesn't cover, a LEAN version change to the time-forward loop that altered minute-bar scheduling, or data feed changes that inject duplicate timestamps. Also occurs when the algorithm's first slice sets _previousTime incorrectly.","solutions":["Log slice.Time and _previousTime at the throw to see the actual gap.","Verify minute data files are complete with no missing timestamps for the test date range.","Check the time-forward / enqueue logic in the data-feed for off-by-one errors in minute scheduling.","Ensure _previousTime is initialized correctly on the first OnData call to avoid a spurious initial delta."],"exampleFix":"// before\nif (_previousTime.Date == slice.Time.Date && (slice.Time - _previousTime) != TimeSpan.FromMinutes(1))\n{\n    throw new RegressionTestException(\"For the same date expected data updates every 1 minute\");\n}\n\n// after — add diagnostic delta\nvar delta = slice.Time - _previousTime;\nif (_previousTime.Date == slice.Time.Date && delta != TimeSpan.FromMinutes(1))\n{\n    throw new RegressionTestException($\"Expected 1-minute interval on same date. Previous: {_previousTime}, Current: {slice.Time}, Delta: {delta}\");\n}","handlingStrategy":"validation","validationCode":"// Validate time delta before asserting\nvar delta = slice.Time - _previousTime;\nif (_previousTime.Date == slice.Time.Date && delta != TimeSpan.FromMinutes(1))\n    Log($\"Unexpected interval: {delta} at {slice.Time} (prev {_previousTime})\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Initialize _previousTime correctly on the first OnData call to avoid spurious deltas.","Ensure minute data files have no gaps for the test date range.","Log timestamps during development to detect scheduling issues early."],"tags":["quantconnect","lean","minute-data","timing","resolution","regression-test"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}