QuantConnect/Lean · error · RegressionTestException

For the same date expected data updates every 1 minute

Error message

For the same date expected data updates every 1 minute

What it means

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.

Source

Thrown at Algorithm.CSharp/CustomUniverseWithBenchmarkRegressionAlgorithm.cs:95

        /// <param name="slice">Slice object keyed by symbol containing the stock data</param>
        public override void OnData(Slice slice)
        {
            var security = Securities[_spy];
            _onDataWasCalled = true;

            var bar = slice.Bars.Values.Single();
            if (_universeSelected)
            {
                if (bar.IsFillForward
                    || bar.Period != TimeSpan.FromMinutes(1))
                {
                    // bar should always be the Minute resolution one here
                    throw new RegressionTestException("Unexpected Bar error");
                }
                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;

View on GitHub (pinned to d2c3659f87)

Solutions

  1. Log slice.Time and _previousTime at the throw to see the actual gap.
  2. Verify minute data files are complete with no missing timestamps for the test date range.
  3. Check the time-forward / enqueue logic in the data-feed for off-by-one errors in minute scheduling.
  4. Ensure _previousTime is initialized correctly on the first OnData call to avoid a spurious initial delta.

Example fix

// before
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");
}

// after — add diagnostic delta
var delta = slice.Time - _previousTime;
if (_previousTime.Date == slice.Time.Date && delta != TimeSpan.FromMinutes(1))
{
    throw new RegressionTestException($"Expected 1-minute interval on same date. Previous: {_previousTime}, Current: {slice.Time}, Delta: {delta}");
}
Defensive patterns

Strategy: validation

Validate before calling

// Validate time delta before asserting
var delta = slice.Time - _previousTime;
if (_previousTime.Date == slice.Time.Date && delta != TimeSpan.FromMinutes(1))
    Log($"Unexpected interval: {delta} at {slice.Time} (prev {_previousTime})");

Prevention

When it happens

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

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

Related errors


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