OptionChain
QuantConnect.Data.Market.OptionChain
OptionChain(
canonical_option_symbol: Union[
Symbol, str, BaseContract, Security
],
time: Union[datetime, date],
flatten: bool = True,
)
OptionChain(
canonical_option_symbol: Union[
Symbol, str, BaseContract, Security
],
time: Union[datetime, date],
contracts: List[OptionUniverse],
symbol_properties: SymbolProperties,
exchange_hours: SecurityExchangeHours = None,
flatten: bool = True,
)
Bases: BaseChain[OptionContract, OptionContracts, QuantConnect_Data_Market_OptionChain, OptionChainFilterUniverse], IOptionContractFilters[QuantConnect_Data_Market_OptionChain]
The option chain filters, the same ones the option universe selection offers, see IOptionContractFilters{TSelf}. The filters shared with the futures chains live in BaseChain{T, TContractsCollection, TSelf, TUniverse}. Each filter returns a new chain, leaving this one untouched
Signature descriptions:
-
Initializes a new instance of the OptionChain class
-
Initializes a new option chain for a list of contracts as OptionUniverse instances
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
canonical_option_symbol
|
Union[Symbol, str, BaseContract, Security]
|
The symbol for this chain. |
required |
time
|
Union[datetime, date]
|
The time of this chain |
required |
flatten
|
bool
|
Whether to flatten the data frame |
True
|
contracts
|
Optional[List[OptionUniverse]]
|
The list of contracts data |
None
|
symbol_properties
|
Optional[SymbolProperties]
|
The option symbol properties |
None
|
exchange_hours
|
Optional[SecurityExchangeHours]
|
The option exchange hours |
None
|
underlying
underlying: BaseData
Gets the most recent trade information for the underlying. This may be a Tick or a TradeBar
trade_bars
trade_bars: TradeBars
Gets all trade bars for every option contract in this chain, keyed by option symbol
quote_bars
quote_bars: QuoteBars
Gets all quote bars for every option contract in this chain, keyed by option symbol
contracts
contracts: (
QuantConnect_Data_Market_BaseChain_TContractsCollection
)
Gets all contracts in the chain, keyed by option symbol
filtered_contracts
filtered_contracts: HashSet[Symbol]
Gets the set of symbols that passed the Option.ContractFilter
data_frame
data_frame: Any
The data frame representation of the option chain
count
count: int
The number of contracts in this chain
strikes
strikes(min_strike: int, max_strike: int) -> OptionChain
strikes(strikes: List[float]) -> OptionChain
Signature descriptions:
-
Selects the contracts with strikes in the given range relative to the underlying price, in number of strikes. Same as BaseOptionFilterUniverse{TUniverse, TData}.Strikes
-
Selects the contracts with any of the given strike prices. Same as BaseOptionFilterUniverse{TUniverse, TData}.Strikes(IEnumerable{decimal})
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 |
|---|---|
OptionChain
|
A new chain with the filter applied. |
atm
atm(
max_strike_distance: Optional[float] = None,
) -> OptionChain
Selects 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 |
|---|---|
OptionChain
|
A new chain with the filter applied. |
at_the_money
at_the_money(
max_strike_distance: Optional[float] = None,
) -> OptionChain
Selects 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. Same as BaseOptionFilterUniverse{TUniverse, TData}.AtTheMoney
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 |
|---|---|
OptionChain
|
A new chain with the filter applied, empty when the underlying price is unknown. |
box_spread
box_spread(
min_days_till_expiry: int = 30, strike_spread: float = 5
) -> OptionChain
Selects an OTM call, an ITM call, an OTM put and an ITM put with the same expiry closest to the criteria given, for a box spread. Same as BaseOptionFilterUniverse{TUniverse, TData}.BoxSpread
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 desired strike price distance of the OTM call and the OTM put from the current underlying price |
5
|
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
call_butterfly
call_butterfly(
min_days_till_expiry: int = 30, strike_spread: float = 5
) -> OptionChain
Selects an ITM, an ATM and an OTM call with the same expiry and equal strike distance closest to the criteria given, for a call butterfly. Same as BaseOptionFilterUniverse{TUniverse, TData}.CallButterfly
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 desired strike price distance of the ITM and OTM calls from the current underlying price |
5
|
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
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,
) -> OptionChain
Selects the 2 call contracts with the same strike and different expiries closest to the criteria given, for a call calendar spread. Same as BaseOptionFilterUniverse{TUniverse, TData}.CallCalendarSpread
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strike_from_atm
|
float
|
The desired strike price distance from the current underlying price |
0
|
min_near_days_till_expiry
|
int
|
The minimum days till expiry of the closer contract from the current time, closest expiry will be selected |
30
|
min_far_days_till_expiry
|
int
|
The minimum days till expiry of the further contract from the current time, closest expiry will be selected |
60
|
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
call_ladder
call_ladder(
min_days_till_expiry: int,
higher_strike_from_atm: float,
middle_strike_from_atm: float,
lower_strike_from_atm: float,
) -> OptionChain
Selects 3 calls with the same expiry and different strikes closest to the criteria given, for a bull or bear call ladder. Same as BaseOptionFilterUniverse{TUniverse, TData}.CallLadder
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 desired strike price distance from the current underlying price of the higher strike price |
required |
middle_strike_from_atm
|
float
|
The desired strike price distance from the current underlying price of the middle strike price |
required |
lower_strike_from_atm
|
float
|
The desired strike price distance from the current underlying price of the lower strike price |
required |
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
calls_only
calls_only() -> OptionChain
Selects the call contracts. Same as BaseOptionFilterUniverse{TUniverse, TData}.CallsOnly
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the 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,
) -> OptionChain
Selects the 2 call contracts with the same expiry and different strikes closest to the criteria given, for a bull or bear call spread. Same as BaseOptionFilterUniverse{TUniverse, TData}.CallSpread
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 desired strike price distance from the current underlying price of the higher strike price |
5
|
lower_strike_from_atm
|
Optional[float]
|
The desired strike price distance from the current underlying price of the lower strike price |
None
|
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
clone
clone() -> BaseData
Return a new instance clone of this object, used in fill forward
Returns:
| Type | Description |
|---|---|
BaseData
|
A clone of the current object. |
conversion
conversion(
min_days_till_expiry: int = 30,
strike_from_atm: float = 5,
) -> OptionChain
Selects a call and a put with the same expiry and strike closest to the criteria given, for a conversion or reverse conversion. Same as BaseOptionFilterUniverse{TUniverse, TData}.Conversion
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 desired strike price distance from the current underlying price |
5
|
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
create_chain
create_chain(
contracts: List[OptionContract],
) -> OptionChain
Creates a copy of this chain with only the given contracts
This Class is protected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
contracts
|
List[OptionContract]
|
The contracts to keep |
required |
create_filter_universe
create_filter_universe() -> OptionChainFilterUniverse
Creates the filter universe over the contracts of this chain
This Class is protected.
d
d(min: float, max: float) -> OptionChain
Selects the contracts with delta in the given range. Alias for delta
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum delta value |
required |
max
|
float
|
The maximum delta value |
required |
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the filter applied. |
delta
delta(min: float, max: float) -> OptionChain
Selects the contracts with delta in the given range. Same as BaseOptionFilterUniverse{TUniverse, TData}.Delta
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum delta value |
required |
max
|
float
|
The maximum delta value |
required |
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the filter applied. |
g
g(min: float, max: float) -> OptionChain
Selects the contracts with gamma in the given range. Alias for gamma
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum gamma value |
required |
max
|
float
|
The maximum gamma value |
required |
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the filter applied. |
gamma
gamma(min: float, max: float) -> OptionChain
Selects the contracts with gamma in the given range. Same as BaseOptionFilterUniverse{TUniverse, TData}.Gamma
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum gamma value |
required |
max
|
float
|
The maximum gamma value |
required |
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the filter applied. |
implied_volatility
implied_volatility(min: float, max: float) -> OptionChain
Selects the contracts with implied volatility in the given range. Same as BaseOptionFilterUniverse{TUniverse, TData}.ImpliedVolatility
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum implied volatility value |
required |
max
|
float
|
The maximum implied volatility value |
required |
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the filter applied. |
in_the_money
in_the_money() -> OptionChain
Selects the in the money contracts: calls with strikes below the underlying price and puts with strikes above it. Same as BaseOptionFilterUniverse{TUniverse, TData}.InTheMoney
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the filter applied, empty when the underlying price is unknown. |
iron_butterfly
iron_butterfly(
min_days_till_expiry: int = 30, strike_spread: float = 5
) -> OptionChain
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, for an iron butterfly. Same as BaseOptionFilterUniverse{TUniverse, TData}.IronButterfly
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 desired strike price distance of the OTM call and the OTM put from the current underlying price |
5
|
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
iron_condor
iron_condor(
min_days_till_expiry: int = 30,
near_strike_spread: float = 5,
far_strike_spread: float = 10,
) -> OptionChain
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, for an iron condor. Same as BaseOptionFilterUniverse{TUniverse, TData}.IronCondor
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 desired strike price distance of the near call and near put from the current underlying price |
5
|
far_strike_spread
|
float
|
The desired strike price distance of the far call and far put from the current underlying price |
10
|
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
itm
itm() -> OptionChain
Selects the in the money contracts. Alias for in_the_money
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the filter applied. |
iv
iv(min: float, max: float) -> OptionChain
Selects the contracts with implied volatility in the given range. Alias for implied_volatility
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum implied volatility value |
required |
max
|
float
|
The maximum implied volatility value |
required |
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the 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,
) -> OptionChain
Selects 2 calls and 2 puts with the same strike and 2 expiries closest to the criteria given, for a jelly roll. Same as BaseOptionFilterUniverse{TUniverse, TData}.JellyRoll
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strike_from_atm
|
float
|
The desired strike price distance from the current underlying price |
0
|
min_near_days_till_expiry
|
int
|
The minimum days till expiry of the closer contract from the current time, closest expiry will be selected |
30
|
min_far_days_till_expiry
|
int
|
The minimum days till expiry of the further contract from the current time, closest expiry will be selected |
60
|
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
naked_call
naked_call(
min_days_till_expiry: int = 30,
strike_from_atm: float = 0,
) -> OptionChain
Selects the single call contract with the closest match to the criteria given, for a naked, covered or protective call. Same as BaseOptionFilterUniverse{TUniverse, TData}.NakedCall
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 desired strike price distance from the current underlying price |
0
|
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
naked_put
naked_put(
min_days_till_expiry: int = 30,
strike_from_atm: float = 0,
) -> OptionChain
Selects the single put contract with the closest match to the criteria given, for a naked, covered or protective put. Same as BaseOptionFilterUniverse{TUniverse, TData}.NakedPut
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 desired strike price distance from the current underlying price |
0
|
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
otm
otm() -> OptionChain
Selects the out of the money contracts. Alias for out_of_the_money
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the filter applied. |
out_of_the_money
out_of_the_money() -> OptionChain
Selects the out of the money contracts: calls with strikes above the underlying price and puts with strikes below it. Same as BaseOptionFilterUniverse{TUniverse, TData}.OutOfTheMoney
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the filter applied, empty when the underlying price is unknown. |
protective_collar
protective_collar(
min_days_till_expiry: int = 30,
call_strike_from_atm: float = 5,
put_strike_from_atm: float = -5,
) -> OptionChain
Selects a call and a put with the same expiry and a lower put strike closest to the criteria given, for a protective collar. Same as BaseOptionFilterUniverse{TUniverse, TData}.ProtectiveCollar
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 desired strike price distance from the current underlying price of the call |
5
|
put_strike_from_atm
|
float
|
The desired strike price distance from the current underlying price of the put |
-5
|
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
put_butterfly
put_butterfly(
min_days_till_expiry: int = 30, strike_spread: float = 5
) -> OptionChain
Selects an ITM, an ATM and an OTM put with the same expiry and equal strike distance closest to the criteria given, for a put butterfly. Same as BaseOptionFilterUniverse{TUniverse, TData}.PutButterfly
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 desired strike price distance of the ITM and OTM puts from the current underlying price |
5
|
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
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,
) -> OptionChain
Selects the 2 put contracts with the same strike and different expiries closest to the criteria given, for a put calendar spread. Same as BaseOptionFilterUniverse{TUniverse, TData}.PutCalendarSpread
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strike_from_atm
|
float
|
The desired strike price distance from the current underlying price |
0
|
min_near_days_till_expiry
|
int
|
The minimum days till expiry of the closer contract from the current time, closest expiry will be selected |
30
|
min_far_days_till_expiry
|
int
|
The minimum days till expiry of the further contract from the current time, closest expiry will be selected |
60
|
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
put_ladder
put_ladder(
min_days_till_expiry: int,
higher_strike_from_atm: float,
middle_strike_from_atm: float,
lower_strike_from_atm: float,
) -> OptionChain
Selects 3 puts with the same expiry and different strikes closest to the criteria given, for a bull or bear put ladder. Same as BaseOptionFilterUniverse{TUniverse, TData}.PutLadder
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 desired strike price distance from the current underlying price of the higher strike price |
required |
middle_strike_from_atm
|
float
|
The desired strike price distance from the current underlying price of the middle strike price |
required |
lower_strike_from_atm
|
float
|
The desired strike price distance from the current underlying price of the lower strike price |
required |
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
puts_only
puts_only() -> OptionChain
Selects the put contracts. Same as BaseOptionFilterUniverse{TUniverse, TData}.PutsOnly
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the 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,
) -> OptionChain
Selects the 2 put contracts with the same expiry and different strikes closest to the criteria given, for a bull or bear put spread. Same as BaseOptionFilterUniverse{TUniverse, TData}.PutSpread
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 desired strike price distance from the current underlying price of the higher strike price |
5
|
lower_strike_from_atm
|
Optional[float]
|
The desired strike price distance from the current underlying price of the lower strike price |
None
|
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
r
r(min: float, max: float) -> OptionChain
Selects the contracts with rho in the given range. Alias for rho
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum rho value |
required |
max
|
float
|
The maximum rho value |
required |
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the filter applied. |
rho
rho(min: float, max: float) -> OptionChain
Selects the contracts with rho in the given range. Same as BaseOptionFilterUniverse{TUniverse, TData}.Rho
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum rho value |
required |
max
|
float
|
The maximum rho value |
required |
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the filter applied. |
straddle
straddle(min_days_till_expiry: int = 30) -> OptionChain
Selects the ATM call and the ATM put with the same expiry closest to the criteria given, for a straddle. Same as BaseOptionFilterUniverse{TUniverse, TData}.Straddle
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 |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
strangle
strangle(
min_days_till_expiry: int = 30,
call_strike_from_atm: float = 5,
put_strike_from_atm: float = -5,
) -> OptionChain
Selects an OTM call and an OTM put with the same expiry closest to the criteria given, for a strangle. Same as BaseOptionFilterUniverse{TUniverse, TData}.Strangle
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 desired strike price distance from the current underlying price of the OTM call, must be positive |
5
|
put_strike_from_atm
|
float
|
The desired strike price distance from the current underlying price of the OTM put, must be negative |
-5
|
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the selected contracts, empty if there is no match. |
strikes_above
strikes_above(price: float) -> OptionChain
Selects the contracts with strikes above the given price, excluding it. Same as BaseOptionFilterUniverse{TUniverse, TData}.StrikesAbove
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
price
|
float
|
The price the strikes must be above |
required |
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the filter applied. |
strikes_below
strikes_below(price: float) -> OptionChain
Selects the contracts with strikes below the given price, excluding it. Same as BaseOptionFilterUniverse{TUniverse, TData}.StrikesBelow
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
price
|
float
|
The price the strikes must be below |
required |
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the filter applied. |
t
t(min: float, max: float) -> OptionChain
Selects the contracts with theta in the given range. Alias for theta
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum theta value |
required |
max
|
float
|
The maximum theta value |
required |
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the filter applied. |
theta
theta(min: float, max: float) -> OptionChain
Selects the contracts with theta in the given range. Same as BaseOptionFilterUniverse{TUniverse, TData}.Theta
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum theta value |
required |
max
|
float
|
The maximum theta value |
required |
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the filter applied. |
v
v(min: float, max: float) -> OptionChain
Selects the contracts with vega in the given range. Alias for vega
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum vega value |
required |
max
|
float
|
The maximum vega value |
required |
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the filter applied. |
vega
vega(min: float, max: float) -> OptionChain
Selects the contracts with vega in the given range. Same as BaseOptionFilterUniverse{TUniverse, TData}.Vega
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
float
|
The minimum vega value |
required |
max
|
float
|
The maximum vega value |
required |
Returns:
| Type | Description |
|---|---|
OptionChain
|
A new chain with the filter applied. |
expiration
expiration(
min_expiry: timedelta, max_expiry: timedelta
) -> QuantConnect_Data_Market_BaseChain_TSelf
expiration(
min_expiry_days: int, max_expiry_days: int
) -> QuantConnect_Data_Market_BaseChain_TSelf
expiration(
expiries: List[datetime],
) -> QuantConnect_Data_Market_BaseChain_TSelf
Signature descriptions:
-
Selects the contracts expiring in the given range relative to the chain date. Same as ContractSecurityFilterUniverse{T, TData}.Expiration(TimeSpan, TimeSpan)
-
Selects the contracts expiring in the given range of days relative to the chain date. Same as ContractSecurityFilterUniverse{T, TData}.Expiration(int, int)
-
Selects the contracts expiring on any of the given dates. Time of day is ignored. Same as ContractSecurityFilterUniverse{T, TData}.Expiration(IEnumerable{DateTime})
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_Data_Market_BaseChain_TSelf
|
A new chain with the filter applied. |
back_month
back_month() -> QuantConnect_Data_Market_BaseChain_TSelf
Selects the contracts of the second nearest expiration. Same as ContractSecurityFilterUniverse{T, TData}.BackMonth
Returns:
| Type | Description |
|---|---|
QuantConnect_Data_Market_BaseChain_TSelf
|
A new chain with the filter applied. |
back_months
back_months() -> QuantConnect_Data_Market_BaseChain_TSelf
Selects the contracts of all expirations but the nearest one. Same as ContractSecurityFilterUniverse{T, TData}.BackMonths
Returns:
| Type | Description |
|---|---|
QuantConnect_Data_Market_BaseChain_TSelf
|
A new chain with the filter applied. |
expiring_after
expiring_after(
date: Union[datetime, date],
) -> QuantConnect_Data_Market_BaseChain_TSelf
Selects the contracts expiring after the given date, excluding it. Time of day is ignored. Same as ContractSecurityFilterUniverse{T, TData}.ExpiringAfter
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
Union[datetime, date]
|
The date the expirations must be after |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Data_Market_BaseChain_TSelf
|
A new chain with the filter applied. |
expiring_before
expiring_before(
date: Union[datetime, date],
) -> QuantConnect_Data_Market_BaseChain_TSelf
Selects the contracts expiring before the given date, excluding it. Time of day is ignored. Same as ContractSecurityFilterUniverse{T, TData}.ExpiringBefore
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
Union[datetime, date]
|
The date the expirations must be before |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Data_Market_BaseChain_TSelf
|
A new chain with the filter applied. |
farthest_expiration
farthest_expiration() -> (
QuantConnect_Data_Market_BaseChain_TSelf
)
Selects the contracts of the farthest expiration. Same as ContractSecurityFilterUniverse{T, TData}.FarthestExpiration
Returns:
| Type | Description |
|---|---|
QuantConnect_Data_Market_BaseChain_TSelf
|
A new chain with the filter applied. |
front_month
front_month() -> QuantConnect_Data_Market_BaseChain_TSelf
Selects the contracts of the nearest expiration. Same as ContractSecurityFilterUniverse{T, TData}.FrontMonth
Returns:
| Type | Description |
|---|---|
QuantConnect_Data_Market_BaseChain_TSelf
|
A new chain with the filter applied. |
oi
oi(
min: int, max: int
) -> QuantConnect_Data_Market_BaseChain_TSelf
Selects the contracts with open interest in 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_Data_Market_BaseChain_TSelf
|
A new chain with the filter applied. |
open_interest
open_interest(
min: int, max: int
) -> QuantConnect_Data_Market_BaseChain_TSelf
Selects the contracts with open interest in the given range. Same as ContractSecurityFilterUniverse{T, TData}.OpenInterest
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_Data_Market_BaseChain_TSelf
|
A new chain with the filter applied. |
standards_only
standards_only() -> (
QuantConnect_Data_Market_BaseChain_TSelf
)
Selects the standard contracts in the chain. Unlike ContractSecurityFilterUniverse{T, TData}.StandardsOnly, it applies to the contracts already selected, so it can be combined with the expiry filters in any order
Returns:
| Type | Description |
|---|---|
QuantConnect_Data_Market_BaseChain_TSelf
|
A new chain with the filter applied. |
volume
volume(
min: int, max: int
) -> QuantConnect_Data_Market_BaseChain_TSelf
Selects the contracts with volume in the given range. Same as ContractSecurityFilterUniverse{T, TData}.Volume
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min
|
int
|
The minimum volume |
required |
max
|
int
|
The maximum volume |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Data_Market_BaseChain_TSelf
|
A new chain with the filter applied. |
weeklys_only
weeklys_only() -> QuantConnect_Data_Market_BaseChain_TSelf
Selects the non standard contracts in the chain. Unlike ContractSecurityFilterUniverse{T, TData}.WeeklysOnly, it applies to the contracts already selected, so it can be combined with the expiry filters in any order
Returns:
| Type | Description |
|---|---|
QuantConnect_Data_Market_BaseChain_TSelf
|
A new chain with the filter applied. |
zero_dte
zero_dte() -> QuantConnect_Data_Market_BaseChain_TSelf
Selects the contracts expiring today. Same as ContractSecurityFilterUniverse{T, TData}.ZeroDte
Returns:
| Type | Description |
|---|---|
QuantConnect_Data_Market_BaseChain_TSelf
|
A new chain with the filter applied. |
get_aux
get_aux(
symbol: Union[Symbol, str, BaseContract, Security],
) -> QuantConnect_Data_Market_BaseChain_GetAux_TAux
get_aux() -> (
DataDictionary[
QuantConnect_Data_Market_BaseChain_GetAux_TAux
]
)
Signature descriptions:
-
Gets the auxiliary data with the specified type and symbol
-
Gets all auxiliary data of the specified type as a dictionary keyed by symbol
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Optional[Union[Symbol, str, BaseContract, Security]]
|
The symbol of the auxiliary data |
None
|
Returns:
| Type | Description |
|---|---|
QuantConnect_Data_Market_BaseChain_GetAux_TAux | DataDictionary[QuantConnect_Data_Market_BaseChain_GetAux_TAux]
|
Depends on the signature used. Case 1: [The last auxiliary data with the specified type and symbol.]; Case 2: [A dictionary containing all auxiliary data of the specified type.] |
get_aux_list
get_aux_list(
symbol: Union[Symbol, str, BaseContract, Security],
) -> List[
QuantConnect_Data_Market_BaseChain_GetAuxList_TAux
]
Signature descriptions:
-
Gets a list of auxiliary data with the specified type and symbol
-
Gets all auxiliary data of the specified type as a dictionary keyed by symbol
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Optional[Union[Symbol, str, BaseContract, Security]]
|
The symbol of the auxiliary data |
None
|
Returns:
| Type | Description |
|---|---|
List[QuantConnect_Data_Market_BaseChain_GetAuxList_TAux] | Dictionary[Symbol, List[BaseData]]
|
Depends on the signature used. Case 1: [The list of auxiliary data with the specified type and symbol.]; Case 2: [A dictionary containing all auxiliary data of the specified type.] |
__contains__
__contains__(
key: Union[Symbol, str, BaseContract, Security],
) -> bool
Checks if the chain contains a contract with the specified symbol
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Union[Symbol, str, BaseContract, Security]
|
The symbol of the contract to check for |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the chain contains a contract with the specified symbol; otherwise, false. |
__iter__
__iter__() -> (
Iterator[QuantConnect_Data_Market_BaseChain_T]
)
__len__
__len__() -> int
contains_key
contains_key(
key: Union[Symbol, str, BaseContract, Security],
) -> bool
Checks if the chain contains a contract with the specified symbol
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Union[Symbol, str, BaseContract, Security]
|
The symbol of the contract to check for |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the chain contains a contract with the specified symbol; otherwise, false. |
filter
filter(
filter: Callable[
[QuantConnect_Data_Market_BaseChain_TUniverse],
QuantConnect_Data_Market_BaseChain_TUniverse,
],
) -> QuantConnect_Data_Market_BaseChain_TSelf
Applies the given universe filter to the contracts of this chain and returns the result as a new chain
This Class is protected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter
|
Callable[[QuantConnect_Data_Market_BaseChain_TUniverse], QuantConnect_Data_Market_BaseChain_TUniverse]
|
The universe filter to apply |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Data_Market_BaseChain_TSelf
|
A new chain with the filter applied. |
get_enumerator
get_enumerator() -> (
IEnumerator[QuantConnect_Data_Market_BaseChain_T]
)
Returns an enumerator that iterates through the collection.
Returns:
| Type | Description |
|---|---|
IEnumerator[QuantConnect_Data_Market_BaseChain_T]
|
An enumerator that can be used to iterate through the collection. |
where
where(
predicate: Any,
) -> QuantConnect_Data_Market_BaseChain_TSelf
Selects the contracts matching the given predicate, e.g. chain.where(lambda contract: contract.open_interest > 100). From C# use Linq's Where, which keeps this chain's type untouched
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predicate
|
Any
|
Function determining which contracts are kept |
required |
Returns:
| Type | Description |
|---|---|
QuantConnect_Data_Market_BaseChain_TSelf
|
A new chain with the filter applied. |