Skip to content

OptionPosition

QuantConnect.Securities.Option.StrategyMatcher.OptionPosition

OptionPosition(
    symbol: Union[Symbol, str, BaseContract], quantity: int
)

Bases: IEquatable[QuantConnect_Securities_Option_StrategyMatcher_OptionPosition]

Defines a lightweight structure representing a position in an option contract or underlying. This type is heavily utilized by the options strategy matcher and is the parameter type of option strategy definition predicates. Underlying quantities should be represented in lot sizes, which is equal to the quantity of shares divided by the contract's multiplier and then rounded down towards zero (truncate)

Initializes a new instance of the OptionPosition structure

Parameters:

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

The option contract symbol

required
quantity int

The number of contracts held

required

has_quantity

has_quantity: bool

Determines whether or not this position has any quantity

is_underlying

is_underlying: bool

Determines whether or not this position is for the underlying symbol

quantity

quantity: int

Number of contracts held, can be positive or negative

symbol

symbol: Symbol

Option contract symbol

underlying

underlying: Symbol

Gets the underlying symbol. If this position represents the underlying, then this property is the same as the symbol property

expiration

expiration: datetime

Option contract expiration date

strike

strike: float

Option contract strike price

right

right: OptionRight

Option contract right (put/call)

side

Gets whether this position is short/long/none

__add__

__add__(right: OptionPosition) -> OptionPosition

OptionPosition + Operator, will add quantities together if they are for the same symbol.

Returns:

Type Description
OptionPosition

Resulting OptionPosition.

__eq__

__eq__(right: OptionPosition) -> bool

Option Position == Operator

Returns:

Type Description
bool

True if they are the same.

__iadd__

__iadd__(right: OptionPosition) -> OptionPosition

OptionPosition + Operator, will add quantities together if they are for the same symbol.

Returns:

Type Description
OptionPosition

Resulting OptionPosition.

__isub__

__isub__(right: OptionPosition) -> OptionPosition

OptionPosition - Operator, will subtract left - right quantities if they are for the same symbol.

Returns:

Type Description
OptionPosition

Resulting OptionPosition.

__ne__

__ne__(right: OptionPosition) -> bool

Option Position != Operator

Returns:

Type Description
bool

True if they are not the same.

__sub__

__sub__(right: OptionPosition) -> OptionPosition

OptionPosition - Operator, will subtract left - right quantities if they are for the same symbol.

Returns:

Type Description
OptionPosition

Resulting OptionPosition.

empty

empty(
    symbol: Union[Symbol, str, BaseContract],
) -> OptionPosition

Gets a new OptionPosition with zero quantity

get_hash_code

get_hash_code() -> int

Returns the hash code for this instance.

Returns:

Type Description
int

A 32-bit signed integer that is the hash code for this instance.

negate

negate() -> OptionPosition

Creates a new OptionPosition instance with negative quantity

to_string

to_string() -> str

Returns the fully qualified type name of this instance.

Returns:

Type Description
str

The fully qualified type name.

with_quantity

with_quantity(quantity: int) -> OptionPosition

Creates a new OptionPosition with this position's symbol and the provided quantity