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
The .expiration(0, 0) method in the Option Universe Selection filter does not select options expiring at the end of the current trading day. Instead, it selects options that have already expired at 0:00 AM on the current day. This contradicts the documentation and leads to incorrect option selection for 0DTE strategies.
Documentation Link
The issue occurs in the following documentation page:
Create a QuantConnect algorithm that adds an Option universe for SPX.
Use .set_filter() with a lambda function that includes .expiration(0, 0).
In the OnData method, log the Expiry property of the selected option contracts.
Run the algorithm for a period with 0DTE SPX options.
Observe that the logged Expiry times are all at 0:00 AM on the current day.
Minimal Reproducible Code Example
fromAlgorithmImportsimport*classOptionExpiryTest(QCAlgorithm):
definitialize(self):
self.set_start_date(2024, 6, 1)
index=self.add_index("SPX")
self.spx_option=self.add_index_option(index.symbol,"SPXW")
self.spx_option.set_filter(lambdauniverse: universe.include_weeklys().expiration(0, 0).strikes(-3,3))
defon_data(self, data):
chain=data.option_chains.get(self.spx_option.symbol)
ifnotchain:
returnforoptioninchain:
self.Log(f"Option Expiry: {option.expiry}")
self.Quit() # Stop after the first data point
Expected Behavior
The .expiration(0, 0) filter should select options that expire at the end of the current trading day, allowing for 0DTE strategies to function correctly.
Actual Behavior
The .expiration(0, 0) filter selects options that expired at 0:00 AM on the current day, making them unusable for trading.
Additional Information
This issue was discovered while attempting to implement an Iron Condor strategy. The incorrect filter behavior leads to selecting expired contracts, resulting in errors and incorrect trading decisions.
The text was updated successfully, but these errors were encountered:
Summary
The
.expiration(0, 0)
method in the Option Universe Selection filter does not select options expiring at the end of the current trading day. Instead, it selects options that have already expired at 0:00 AM on the current day. This contradicts the documentation and leads to incorrect option selection for 0DTE strategies.Documentation Link
The issue occurs in the following documentation page:
https://www.lean.io/docs/v2/writing-algorithms/universes/option-filters#Expiration
Steps to Reproduce
.set_filter()
with a lambda function that includes.expiration(0, 0)
.OnData
method, log theExpiry
property of the selected option contracts.Expiry
times are all at 0:00 AM on the current day.Minimal Reproducible Code Example
Expected Behavior
The .expiration(0, 0) filter should select options that expire at the end of the current trading day, allowing for 0DTE strategies to function correctly.
Actual Behavior
The .expiration(0, 0) filter selects options that expired at 0:00 AM on the current day, making them unusable for trading.
Additional Information
This issue was discovered while attempting to implement an Iron Condor strategy. The incorrect filter behavior leads to selecting expired contracts, resulting in errors and incorrect trading decisions.
The text was updated successfully, but these errors were encountered: