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
@@ -39,8 +39,7 @@ class BasicTemplateOptionStrategyAlgorithm(QCAlgorithm):
# set our strike/expiry filter for this option chain
# SetFilter method accepts timedelta objects or integer for days.
# The following statements yield the same filtering criteria
option.set_filter(-2, +2, 0, 180)
# option.set_filter(-2,2, timedelta(0), timedelta(180))
option.set_filter(lambda u: (u.standards_only().strikes(-2, +2).expiration(0, 180)))
# use the underlying equity as the benchmark
self.set_benchmark("GOOG")