You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Canonical option downloads discard the first history point #22
ThetaDataDownloader.GetCanonicalOptionHistory drops the first history point produced for every non-empty canonical option download.
At ThetaDataDownloader.cs:119–127, options is a BlockingCollection<BaseData>.GetConsumingEnumerable(). Calling options.Any() removes its first item. Returning options then delivers only the remaining points. The discarded contract/time can vary because the history requests run in parallel. If just one point is produced, the result is non-null but empty.
Reproduction
The consuming-probe logic reproduces without an account or network requests:
usingvarqueue=newBlockingCollection<int>();queue.Add(1);queue.Add(2);queue.CompleteAdding();vardata=queue.GetConsumingEnumerable();Console.WriteLine(data.Any());// True; consumes 1Console.WriteLine(string.Join(",",data));// 2, not 1,2
I ran this pattern with 1, 2 and 6 queued items: the returned sequence contained 0, 1 and 5 items respectively. The production path above uses the same probe on BaseData; no ThetaData request was run.
Expected outcome
Return every history point produced, while retaining null for an entirely empty response. A suggested fix is to retain the first point taken while waiting for data and yield it before the remaining stream. Add no-data, single-point and multi-contract regression tests.
QuantConnect/Lean#10100 adds a shared helper for this: GetConsumingEnumerableOrNull() on a BlockingCollection<T> waits for the first item, returns null if the collection completes adding without one, and otherwise returns every item, the first one included. Once this repository builds against a Lean that has it, the fix is one call:
Activity
Martin-Molinero commentedon Nov 12, 2026
QuantConnect/Lean#10100 adds a shared helper for this:
GetConsumingEnumerableOrNull()on aBlockingCollection<T>waits for the first item, returnsnullif the collection completes adding without one, and otherwise returns every item, the first one included. Once this repository builds against a Lean that has it, the fix is one call:It replaces the
GetConsumingEnumerable()+Any()check and keeps returningnullwhen nothing was added.