OptionChainFilterUniverse
QuantConnect.Securities.OptionChainFilterUniverse
OptionChainFilterUniverse(underlying_scale_factor: float)
OptionChainFilterUniverse(
all_data: Sequence[
QuantConnect_Securities_BaseOptionFilterUniverse_TData
],
underlying: BaseData,
local_time: Union[datetime, date],
underlying_scale_factor: float = 1,
)
Bases: BaseOptionFilterUniverse[QuantConnect_Securities_OptionChainFilterUniverse, OptionContract]
Option contracts filter over the contracts of an OptionChain, so chains offer the same filters as the option universe selection (OptionFilterUniverse)
Signature descriptions:
-
Constructs BaseOptionFilterUniverse By default, the filter includes both standard and weekly contracts.
-
Constructs BaseOptionFilterUniverse
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
underlying_scale_factor
|
float
|
The option strike multiplier, see SymbolProperties.strike_multiplier |
1
|
all_data
|
Optional[Sequence[QuantConnect_Securities_BaseOptionFilterUniverse_TData]]
|
All data for the option contracts |
None
|
underlying
|
Optional[BaseData]
|
The current underlying last data point |
None
|
local_time
|
Optional[Union[datetime, date]]
|
The current local time |
None
|
exchange_hours
exchange_hours: SecurityExchangeHours
The option exchange hours
This Property is protected.
count
count: int
The number of contracts in the universe
DEFAULT_EXPIRATION_TYPE
DEFAULT_EXPIRATION_TYPE: ContractExpirationType = ...
The default expiration type filter value
This Field is protected.
type
type: ContractExpirationType
Expiration Types allowed through the filter Standards only by default
This Property is protected.
local_time
local_time: datetime
The local exchange current time
underlying_internal
underlying_internal: BaseData
The underlying price data
This Property is protected.
ContractExpirationType
Bases: IntEnum
Defines listed contract types with Flags attribute
This Class is protected.
STANDARD
STANDARD = 1
Standard contracts
WEEKLY
WEEKLY = 2
Non standard weekly contracts
create_data_instance
create_data_instance(
symbol: Union[Symbol, str, BaseContract, Security],
) -> OptionContract
Not supported: the chain filters only ever select contracts that are already in the chain
This Class is protected.
get_greeks
get_greeks(contract: OptionContract) -> Greeks
Gets the greeks of the given contract
This Class is protected.
get_implied_volatility
get_implied_volatility(contract: OptionContract) -> float
Gets the implied volatility of the given contract
This Class is protected.
get_open_interest
get_open_interest(contract: OptionContract) -> float
Gets the open interest of the given contract
This Class is protected.
get_volume
get_volume(contract: OptionContract) -> float
Gets the volume of the given contract
This Class is protected.
expiration
expiration(
min_expiry: timedelta, max_expiry: timedelta
) -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
expiration(
min_expiry_days: int, max_expiry_days: int
) -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
expiration(
expiries: List[datetime],
) -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
Signature descriptions:
-
Applies filter selecting options contracts based on a range of expiration dates relative to the current day
-
Applies filter selecting contracts based on a range of expiration dates relative to the current day
-
Applies filter selecting the contracts expiring on any of the given dates. Time of day is ignored
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_expiry
|
Optional[timedelta]
|
The minimum time until expiry to include, for example, TimeSpan.FromDays(10) |
None
|
max_expiry
|
Optional[timedelta]
|
The maximum time until expiry to include, for example, TimeSpan.FromDays(10) |
None
|
min_expiry_days
|
Optional[int]
|
The minimum time, expressed in days, until expiry to include, for example, 10 |
None
|
max_expiry_days
|
Optional[int]
|
The maximum time, expressed in days, until expiry to include, for example, 10 |
None
|
expiries
|
Optional[List[datetime]]
|
The expiration dates |
None
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_ContractSecurityFilterUniverse_T
|
Universe with filter applied. |
back_month
back_month() -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
Returns first of back month contracts
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_ContractSecurityFilterUniverse_T
|
Universe with filter applied. |
back_months
back_months() -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
Returns a list of back month contracts
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_ContractSecurityFilterUniverse_T
|
Universe with filter applied. |
expiring_after
expiring_after(
date: Union[datetime, date],
) -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
Applies filter selecting the contracts expiring after the given date, excluding it. Time of day is ignored
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
Union[datetime, date]
|
The date the expirations must be after |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_ContractSecurityFilterUniverse_T
|
Universe with filter applied. |
expiring_before
expiring_before(
date: Union[datetime, date],
) -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
Applies filter selecting the contracts expiring before the given date, excluding it. Time of day is ignored
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
Union[datetime, date]
|
The date the expirations must be before |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_ContractSecurityFilterUniverse_T
|
Universe with filter applied. |
farthest_expiration
farthest_expiration() -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
Returns the contracts of the farthest expiration
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_ContractSecurityFilterUniverse_T
|
Universe with filter applied. |
front_month
front_month() -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
Returns front month contract
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_ContractSecurityFilterUniverse_T
|
Universe with filter applied. |
oi
oi(
min: int, max: int
) -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
Applies filter selecting the contracts with open interest between the given range. Alias for open_interest
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
int
|
The minimum open interest value |
required |
max
|
int
|
The maximum open interest value |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_ContractSecurityFilterUniverse_T
|
Universe with filter applied. |
open_interest
open_interest(
min: int, max: int
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Applies the filter to the universe selecting the contracts with open interest between the given range. Not supported for future options
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
int
|
The minimum open interest value |
required |
max
|
int
|
The maximum open interest value |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
standards_only
standards_only() -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
Sets universe of standard contracts (if any) as selection Contracts by default are standards; only needed to switch back if changed
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_ContractSecurityFilterUniverse_T
|
Universe with filter applied. |
volume
volume(
min: int, max: int
) -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
Applies filter selecting the contracts with volume between the given range
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
int
|
The minimum volume |
required |
max
|
int
|
The maximum volume |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_ContractSecurityFilterUniverse_T
|
Universe with filter applied. |
weeklys_only
weeklys_only() -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
Sets universe of weeklys contracts (if any) as selection
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_ContractSecurityFilterUniverse_T
|
Universe with filter applied. |
zero_dte
zero_dte() -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
Applies filter selecting the contracts expiring today
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_ContractSecurityFilterUniverse_T
|
Universe with filter applied. |
strikes
strikes(
min_strike: int, max_strike: int
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
strikes(
strikes: List[float],
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Signature descriptions:
-
Applies filter selecting options contracts based on a range of strikes in relative terms
-
Applies filter selecting the contracts with any of the given strike prices
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_strike
|
Optional[int]
|
The minimum strike relative to the underlying price, for example, -1 would filter out contracts further than 1 strike below market price |
None
|
max_strike
|
Optional[int]
|
The maximum strike relative to the underlying price, for example, +1 would filter out contracts further than 1 strike above market price |
None
|
strikes
|
Optional[List[float]]
|
The strike prices |
None
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
atm
atm(
max_strike_distance: Optional[float] = None,
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Applies filter selecting the contracts at the money. Alias for at_the_money
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_strike_distance
|
Optional[float]
|
The largest distance between a strike and the underlying price for its contracts to be at the money, in units of the underlying price. Zero selects only a strike equal to the price. Null, the default, selects the strikes on either side of the price, the highest at or below it and the lowest at or above it, each only when it is within the percentage of the price given by OptionFilterUniverse.default_at_the_money_strike_distance |
None
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
at_the_money
at_the_money(
max_strike_distance: Optional[float] = None,
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Applies filter selecting the contracts at the money: the ones with strikes within the given distance of the underlying price, or by default the ones at the strikes on either side of it. Selects nothing when the underlying price is unknown
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_strike_distance
|
Optional[float]
|
The largest distance between a strike and the underlying price for its contracts to be at the money, in units of the underlying price. Zero selects only a strike equal to the price. Null, the default, selects the strikes on either side of the price, the highest at or below it and the lowest at or above it, each only when it is within the percentage of the price given by OptionFilterUniverse.default_at_the_money_strike_distance |
None
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
box_spread
box_spread(
min_days_till_expiry: int = 30, strike_spread: float = 5
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Sets universe of an OTM call, an ITM call, an OTM put, and an ITM put with the same expiry with closest match to the criteria given. The OTM call has the same strike as the ITM put, while the same holds for the ITM call and the OTM put
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_days_till_expiry
|
int
|
The minimum days till expiry from the current time, closest expiry will be selected |
30
|
strike_spread
|
float
|
The desire strike price distance of the OTM call and the OTM put from the current underlying price |
5
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
call_butterfly
call_butterfly(
min_days_till_expiry: int = 30, strike_spread: float = 5
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Sets universe of an ITM call, an ATM call, and an OTM call with the same expiry and equal strike price distance, with closest match to the criteria given
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_days_till_expiry
|
int
|
The minimum days till expiry from the current time, closest expiry will be selected |
30
|
strike_spread
|
float
|
The desire strike price distance of the ITM call and the OTM call from the current underlying price |
5
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
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_BaseOptionFilterUniverse_TUniverse
Sets universe of 2 call contracts with the same strike price and different expiration dates, with closest match to the criteria given
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strike_from_atm
|
float
|
The desire strike price distance from the current underlying price |
0
|
min_near_days_till_expiry
|
int
|
The mininum days till expiry of the closer contract from the current time, closest expiry will be selected |
30
|
min_far_days_till_expiry
|
int
|
The mininum days till expiry of the further conrtact from the current time, closest expiry will be selected |
60
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
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_BaseOptionFilterUniverse_TUniverse
Sets universe of 3 call contracts with the same expiry and different strike prices, with closest match to the criteria given
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_days_till_expiry
|
int
|
The minimum days till expiry from the current time, closest expiry will be selected |
required |
higher_strike_from_atm
|
float
|
The desire strike price distance from the current underlying price of the higher strike price |
required |
middle_strike_from_atm
|
float
|
The desire strike price distance from the current underlying price of the middle strike price |
required |
lower_strike_from_atm
|
float
|
The desire strike price distance from the current underlying price of the lower strike price |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
calls_only
calls_only() -> (
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
)
Sets universe of call options (if any) as a selection
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
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_BaseOptionFilterUniverse_TUniverse
Sets universe of 2 call contracts with the same expiry and different strike prices, with closest match to the criteria given
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_days_till_expiry
|
int
|
The minimum days till expiry from the current time, closest expiry will be selected |
30
|
higher_strike_from_atm
|
float
|
The desire strike price distance from the current underlying price of the higher strike price |
5
|
lower_strike_from_atm
|
Optional[float]
|
The desire strike price distance from the current underlying price of the lower strike price |
None
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
conversion
conversion(
min_days_till_expiry: int = 30,
strike_from_atm: float = 5,
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Sets universe of a call contract and a put contract with the same expiry and strike price, with closest match to the criteria given
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_days_till_expiry
|
int
|
The minimum days till expiry from the current time, closest expiry will be selected |
30
|
strike_from_atm
|
float
|
The desire strike price distance from the current underlying price |
5
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
d
d(
min: float, max: float
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Applies the filter to the universe selecting the contracts with Delta between the given range. Alias for delta(decimal, decimal)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum Delta value |
required |
max
|
float
|
The maximum Delta value |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
delta
delta(
min: float, max: float
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Applies the filter to the universe selecting the contracts with Delta between the given range
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum Delta value |
required |
max
|
float
|
The maximum Delta value |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
g
g(
min: float, max: float
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Applies the filter to the universe selecting the contracts with Gamma between the given range. Alias for gamma(decimal, decimal)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum Gamma value |
required |
max
|
float
|
The maximum Gamma value |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
gamma
gamma(
min: float, max: float
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Applies the filter to the universe selecting the contracts with Gamma between the given range
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum Gamma value |
required |
max
|
float
|
The maximum Gamma value |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
implied_volatility
implied_volatility(
min: float, max: float
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Applies the filter to the universe selecting the contracts with implied volatility between the given range
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum implied volatility value |
required |
max
|
float
|
The maximum implied volatility value |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
in_the_money
in_the_money() -> (
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
)
Applies filter selecting the in the money contracts: calls with strikes below the underlying price and puts with strikes above it. Selects nothing when the underlying price is unknown
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
iron_butterfly
iron_butterfly(
min_days_till_expiry: int = 30, strike_spread: float = 5
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Sets universe of an OTM call, an ATM call, an ATM put, and an OTM put with the same expiry and equal strike price distance, with closest match to the criteria given
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_days_till_expiry
|
int
|
The minimum days till expiry from the current time, closest expiry will be selected |
30
|
strike_spread
|
float
|
The desire strike price distance of the OTM call and the OTM put from the current underlying price |
5
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
iron_condor
iron_condor(
min_days_till_expiry: int = 30,
near_strike_spread: float = 5,
far_strike_spread: float = 10,
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Sets universe of a far-OTM call, a near-OTM call, a near-OTM put, and a far-OTM put with the same expiry and equal strike price distance between both calls and both puts, with closest match to the criteria given
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_days_till_expiry
|
int
|
The minimum days till expiry from the current time, closest expiry will be selected |
30
|
near_strike_spread
|
float
|
The desire strike price distance of the near-to-expiry call and the near-to-expiry put from the current underlying price |
5
|
far_strike_spread
|
float
|
The desire strike price distance of the further-to-expiry call and the further-to-expiry put from the current underlying price |
10
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
itm
itm() -> (
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
)
Applies filter selecting the in the money contracts. Alias for in_the_money
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
iv
iv(
min: float, max: float
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Applies the filter to the universe selecting the contracts with implied volatility between the given range. Alias for implied_volatility(decimal, decimal)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum implied volatility value |
required |
max
|
float
|
The maximum implied volatility value |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
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_BaseOptionFilterUniverse_TUniverse
Sets universe of 2 call and 2 put contracts with the same strike price and 2 expiration dates, with closest match to the criteria given
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strike_from_atm
|
float
|
The desire strike price distance from the current underlying price |
0
|
min_near_days_till_expiry
|
int
|
The mininum days till expiry of the closer contract from the current time, closest expiry will be selected |
30
|
min_far_days_till_expiry
|
int
|
The mininum days till expiry of the further conrtact from the current time, closest expiry will be selected |
60
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
naked_call
naked_call(
min_days_till_expiry: int = 30,
strike_from_atm: float = 0,
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Sets universe of a single call contract with the closest match to criteria given
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_days_till_expiry
|
int
|
The minimum days till expiry from the current time, closest expiry will be selected |
30
|
strike_from_atm
|
float
|
The desire strike price distance from the current underlying price |
0
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
naked_put
naked_put(
min_days_till_expiry: int = 30,
strike_from_atm: float = 0,
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Sets universe of a single put contract with the closest match to criteria given
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_days_till_expiry
|
int
|
The minimum days till expiry from the current time, closest expiry will be selected |
30
|
strike_from_atm
|
float
|
The desire strike price distance from the current underlying price |
0
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
otm
otm() -> (
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
)
Applies filter selecting the out of the money contracts. Alias for out_of_the_money
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
out_of_the_money
out_of_the_money() -> (
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
)
Applies filter selecting the out of the money contracts: calls with strikes above the underlying price and puts with strikes below it. Selects nothing when the underlying price is unknown
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
protective_collar
protective_collar(
min_days_till_expiry: int = 30,
call_strike_from_atm: float = 5,
put_strike_from_atm: float = -5,
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Sets universe of a call contract and a put contract with the same expiry but lower strike price, with closest match to the criteria given
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_days_till_expiry
|
int
|
The minimum days till expiry from the current time, closest expiry will be selected |
30
|
call_strike_from_atm
|
float
|
The desire strike price distance from the current underlying price of the call. |
5
|
put_strike_from_atm
|
float
|
The desire strike price distance from the current underlying price of the put. |
-5
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
put_butterfly
put_butterfly(
min_days_till_expiry: int = 30, strike_spread: float = 5
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Sets universe of an ITM put, an ATM put, and an OTM put with the same expiry and equal strike price distance, with closest match to the criteria given
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_days_till_expiry
|
int
|
The minimum days till expiry from the current time, closest expiry will be selected |
30
|
strike_spread
|
float
|
The desire strike price distance of the ITM put and the OTM put from the current underlying price |
5
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
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_BaseOptionFilterUniverse_TUniverse
Sets universe of 2 put contracts with the same strike price and different expiration dates, with closest match to the criteria given
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strike_from_atm
|
float
|
The desire strike price distance from the current underlying price |
0
|
min_near_days_till_expiry
|
int
|
The mininum days till expiry of the closer contract from the current time, closest expiry will be selected |
30
|
min_far_days_till_expiry
|
int
|
The mininum days till expiry of the further conrtact from the current time, closest expiry will be selected |
60
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
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_BaseOptionFilterUniverse_TUniverse
Sets universe of 3 put contracts with the same expiry and different strike prices, with closest match to the criteria given
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_days_till_expiry
|
int
|
The minimum days till expiry from the current time, closest expiry will be selected |
required |
higher_strike_from_atm
|
float
|
The desire strike price distance from the current underlying price of the higher strike price |
required |
middle_strike_from_atm
|
float
|
The desire strike price distance from the current underlying price of the middle strike price |
required |
lower_strike_from_atm
|
float
|
The desire strike price distance from the current underlying price of the lower strike price |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
puts_only
puts_only() -> (
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
)
Sets universe of put options (if any) as a selection
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
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_BaseOptionFilterUniverse_TUniverse
Sets universe of 2 put contracts with the same expiry and different strike prices, with closest match to the criteria given
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_days_till_expiry
|
int
|
The minimum days till expiry from the current time, closest expiry will be selected |
30
|
higher_strike_from_atm
|
float
|
The desire strike price distance from the current underlying price of the higher strike price |
5
|
lower_strike_from_atm
|
Optional[float]
|
The desire strike price distance from the current underlying price of the lower strike price |
None
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
r
r(
min: float, max: float
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Applies the filter to the universe selecting the contracts with Rho between the given range. Alias for rho(decimal, decimal)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum Rho value |
required |
max
|
float
|
The maximum Rho value |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
rho
rho(
min: float, max: float
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Applies the filter to the universe selecting the contracts with Rho between the given range
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum Rho value |
required |
max
|
float
|
The maximum Rho value |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
straddle
straddle(
min_days_till_expiry: int = 30,
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Sets universe of an ATM call contract and an ATM put contract with the same expiry, with closest match to the criteria given
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_days_till_expiry
|
int
|
The minimum days till expiry from the current time, closest expiry will be selected |
30
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
strangle
strangle(
min_days_till_expiry: int = 30,
call_strike_from_atm: float = 5,
put_strike_from_atm: float = -5,
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Sets universe of an OTM call contract and an OTM put contract with the same expiry, with closest match to the criteria given
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_days_till_expiry
|
int
|
The minimum days till expiry from the current time, closest expiry will be selected |
30
|
call_strike_from_atm
|
float
|
The desire strike price distance from the current underlying price of the OTM call. It must be positive. |
5
|
put_strike_from_atm
|
float
|
The desire strike price distance from the current underlying price of the OTM put. It must be negative. |
-5
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
strikes_above
strikes_above(
price: float,
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Applies filter selecting the contracts with strikes above the given price, excluding it
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
price
|
float
|
The price the strikes must be above |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
strikes_below
strikes_below(
price: float,
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Applies filter selecting the contracts with strikes below the given price, excluding it
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
price
|
float
|
The price the strikes must be below |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
t
t(
min: float, max: float
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Applies the filter to the universe selecting the contracts with Theta between the given range. Alias for theta(decimal, decimal)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum Theta value |
required |
max
|
float
|
The maximum Theta value |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
theta
theta(
min: float, max: float
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Applies the filter to the universe selecting the contracts with Theta between the given range
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum Theta value |
required |
max
|
float
|
The maximum Theta value |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
v
v(
min: float, max: float
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Applies the filter to the universe selecting the contracts with Vega between the given range. Alias for vega(decimal, decimal)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum Vega value |
required |
max
|
float
|
The maximum Vega value |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
vega
vega(
min: float, max: float
) -> QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
Applies the filter to the universe selecting the contracts with Vega between the given range
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum Vega value |
required |
max
|
float
|
The maximum Vega value |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_BaseOptionFilterUniverse_TUniverse
|
Universe with filter applied. |
__len__
__len__() -> int
contracts
contracts(
contracts: Any,
) -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
contracts(
contracts: List[Symbol],
) -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
contracts(
contracts: List[
QuantConnect_Securities_ContractSecurityFilterUniverse_TData
],
) -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
contracts(
contract_selector: Callable[
[
List[
QuantConnect_Securities_ContractSecurityFilterUniverse_TData
]
],
List[Symbol],
],
) -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
contracts(
contract_selector: Callable[
[
List[
QuantConnect_Securities_ContractSecurityFilterUniverse_TData
]
],
List[
QuantConnect_Securities_ContractSecurityFilterUniverse_TData
],
],
) -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
Signature descriptions:
-
Explicitly sets the selected contract symbols for this universe. This overrides and and all other methods of selecting symbols assuming it is called last.
-
Sets a function used to filter the set of available contract filters. The input to the 'contract_selector' function will be the already filtered list if any other filters have already been applied.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
contracts
|
Optional[Any | List[Symbol] | List[QuantConnect_Securities_ContractSecurityFilterUniverse_TData]]
|
The option contract symbol objects to select |
None
|
contract_selector
|
Optional[Callable[[List[QuantConnect_Securities_ContractSecurityFilterUniverse_TData]], List[Symbol]] | Callable[[List[QuantConnect_Securities_ContractSecurityFilterUniverse_TData]], List[QuantConnect_Securities_ContractSecurityFilterUniverse_TData]]]
|
The option contract symbol objects to select |
None
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_ContractSecurityFilterUniverse_T
|
Universe with filter applied. |
__iter__
__iter__() -> (
Iterator[
QuantConnect_Securities_ContractSecurityFilterUniverse_TData
]
)
adjust_expiration_reference_date
adjust_expiration_reference_date(
reference_date: Union[datetime, date],
) -> datetime
Adjusts the date to the next trading day if the current date is not a trading day, so that expiration filter is properly applied. e.g. Selection for Mondays happen on Friday midnight (Saturday start), so if the minimum time to expiration is, say 0, contracts expiring on Monday would be filtered out if the date is not properly adjusted to the next trading day (Monday).
This Class is protected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference_date
|
Union[datetime, date]
|
The date to be adjusted |
required |
Returns:
| Type | Description |
|---|---|
datetime
|
The adjusted date. |
get_enumerator
get_enumerator() -> (
IEnumerator[
QuantConnect_Securities_ContractSecurityFilterUniverse_TData
]
)
IEnumerable interface method implementation
Returns:
| Type | Description |
|---|---|
IEnumerator[QuantConnect_Securities_ContractSecurityFilterUniverse_TData]
|
IEnumerator of Symbols in Universe. |
get_last_trading_date
get_last_trading_date(
symbol: Union[Symbol, str, BaseContract, Security],
) -> datetime
get_last_trading_date(
contract: QuantConnect_Securities_BaseOptionFilterUniverse_TData,
) -> datetime
Signature descriptions:
-
Gets the last trading date of the given contract, see get_last_trading_date(TData). Uses the universe exchange hours and keeps the last resolved expiration, since every contract in the universe shares them
-
Gets the last trading date of the given contract: the previous open day for equity options expiring on a Saturday or a holiday, see OptionSymbol.get_last_day_of_trading(Symbol, SecurityExchangeHours), the expiration date otherwise
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Optional[Union[Symbol, str, BaseContract, Security]]
|
The contract symbol |
None
|
contract
|
Optional[QuantConnect_Securities_BaseOptionFilterUniverse_TData]
|
The contract |
None
|
Returns:
| Type | Description |
|---|---|
datetime
|
The date the contract stops trading. |
include_weeklys
include_weeklys() -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
Includes universe of non-standard weeklys contracts (if any) into selection
IncludeWeeklys is obsolete because weekly contracts are now included by default.
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_ContractSecurityFilterUniverse_T
|
Universe with filter applied. |
in_range
in_range(
selector: Callable[
[
QuantConnect_Securities_ContractSecurityFilterUniverse_TData
],
float,
],
min: float,
max: float,
) -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
Selects the contracts whose value, given by the selector, is within the given range. The selector runs once per contract
This Class is protected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
selector
|
Callable[[QuantConnect_Securities_ContractSecurityFilterUniverse_TData], float]
|
Gets the value of a contract |
required |
min
|
float
|
The minimum value |
required |
max
|
float
|
The maximum value |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_ContractSecurityFilterUniverse_T
|
Universe with filter applied. |
is_standard
is_standard(
symbol: Union[Symbol, str, BaseContract, Security],
) -> bool
Determine if the given Option contract symbol is standard
This Class is protected.
Returns:
| Type | Description |
|---|---|
bool
|
True if standard. |
only_apply_filter_at_market_open
only_apply_filter_at_market_open() -> (
QuantConnect_Securities_ContractSecurityFilterUniverse_T
)
Instructs the engine to only filter contracts on the first time step of each market day.
Deprecated as of 2023-12-13. Filters are always non-dynamic as of now, which means they will only bee applied daily.
Returns:
| Type | Description |
|---|---|
QuantConnect_Securities_ContractSecurityFilterUniverse_T
|
Universe with filter applied. |
refresh
refresh(
all_contracts_data: Sequence[
QuantConnect_Securities_BaseOptionFilterUniverse_TData
],
underlying: BaseData,
local_time: Union[datetime, date],
) -> None
Refreshes this option filter universe and allows specifying if the exchange date changed from last call
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
all_contracts_data
|
Sequence[QuantConnect_Securities_BaseOptionFilterUniverse_TData]
|
All data for the option contracts |
required |
underlying
|
BaseData
|
The current underlying last data point |
required |
local_time
|
Union[datetime, date]
|
The current local time |
required |