QuantConnect/Lean · error · RegressionTestException
{ActiveSecurities.Count.ToString().ToCamelCase()} data point
Error message
{ActiveSecurities.Count.ToString().ToCamelCase()} data points were expected, but only {slice.Count} were received What it means
Asserts that every time slice carries exactly one data point per active security (slice.Count == ActiveSecurities.Count). With two forex + two custom-data securities, each aligned hourly slice should contain a point for each. A smaller slice.Count means a subscription dropped or mis-aligned a point on that bar.
Source
Thrown at Algorithm.CSharp/CustomDataWorksWithDifferentExchangesRegressionAlgorithm.cs:56
throw new RegressionTestException($"The time zone of security {firstCustomSecurity} should be {TimeZones.Utc}, but it was {firstCustomSecurity.Exchange.TimeZone}");
}
var market2 = AddForex("EURUSD", Resolution.Hour, Market.Oanda);
var secondCustomSecurity = AddData<ExampleCustomData>(market2.Symbol, Resolution.Hour, TimeZones.Utc, false);
if (secondCustomSecurity.Exchange.TimeZone != TimeZones.Utc)
{
throw new RegressionTestException($"The time zone of security {secondCustomSecurity} should be {TimeZones.Utc}, but it was {secondCustomSecurity.Exchange.TimeZone}");
}
_noDataPointsReceived = true;
}
public override void OnData(Slice slice)
{
_noDataPointsReceived = false;
if (slice.Count != ActiveSecurities.Count)
{
throw new RegressionTestException($"{ActiveSecurities.Count.ToString().ToCamelCase()} data points were expected, but only {slice.Count} were received");
}
}
public override void OnEndOfAlgorithm()
{
if (_noDataPointsReceived)
{
throw new RegressionTestException($"No points were received");
}
}
/// <summary>
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
/// </summary>
public bool CanRunLocally { get; } = true;
/// <summary>
/// This is used by the regression test system to indicate which languages this algorithm is written in.View on GitHub (pinned to d2c3659f87)
Solutions
- Enable fillForward on the custom-data subscriptions so empty bars are filled to match forex.
- Confirm the custom data Reader returns points stamped with the correct time-zone-converted time so they land in the right hourly bucket.
- Check the custom data source for missing rows in the test window and either supply complete data or allow gaps.
- Verify ActiveSecurities does not include a security whose data feed never starts (e.g., a stale AddData call).
Example fix
// before: fillForward=false causes uneven slice counts var s = AddData<ExampleCustomData>(m.Symbol, Resolution.Hour, TimeZones.Utc, false); // after: fill forward so each bar has a point per security var s = AddData<ExampleCustomData>(m.Symbol, Resolution.Hour, TimeZones.Utc, true);
Defensive patterns
Strategy: validation
Validate before calling
// Validate per-slice coverage before acting
if (slice.Count != ActiveSecurities.Count)
{
var missing = ActiveSecurities.Keys.Except(slice.Keys).ToList();
Log($"Slice missing {missing.Count} securities at {Time}: {string.Join(",", missing)}");
return;
} Type guard
bool SliceIsComplete(Slice slice, int active) => slice.Count == active;
Prevention
- Enable fillForward on subscriptions that must align bar-to-bar.
- Stamp custom-data points with the correct time-zone-converted time so they bucket together.
- When gaps are acceptable, handle them explicitly instead of asserting equality.
When it happens
Trigger: Stepping OnData on an hour boundary and finding slice.Count less than the number of active securities; one or more subscriptions did not emit a bar for that time.
Common situations: Custom-data source has gaps or its time-zone conversion shifts points into an adjacent bar; fillForward disabled so missing bars stay empty; or data-feed scheduling misaligns custom and forex feeds. Also happens if a security is added but its data file is empty for the range.
Related errors
- The ticker did not rename throughout the course of its life
- The time zone of security {firstCustomSecurity} should be {T
- The time zone of security {secondCustomSecurity} should be {
- No points were received
- Custom data was not received
AI-assisted analysis of QuantConnect/Lean@d2c3659f87 (2026-08-13).
Data as JSON: /api/errors/74f04cbe5d79c1f0.
Report an issue: GitHub.