Feat: CanonicalDataDownloaderDecorator for chain support#9299
Merged
Romazes merged 23 commits intoQuantConnect:masterfrom Feb 23, 2026
Merged
Feat: CanonicalDataDownloaderDecorator for chain support#9299Romazes merged 23 commits intoQuantConnect:masterfrom
CanonicalDataDownloaderDecorator for chain support#9299Romazes merged 23 commits intoQuantConnect:masterfrom
Conversation
f80b87f to
1a17a50
Compare
Martin-Molinero
approved these changes
Feb 20, 2026
Introduced CanonicalDataDownloaderDecorator to enable automatic resolution and parallel downloading of all contracts for canonical symbols (options and futures chains). Updated Program.cs and DownloaderDataProvider to use this decorator, ensuring seamless data retrieval for both canonical and non-canonical symbols. Refactored initialization logic to handle chain providers within the decorator and removed redundant code from Program.cs.
Introduce DataDownloaderSelector to choose the correct IDataDownloader implementation based on data type, using CanonicalDataDownloaderDecorator only when needed. Update Program.cs and DownloaderDataProvider to use the selector, remove redundant initialization logic, and ensure proper resource disposal. This improves flexibility, correctness, and resource management for data downloads, especially for custom and canonical data types.
…oader - Set ConsoleLogHandler as the default log handler in code and config - Make contract download parallelism configurable via downloader-thread-count (default 4) - Track and log number of processed contracts in CanonicalDataDownloaderDecorator - Add error logging for missing universe data - Improve logging clarity and code readability
Introduce ContractDownloadParameters to uniquely identify contract/tick type/resolution combinations and cache them in CanonicalDataDownloaderDecorator, avoiding redundant downloads when contracts are shared across canonical symbol chains. Add date range optimization for contract downloads and unit tests for the new class.
This reverts commit 44386c4.
Added AdjustDateRangeForContract to CanonicalDataDownloaderDecorator to clamp start/end dates based on contract expiry and security type. Introduced _contractsCache to prevent duplicate downloads across canonical chains and _processedContracts for logging. Updated contract retrieval logic for deduplication. Added NUnit tests to verify date range adjustments for futures and options.
Revert "refactor: remove Lazy from CanonicalDataDownloaderDecorator" This reverts commit 909c129. refactor: Inject IMapFileProvider into downloader selectors Revert "refactor: Inject IMapFileProvider into downloader selectors" This reverts commit 0add952. Reapply "refactor: remove Lazy from CanonicalDataDownloaderDecorator" This reverts commit 9e3c4be.
064c71c to
ea5384e
Compare
- Require explicit IDataProvider in DataDownloaderSelector constructor, removing default and fallback logic - Change default log handler to ConsoleLogHandler in Program.cs - Pass DownloaderDataProvider as IDataProvider to DataDownloaderSelector - Add DataDownloaderSelector unit tests to verify correct downloader selection and decorator usage
Martin-Molinero
approved these changes
Feb 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The PR added the
CanonicalDataDownloaderDecorator, which helps todownload/research/backtestdata forOption,FutureOption,IndexOptionandFuture, read theuniversesfile, and select the available contracts for a specific date range in the algorithm using a specificDataSourceprovider (e.g. DataBento, Polygon, ...).In addition:
Added the
TryAdjustDateRangeForContracthelperstaticmethod, which can be used externally in anyDataProviderto improve the speed of downloading security types with expiry opportunities.Related Issue
Actually, it relates to the DataBento repo to use it comfortably in
backtestingmode.Motivation and Context
Utilizes the Lean engine flexibly with generic logic applied universally across all plugins.
Requires Documentation Change
N/a
How Has This Been Tested?
lean data download --data-provider-historical databento --data-type Trade --resolution Daily --security-type Future --market CME --ticker ES --start 20260201 --end 20260210lean data download --data-provider-historical databento --data-type Trade --resolution minute --security-type Future --market CME --ticker ES --start 20260201 --end 20260210(minute)lean backtest DatabentoTestAlgo --data-provider-historical DataBento(Daily)lean backtest DatabentoTestAlgo --data-provider-historical DataBento(Minute)lean data download --data-provider-historical Polygon --market USA --data-type trade --security-type Option --ticker AAPL --resolution minute --start 20260201 --end 20260210(I have used custom Polygon pckg without support Canonical symbols)Types of changes
Checklist:
bug-<issue#>-<description>orfeature-<issue#>-<description>