Hi there
I am developing backtests for data including FutureOptions.
I have this function, which first find the future contract, then based on the contract and contract starts date it tries to get optionsContract but allOptionContract is always empty, any help appreciated.
The values I am calling the function is “HE”, “cme”, 2024, 12, Call, 80000
The contract found is HE13Z24, and targetContract.ID.Date is 2024-12-13
private Symbol CreateFutureOptionSymbol(string underlying, string market, int year, int month, OptionRight? optionRight, decimal strike)
{
var futureSymbol = AddFuture(underlying, market: market).Symbol;
var contracts = FutureChainProvider.GetFutureContractList(futureSymbol, new DateTime(year, month, 1));
var targetContract = contracts
.Where(c => c.ID.Date.Year == year && c.ID.Date.Month == month)
.OrderBy(c => c.ID.Date)
.FirstOrDefault();
if (targetContract == null)
{
Error($"No future contract found for {underlying} in {year}-{month:D2}");
return null;
}
var allOptionContract = OptionChainProvider.GetOptionContractList(targetContract, targetContract.ID.Date);
Mia Alissi
Based on the information gathered, here are some steps and considerations to help you troubleshoot and resolve the issue with your function for fetching future options contracts:
Verify Future Contract Addition: Ensure that the
AddFuture
method is correctly adding the future contract. TheSymbol
returned should match your expectations. TheAddFuture
method requires the underlying ticker and market, and it should be correctly set up in your algorithm.Check Future Contract List: Use the
FutureChainProvider.get_future_contract_list
method to verify that the list of future contracts is being populated correctly. Ensure that the date provided is correct and that the contracts returned include the one you are targeting.Validate Target Contract Selection: Confirm that the logic for selecting the
targetContract
is accurate. Check if the filtering criteria (year and month) are correctly applied and that the contract exists in the list.Confirm Option Chain Provider Usage: Ensure that the
OptionChainProvider.get_option_contract_list
method is being called with the correct parameters, particularly thetargetContract
and itsID.date
.Inspect Option Contract List: After calling
GetOptionContractList
, check if theallOptionContract
list is empty. If so, verify that thetargetContract
is valid and that the date provided is correct.Review Documentation and Examples: Refer to the QuantConnect documentation and examples for
AddFuture
,GetFutureContractList
, andGetOptionContractList
to ensure proper usage and to identify any potential discrepancies in your implementation.Debug and Log Outputs: Add logging statements to output the values of key variables and the results of method calls to help identify where the process might be failing.
By following these steps, you should be able to identify and resolve the issue with your function for fetching future options contracts. If the problem persists, consider reviewing the specific implementation details and ensuring that all parameters and method calls are correctly aligned with the QuantConnect API.
Sources: Individual Contracts - QuantConnect.com, Futures - QuantConnect.com, Individual Contracts - QuantConnect.com, Add Future Option Contract Data Streaming Regression Algorithm, Basic Template Futures Algorithm
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Ryan Rahmati
even I added this for debugging, it's 0 for any dates between 2023 Jan, 2025 Jan
Ryan Rahmati
Thanks Mia for response
- The contract is correct, I am able to place older using same contract on non option trades.
- OptionChainProvider.GetOptionContractList is getting called with contract value, I wasn't sure about the date time passed (if logically correct), so I ran above debugging code.
- could it be the futureOptions is not suppoprted for specific market or ticker?
Ryan Rahmati
I figured out the beans are not supported in FutureOptions
Ryan Rahmati
Now I am facing another issue, when running backtest what needed to be passed as datetime to OptionChainProvider.GetOptionContractList
When the contract is for 2025-3 if I pass date time as 2024-12 it returns data, but doesn't return anything if pass contract.ID.Date or 2025-03-01
Ryan Rahmati
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!