QuantConnect/Lean · error · RegressionTestException

Security Price error. Price should not change every minute

Error message

Security Price error. Price should not change every minute

What it means

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.

Source

Thrown at Algorithm.CSharp/CustomUniverseWithBenchmarkRegressionAlgorithm.cs:109

                }
                if (_previousTime.Date == slice.Time.Date
                    && (slice.Time - _previousTime) != TimeSpan.FromMinutes(1))
                {
                    throw new RegressionTestException("For the same date expected data updates every 1 minute");
                }
            }
            else
            {
                if (slice.Time.Minute == 0
                    && _previousSecurityValue == security.Price)
                {
                    throw new RegressionTestException($"Security Price error. Price should change every new hour");
                }
                if (slice.Time.Minute != 0
                    && _previousSecurityValue != security.Price
                    && security.IsTradable)
                {
                    throw new RegressionTestException($"Security Price error. Price should not change every minute");
                }
            }
            _previousSecurityValue = security.Price;

            // assert benchmark updates only on date change
            var currentValue = Benchmark.Evaluate(slice.Time);
            if (_previousTime.Hour == slice.Time.Hour)
            {
                if (currentValue != _previousBenchmarkValue)
                {
                    throw new RegressionTestException($"Benchmark value error - expected: {_previousBenchmarkValue} {_previousTime}, actual: {currentValue} {slice.Time}. " +
                                        "Benchmark value should only change when there is a change in hours");
                }
            }
            else
            {
                if (slice.Time.Minute == 0)
                {

View on GitHub (pinned to d2c3659f87)

Solutions

  1. Log slice.Time, security.Price, _previousSecurityValue, and security.IsTradable at the throw point.
  2. Check whether any subscription is delivering minute-resolution data to the hour-resolution security (resolution leak).
  3. Verify fill-forward only occurs at resolution boundaries (hourly), not intra-hour.
  4. If testing engine changes, trace the SubscriptionDataConfig merge logic to ensure hour and minute feeds don't cross-contaminate.

Example fix

// before
if (slice.Time.Minute != 0 && _previousSecurityValue != security.Price && security.IsTradable)
{
    throw new RegressionTestException($"Security Price error. Price should not change every minute");
}

// after — diagnostic
if (slice.Time.Minute != 0 && _previousSecurityValue != security.Price && security.IsTradable)
{
    throw new RegressionTestException($"Intra-hour price change at {slice.Time}: prev={_previousSecurityValue}, current={security.Price}");
}
Defensive patterns

Strategy: validation

Validate before calling

// Validate no intra-hour price changes for hour resolution
if (slice.Time.Minute != 0 && _previousSecurityValue != security.Price)
    Log($"Intra-hour price change detected at {slice.Time}: prev={_previousSecurityValue}, current={security.Price}");

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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