Skip to content

OptionStrategy

QuantConnect.Securities.Option.OptionStrategy

Bases: Object

Option strategy specification class. Describes option strategy and its parameters for trading.

name

name: str

Option strategy name

canonical_option

canonical_option: Symbol

The canonical Option symbol of the strategy

underlying

underlying: Symbol

Underlying symbol of the strategy

option_legs

option_legs: List[OptionLegData]

Option strategy legs

underlying_legs

underlying_legs: List[UnderlyingLegData]

Option strategy underlying legs (usually 0 or 1 legs)

UnderlyingLegData

Bases: QuantConnect_Securities_Option_OptionStrategy_LegData

This class is a POCO containing basic data for the underlying leg of the strategy

create

create(
    quantity: int,
    symbol: Union[Symbol, str, BaseContract],
    order_price: Optional[float] = None,
) -> UnderlyingLegData
create(
    quantity: int, order_price: Optional[float] = None
) -> UnderlyingLegData

Creates a new instance of UnderlyingLegData for the specified quantity of underlying shares.

invoke

invoke(
    underlying_handler: Callable[[UnderlyingLegData], Any],
    option_handler: Callable[[OptionLegData], Any],
) -> None

Invokes the underlying_handler

LegData

Bases: Leg

Defines common properties between OptionLegData and UnderlyingLegData

symbol

symbol: Symbol

The legs symbol

quantity

quantity: int

Quantity multiplier used to specify proper scale (and direction) of the leg within the strategy

order_price

order_price: Optional[float]

Order limit price of the leg in case limit order is sent to the market on strategy execution

invoke

invoke(
    underlying_handler: Callable[[UnderlyingLegData], Any],
    option_handler: Callable[[OptionLegData], Any],
) -> None

Invokes the correct handler based on the runtime type.

create

create(
    symbol: Union[Symbol, str, BaseContract],
    quantity: int,
    limit_price: Optional[float] = None,
) -> Leg

Creates a new instance

Parameters:

Name Type Description Default
symbol Union[Symbol, str, BaseContract]

The symbol

required
quantity int

The quantity

required
limit_price Optional[float]

Associated limit price if any

None

OptionLegData

Bases: QuantConnect_Securities_Option_OptionStrategy_LegData

This class is a POCO containing basic data for the option legs of the strategy

right

right: OptionRight

Option right (type) of the option leg

expiration

expiration: datetime

Expiration date of the leg

strike

strike: float

Strike price of the leg

create

create(
    quantity: int,
    symbol: Union[Symbol, str, BaseContract],
    order_price: Optional[float] = None,
) -> OptionLegData

Creates a new instance of OptionLegData from the specified parameters

invoke

invoke(
    underlying_handler: Callable[[UnderlyingLegData], Any],
    option_handler: Callable[[OptionLegData], Any],
) -> None

Invokes the option_handler