-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty Option Contracts Returned if Invoked inside the Lean Environment (both Backtest and Research) #9
Comments
@efJerryYang "closed as completed"? Within a backtest I'm able to download Index data, but not IndexOption. Suspect it's the same issue. fwiw this downloads quotes correctly, but no way to prefilter the strikes, so gets too big at small resolutions.
|
@andywatts Hi, as we have discussed in discord, but I also quoted here for other's reference. Using third-party provider requires us to prepare the Universe Dataset ourselves, which can be done inside the lean docker image (we need to call the Avoid using their downloader if you are to fetch years of data, which was using sync request with a single thread and it would take forever to download merely the OpenInterest data (estimated to be about 12x24 hours...). In my attempt, with 32 threads and roughly 256 concurrent connections it will only take several minutes for the OpenInterest, couple of hours to download the Quote data and convert to lean-compatible format. And there are still many other issues may encountered in local development... |
Sorry for the delay, but please do report any bugs and how to reproduce so we fix them asap. |
Hi, thanks for the update. I want to clarify this is not a bug but a misunderstanding of the dataset requirements. Users need to prepare their Universe Dataset in lean-compatible format for running the backtest/research/live via ThetaData. Please close the issue if you believe this is not in the scope of QuantConnect support. |
Problem Description
If I directly run the test cases in the repository, everything runs smoothly. More specifically, I tried the following code in this repository:
And run the test with
dotnet test --filter "FullyQualifiedName=QuantConnect.Lean.DataSource.ThetaData.Tests.ThetaDataOptionChainProviderTests.GetOptionContractList"
The test case runs without an error, and the API returns the expected number of contracts. Everything works as expected here.
However, when running the code in backtesting or research, things go wrong. See the following section, which indicates an issue with the integration with the Lean repository.
The code correctly sets up the
DownloaderDataProvider
, as expected, and the logs confirm this:The
ThetaDataDownloader
is also correctly set in theDownloaderDataProvider
, but it is likely not being called, and all the data returned is only fetched from the local disk.Note: I didn't run
lean download
to fetch local data. My goal is to use Lean CLI to access the ThetaData API directly instead of QuantConnect's data source.I have also examined
Lean/Engine/HistoricalData/SubscriptionDataReaderHistoryProvider.cs
, where theGetHistory
method does not return meaningful data. It is invoked fromBacktestingChainProvider.GetOptionSymbols
.Alex mentioned that this issue was caused by changes to the option contract fetching logic made four months ago. I have identified the relevant commit in the Lean repository here: QuantConnect/Lean@16c4259, along with some subsequent commits. However, simply mimicking the changes in that commit does not resolve my issue. For example, in that commit:
And if I use the following code directly, the contract count is still 0:
This suggests an issue with the outdated integration in this repository. I am wondering if you can help resolve this issue or at least you may direct me to a 'correctly updated' DataSource repository, so that I can understand what's the correct way of integrating with the Lean Engine and make a fix for here.
Thanks!
For convenience, I have provided a minimal project to reproduce the issue: https://github.com/efJerryYang/ThetaDataWithLeanEmptyResultDemo
I used a fixed Lean Engine version for reproducibility:
And the logs would be like:
The text was updated successfully, but these errors were encountered: