Canonical downloads hide contract-discovery failures

Open
#10,099 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp

Research direction

Start with CanonicalDataDownloaderDecorator, in particular GetContractsData, where producerTask is started with Task.Run and never observed, and the finally block that calls CompleteAdding. Reproduce with a synthetic IDataDownloader and an IFutureChainProvider that throws on a later date, then enumerate Get to completion. Done means the discovery exception reaches the caller on both the first-date and later-date paths, with tests covering each.

Written by the indexing model from the issue text.

Description

Problem

CanonicalDataDownloaderDecorator does not observe failures from contract discovery. If a future/option chain provider throws, a canonical download can look like either no data or a successfully completed partial download.

Reproduction

Use a synthetic IDataDownloader that returns null for a canonical MNQ future and two minute bars for its dated contract. Set downloader-thread-count to 1 so the sequence is deterministic.

  1. Request December 8–9, 2025.
  2. Have IFutureChainProvider.GetFutureContractList return the dated contract for December 8.
  3. On December 9, throw InvalidOperationException("synthetic later-date discovery failure") instead of returning a chain.
  4. Enumerate the result of CanonicalDataDownloaderDecorator.Get to completion.

Observed: enumeration ends normally after the earlier contract's data. The discovery exception never reaches the caller. I also tested a provider that throws on its first call: Get returns null and reports no contracts rather than reporting the discovery failure. Both behaviors reproduce with the existing consuming-probe implementation as well as with a probe that preserves the first point.

These are synthetic local reproductions, with no external data-provider requests.

Cause and expected outcome

GetContractsData starts producerTask with Task.Run but never observes that task. GetContracts is lazy, so chain-provider exceptions occur inside the producer. Its finally calls CompleteAdding, making the consumer see normal completion despite the fault.

A fix must distinguish failed contract discovery from a genuinely empty or complete chain. A suggested approach is to observe the producer's failure when consuming the result, including the no-data path; if best-effort partial results are intended, the failure and incompleteness still need to be made explicit. Cover both first-date failure and failure after an earlier contract has produced data.

Dominant language
C#
Stars
22.6k
Forks
5.4k
Avg merge
11h 39m
Merged PRs (30d)
104

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from QuantConnect/Lean

All issues in QuantConnect/Lean

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.