Default option filter now includes weeklies to prevent empty chains (#9162)

* Return weekly contracts if no standard contracts exist

* Fix unit and regression tests

* Centralize default expiration type flags

* Add ExcludeWeeklys() method

* Mark IncludeWeeklys() as obsolete since weeklies are now default
This commit is contained in:
JosueNina
2025-12-31 08:11:46 -05:00
committed by GitHub
parent 2c0390fde3
commit 0854ab82da
51 changed files with 311 additions and 97 deletions
@@ -34,7 +34,7 @@ class BasicTemplateOptionsAlgorithm(QCAlgorithm):
self.option_symbol = option.symbol
# set our strike/expiry filter for this option chain
option.set_filter(lambda u: (u.strikes(-2, +2)
option.set_filter(lambda u: (u.standards_only().strikes(-2, +2)
# Expiration method accepts TimeSpan objects or integer for days.
# The following statements yield the same filtering criteria
.expiration(0, 180)))