Skip to content

IOptionContractFilters

QuantConnect.Securities.IOptionContractFilters

Bases: Generic[QuantConnect_Securities_IOptionContractFilters_TSelf], IContractFilters[QuantConnect_Securities_IOptionContractFilters_TSelf]

The option contract filters shared by the option universe selection (OptionFilterUniverse) and the option chain (Data.Market.OptionChain), so both offer the same filters with the same semantics, on top of the ones every contract has, see IContractFilters{TSelf}. OptionChainTests.ChainExposesEveryUniverseFilter checks that every universe filter is declared here

strikes

strikes(
    min_strike: int, max_strike: int
) -> QuantConnect_Securities_IOptionContractFilters_TSelf
strikes(
    strikes: List[float],
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Signature descriptions:

  • Selects the contracts with strikes in the given range relative to the underlying price, in number of strikes

  • Selects the contracts with any of the given strike prices

atm

atm(
    max_strike_distance: Optional[float] = None,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the contracts at the money. Alias for at_the_money

at_the_money

at_the_money(
    max_strike_distance: Optional[float] = None,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the contracts with strikes within the given distance of the underlying price, in units of it, zero only a strike equal to the price; null, the default, the strikes on either side of the price, each within the percentage of it given by OptionFilterUniverse.default_at_the_money_strike_distance

box_spread

box_spread(
    min_days_till_expiry: int = 30, strike_spread: float = 5
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects an OTM call, an ITM call, an OTM put and an ITM put with the same expiry closest to the criteria given

call_butterfly

call_butterfly(
    min_days_till_expiry: int = 30, strike_spread: float = 5
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects an ITM, an ATM and an OTM call with the same expiry and equal strike distance closest to the criteria given

call_calendar_spread

call_calendar_spread(
    strike_from_atm: float = 0,
    min_near_days_till_expiry: int = 30,
    min_far_days_till_expiry: int = 60,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the 2 call contracts with the same strike and different expiries closest to the criteria given

call_ladder

call_ladder(
    min_days_till_expiry: int,
    higher_strike_from_atm: float,
    middle_strike_from_atm: float,
    lower_strike_from_atm: float,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects 3 calls with the same expiry and different strikes closest to the criteria given

calls_only

calls_only() -> (
    QuantConnect_Securities_IOptionContractFilters_TSelf
)

Selects the call contracts

call_spread

call_spread(
    min_days_till_expiry: int = 30,
    higher_strike_from_atm: float = 5,
    lower_strike_from_atm: Optional[float] = None,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the 2 call contracts with the same expiry and different strikes closest to the criteria given

conversion

conversion(
    min_days_till_expiry: int = 30,
    strike_from_atm: float = 5,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects a call and a put with the same expiry and strike closest to the criteria given

d

d(
    min: float, max: float
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the contracts with delta in the given range. Alias for delta

delta

delta(
    min: float, max: float
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the contracts with delta in the given range

g

g(
    min: float, max: float
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the contracts with gamma in the given range. Alias for gamma

gamma

gamma(
    min: float, max: float
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the contracts with gamma in the given range

implied_volatility

implied_volatility(
    min: float, max: float
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the contracts with implied volatility in the given range

in_the_money

in_the_money() -> (
    QuantConnect_Securities_IOptionContractFilters_TSelf
)

Selects the in the money contracts: calls below and puts above the underlying price

iron_butterfly

iron_butterfly(
    min_days_till_expiry: int = 30, strike_spread: float = 5
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects an OTM call, an ATM call, an ATM put and an OTM put with the same expiry and equal strike distance closest to the criteria given

iron_condor

iron_condor(
    min_days_till_expiry: int = 30,
    near_strike_spread: float = 5,
    far_strike_spread: float = 10,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects a far OTM call, a near OTM call, a near OTM put and a far OTM put with the same expiry closest to the criteria given

itm

itm() -> (
    QuantConnect_Securities_IOptionContractFilters_TSelf
)

Selects the in the money contracts. Alias for in_the_money

iv

iv(
    min: float, max: float
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the contracts with implied volatility in the given range. Alias for implied_volatility

jelly_roll

jelly_roll(
    strike_from_atm: float = 0,
    min_near_days_till_expiry: int = 30,
    min_far_days_till_expiry: int = 60,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects 2 calls and 2 puts with the same strike and 2 expiries closest to the criteria given

naked_call

naked_call(
    min_days_till_expiry: int = 30,
    strike_from_atm: float = 0,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the single call contract with the closest match to the criteria given

naked_put

naked_put(
    min_days_till_expiry: int = 30,
    strike_from_atm: float = 0,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the single put contract with the closest match to the criteria given

otm

otm() -> (
    QuantConnect_Securities_IOptionContractFilters_TSelf
)

Selects the out of the money contracts. Alias for out_of_the_money

out_of_the_money

out_of_the_money() -> (
    QuantConnect_Securities_IOptionContractFilters_TSelf
)

Selects the out of the money contracts: calls above and puts below the underlying price

protective_collar

protective_collar(
    min_days_till_expiry: int = 30,
    call_strike_from_atm: float = 5,
    put_strike_from_atm: float = -5,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects a call and a put with the same expiry and a lower put strike closest to the criteria given

put_butterfly

put_butterfly(
    min_days_till_expiry: int = 30, strike_spread: float = 5
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects an ITM, an ATM and an OTM put with the same expiry and equal strike distance closest to the criteria given

put_calendar_spread

put_calendar_spread(
    strike_from_atm: float = 0,
    min_near_days_till_expiry: int = 30,
    min_far_days_till_expiry: int = 60,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the 2 put contracts with the same strike and different expiries closest to the criteria given

put_ladder

put_ladder(
    min_days_till_expiry: int,
    higher_strike_from_atm: float,
    middle_strike_from_atm: float,
    lower_strike_from_atm: float,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects 3 puts with the same expiry and different strikes closest to the criteria given

puts_only

puts_only() -> (
    QuantConnect_Securities_IOptionContractFilters_TSelf
)

Selects the put contracts

put_spread

put_spread(
    min_days_till_expiry: int = 30,
    higher_strike_from_atm: float = 5,
    lower_strike_from_atm: Optional[float] = None,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the 2 put contracts with the same expiry and different strikes closest to the criteria given

r

r(
    min: float, max: float
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the contracts with rho in the given range. Alias for rho

rho

rho(
    min: float, max: float
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the contracts with rho in the given range

straddle

straddle(
    min_days_till_expiry: int = 30,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the ATM call and the ATM put with the same expiry closest to the criteria given

strangle

strangle(
    min_days_till_expiry: int = 30,
    call_strike_from_atm: float = 5,
    put_strike_from_atm: float = -5,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects an OTM call and an OTM put with the same expiry closest to the criteria given

strikes_above

strikes_above(
    price: float,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the contracts with strikes above the given price, excluding it

strikes_below

strikes_below(
    price: float,
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the contracts with strikes below the given price, excluding it

t

t(
    min: float, max: float
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the contracts with theta in the given range. Alias for theta

theta

theta(
    min: float, max: float
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the contracts with theta in the given range

v

v(
    min: float, max: float
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the contracts with vega in the given range. Alias for vega

vega

vega(
    min: float, max: float
) -> QuantConnect_Securities_IOptionContractFilters_TSelf

Selects the contracts with vega in the given range

expiration

expiration(
    min_expiry: timedelta, max_expiry: timedelta
) -> QuantConnect_Securities_IContractFilters_TSelf
expiration(
    min_expiry_days: int, max_expiry_days: int
) -> QuantConnect_Securities_IContractFilters_TSelf
expiration(
    expiries: List[datetime],
) -> QuantConnect_Securities_IContractFilters_TSelf

Signature descriptions:

  • Selects the contracts expiring in the given range relative to the current date

  • Selects the contracts expiring in the given range of days relative to the current date

  • Selects the contracts expiring on any of the given dates, ignoring the time of day

back_month

back_month() -> (
    QuantConnect_Securities_IContractFilters_TSelf
)

Selects the contracts of the second nearest expiration

back_months

back_months() -> (
    QuantConnect_Securities_IContractFilters_TSelf
)

Selects the contracts of all expirations but the nearest one

expiring_after

expiring_after(
    date: Union[datetime, date],
) -> QuantConnect_Securities_IContractFilters_TSelf

Selects the contracts expiring after the given date, excluding it

expiring_before

expiring_before(
    date: Union[datetime, date],
) -> QuantConnect_Securities_IContractFilters_TSelf

Selects the contracts expiring before the given date, excluding it

farthest_expiration

farthest_expiration() -> (
    QuantConnect_Securities_IContractFilters_TSelf
)

Selects the contracts of the farthest expiration

front_month

front_month() -> (
    QuantConnect_Securities_IContractFilters_TSelf
)

Selects the contracts of the nearest expiration

oi

oi(
    min: int, max: int
) -> QuantConnect_Securities_IContractFilters_TSelf

Selects the contracts with open interest in the given range. Alias for open_interest

open_interest

open_interest(
    min: int, max: int
) -> QuantConnect_Securities_IContractFilters_TSelf

Selects the contracts with open interest in the given range

standards_only

standards_only() -> (
    QuantConnect_Securities_IContractFilters_TSelf
)

Selects the standard contracts, excluding weeklys

volume

volume(
    min: int, max: int
) -> QuantConnect_Securities_IContractFilters_TSelf

Selects the contracts with volume in the given range

weeklys_only

weeklys_only() -> (
    QuantConnect_Securities_IContractFilters_TSelf
)

Selects the non standard weekly contracts

zero_dte

zero_dte() -> (
    QuantConnect_Securities_IContractFilters_TSelf
)

Selects the contracts expiring today