{"record":{"id":"427cd7d424507afc","repo":"QuantConnect/Lean","slug":"security-price-error-price-should-not-change-ever","errorCode":null,"errorMessage":"Security Price error. Price should not change every minute","messagePattern":"Security Price error\\. Price should not change every minute","errorType":"exception","errorClass":"RegressionTestException","httpStatus":null,"severity":"error","filePath":"Algorithm.CSharp/CustomUniverseWithBenchmarkRegressionAlgorithm.cs","lineNumber":109,"sourceCode":"                }\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\n            // assert benchmark updates only on date change\n            var currentValue = Benchmark.Evaluate(slice.Time);\n            if (_previousTime.Hour == slice.Time.Hour)\n            {\n                if (currentValue != _previousBenchmarkValue)\n                {\n                    throw new RegressionTestException($\"Benchmark value error - expected: {_previousBenchmarkValue} {_previousTime}, actual: {currentValue} {slice.Time}. \" +\n                                        \"Benchmark value should only change when there is a change in hours\");\n                }\n            }\n            else\n            {\n                if (slice.Time.Minute == 0)\n                {","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.CSharp/CustomUniverseWithBenchmarkRegressionAlgorithm.cs#L91-L127","documentation":"This RegressionTestException is thrown in OnData when the universe is NOT selected and slice.Time.Minute != 0 (intra-hour). It asserts that the security price does NOT change from the previous slice — because at Hour resolution, only one bar per hour should exist, so price must remain constant within the hour. LEAN throws it to verify the hour-resolution subscription doesn't leak minute-level price updates.","triggerScenarios":"Within the same hour (Minute != 0), security.Price differs from _previousSecurityValue while the security is tradable. This means an intra-hour price update occurred, which should be impossible for a pure Hour-resolution subscription unless minute data leaked in.","commonSituations":"A universe-selection or subscription-resolution change caused minute data to merge into an hour subscription, fill-forward logic updated prices intra-hour unexpectedly, or a LEAN version change to data-feed merging broke resolution isolation.","solutions":["Log slice.Time, security.Price, _previousSecurityValue, and security.IsTradable at the throw point.","Check whether any subscription is delivering minute-resolution data to the hour-resolution security (resolution leak).","Verify fill-forward only occurs at resolution boundaries (hourly), not intra-hour.","If testing engine changes, trace the SubscriptionDataConfig merge logic to ensure hour and minute feeds don't cross-contaminate."],"exampleFix":"// before\nif (slice.Time.Minute != 0 && _previousSecurityValue != security.Price && security.IsTradable)\n{\n    throw new RegressionTestException($\"Security Price error. Price should not change every minute\");\n}\n\n// after — diagnostic\nif (slice.Time.Minute != 0 && _previousSecurityValue != security.Price && security.IsTradable)\n{\n    throw new RegressionTestException($\"Intra-hour price change at {slice.Time}: prev={_previousSecurityValue}, current={security.Price}\");\n}","handlingStrategy":"validation","validationCode":"// Validate no intra-hour price changes for hour resolution\nif (slice.Time.Minute != 0 && _previousSecurityValue != security.Price)\n    Log($\"Intra-hour price change detected at {slice.Time}: prev={_previousSecurityValue}, current={security.Price}\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure subscriptions at different resolutions don't leak data into each other.","Verify fill-forward only triggers at resolution boundaries, not intra-period.","Trace SubscriptionDataConfig merge logic when mixing Hour and Minute subscriptions on the same symbol."],"tags":["quantconnect","lean","hour-data","price","resolution-isolation","regression-test"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}