QuantConnect/Lean · error · RegressionTestException
Empty history at {Time}
Error message
Empty history at {Time} What it means
A scheduled history probe calls History(10, Resolution.Minute) and asserts at least 10 minute bars return. Fewer than 10 means the history request yielded insufficient data for the period — the futures universe lacked 10 minutes of lookback at that call time, so the data window was empty or short.
Source
Thrown at Algorithm.CSharp/BasicTemplateFuturesHistoryAlgorithm.cs:72
SetCash(1000000);
foreach (var root in roots)
{
// set our expiry filter for this futures chain
AddFuture(root, Resolution.Minute, extendedMarketHours: ExtendedMarketHours).SetFilter(TimeSpan.Zero, TimeSpan.FromDays(182));
}
SetBenchmark(d => 1000000);
Schedule.On(DateRules.EveryDay(), TimeRules.Every(TimeSpan.FromHours(1)), MakeHistoryCall);
}
private void MakeHistoryCall()
{
var history = History(10, Resolution.Minute);
if (history.Count() < 10)
{
throw new RegressionTestException($"Empty history at {Time}");
}
_successCount++;
}
public override void OnEndOfAlgorithm()
{
if (_successCount < ExpectedHistoryCallCount)
{
throw new RegressionTestException($"Scheduled Event did not assert history call as many times as expected: {_successCount}/49");
}
}
/// <summary>
/// Event - v3.0 DATA EVENT HANDLER: (Pattern) Basic template for user to override for receiving all subscription data in a single event
/// </summary>
/// <param name="slice">The current slice of data keyed by symbol string</param>
public override void OnData(Slice slice)
{View on GitHub (pinned to d2c3659f87)
Solutions
- Ensure the algorithm is warmed up (SetWarmup) so 10 minute bars exist before the scheduled call fires.
- Confirm the futures subscription resolution is Minute (or finer) so minute history is available.
- Start the scheduled history probe only after enough bars have accumulated (guard on algorithm time / bar count).
- Verify no data gaps in the backtest window; if gaps exist, lower the requested bar count or tolerate short windows.
Example fix
// before
var history = History(10, Resolution.Minute);
if (history.Count() < 10) { throw ...; }
// after: skip the check while warming up
if (IsWarmingUp) return;
var history = History(10, Resolution.Minute);
if (history.Count() < 10) { Log($"Short history at {Time}: {history.Count()}"); return; } Defensive patterns
Strategy: validation
Validate before calling
private void MakeHistoryCall()
{
if (IsWarmingUp) return;
var history = History(10, Resolution.Minute);
if (history.Count() < 10)
{
Log($"Short history at {Time}: {history.Count()} bars.");
return;
}
_successCount++;
} Prevention
- Warm up the algorithm so 10 minute bars exist before scheduled history calls.
- Confirm the futures subscription resolution is Minute or finer.
- Start history probes only after enough bars accumulated.
When it happens
Trigger: MakeHistoryCall() (scheduled every hour) runs History(10, Resolution.Minute) and the returned enumerable has Count() < 10 — not enough minute-bar history exists for the subscribed futures at that wall-clock point (e.g. near warm-up, market open, or a data gap).
Common situations: Called during warm-up before 10 bars accumulated; near the algorithm start date where lookback underflows; a data gap/hole in the minute feed; the futures subscription hadn't received enough bars yet; resolution mismatch (subscribed daily but requesting minute).
Related errors
- Scheduled Event did not assert history call as many times as
- Future contracts did not work up as expected: {addedSecurity
- Future contracts did not work up as expected: {addedSecurity
- _customWarmUp indicator was expected to be ready
- _customWarmUp indicator was expected to have processed 60 da
AI-assisted analysis of QuantConnect/Lean@d2c3659f87 (2026-08-13).
Data as JSON: /api/errors/ecf63602edd0b6ad.
Report an issue: GitHub.