QuantConnect/Lean · error · RegressionTestException
Custom data was not fetched
Error message
Custom data was not fetched
What it means
OnEndOfAlgorithm asserts _receivedData.Count > 0. _receivedData is populated in OnData only when slice.ContainsKey(_customSymbol) is true and the zero-field check passes. A count of 0 means no custom data point was ever delivered to OnData during the entire backtest.
Source
Thrown at Algorithm.CSharp/DescendingCustomDataObjectStoreRegressionAlgorithm.cs:96
public override void OnData(Slice slice)
{
if (slice.ContainsKey(_customSymbol))
{
var sortCustomData = slice.Get<SortCustomData>(_customSymbol);
if (sortCustomData.Open == 0 || sortCustomData.High == 0 || sortCustomData.Low == 0 || sortCustomData.Close == 0 || sortCustomData.Price == 0)
{
throw new RegressionTestException("One or more custom data fields (Open, High, Low, Close, Price) are zero.");
}
_receivedData.Add(sortCustomData);
}
}
public override void OnEndOfAlgorithm()
{
if (_receivedData.Count == 0)
{
throw new RegressionTestException("Custom data was not fetched");
}
var history = History<SortCustomData>(_customSymbol, StartDate, EndDate, Resolution.Hour).ToList();
if (history.Count != _receivedData.Count)
{
throw new RegressionTestException("History request returned different data than expected");
}
// Iterate through the history collection, checking if the EndTime is in ascending order.
for (int i = 0; i < history.Count - 1; i++)
{
if (history[i].EndTime > history[i + 1].EndTime)
{
throw new RegressionTestException($"Order failure: {history[i].EndTime} > {history[i + 1].EndTime} at index {i}.");
}
}
}View on GitHub (pinned to d2c3659f87)
Solutions
- Confirm ObjectStore.Save(CustomDataKey, ...) succeeds in Initialize and the key matches SortCustomData.CustomDataKey used in GetSource.
- Verify AddData<SortCustomData>(...) symbol and that _customSymbol matches the subscription.
- Log inside SortCustomData.Reader to confirm it is invoked and returns non-null objects.
- Check the date range aligns with the data timestamps (2024-09-09 to 2024-10-03).
Defensive patterns
Strategy: validation
Validate before calling
// In Initialize, verify the object store save succeeded
ObjectStore.Save(CustomDataKey, string.Join("\n", descendingCustomData));
if (!ObjectStore.ContainsKey(CustomDataKey))
{
throw new InvalidOperationException("ObjectStore save failed; no custom data will be delivered");
} Prevention
- Verify ObjectStore.Save succeeds and the key matches SortCustomData.CustomDataKey.
- Log inside Reader to confirm it is invoked.
- Confirm the date range overlaps the data timestamps.
When it happens
Trigger: The SortCustomData subscription never produced a data point: ObjectStore.Save failed or was empty, the subscription symbol/key mismatch, GetSource returns an unreachable key, or the date range (2024-09-09 to 2024-10-03) has no matching rows after filtering.
Common situations: ObjectStore key in SortCustomData.CustomDataKey does not match the AddData symbol registration, the object store is not enabled/configured, or Reader returns null for every line so nothing reaches OnData.
Related errors
- One or more custom data fields (Open, High, Low, Close, Pric
- History request returned different data than expected
- Order failure: {history[i].EndTime} > {history[i + 1].EndTim
- Unexpected universe data count {historicalSelectionData.Coun
- Unexpected universe data receieved
AI-assisted analysis of QuantConnect/Lean@d2c3659f87 (2026-08-13).
Data as JSON: /api/errors/3fed1f0a12ce63cb.
Report an issue: GitHub.