Lean  $LEAN_TAG$
QuantConnect.Securities.Option.StrategyMatcher.OptionPosition Struct Reference

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) More...

Inheritance diagram for QuantConnect.Securities.Option.StrategyMatcher.OptionPosition:
[legend]

Public Member Functions

 OptionPosition (Symbol symbol, int quantity)
 Initializes a new instance of the OptionPosition structure More...
 
OptionPosition Negate ()
 Creates a new OptionPosition instance with negative Quantity More...
 
OptionPosition WithQuantity (int quantity)
 Creates a new OptionPosition with this position's Symbol and the provided quantity More...
 
bool Equals (OptionPosition other)
 Indicates whether the current object is equal to another object of the same type. More...
 
override bool Equals (object obj)
 Indicates whether this instance and a specified object are equal. More...
 
override int GetHashCode ()
 Returns the hash code for this instance. More...
 
override string ToString ()
 Returns the fully qualified type name of this instance. More...
 

Static Public Member Functions

static OptionPosition Empty (Symbol symbol)
 Gets a new OptionPosition with zero Quantity More...
 
static OptionPosition operator* (OptionPosition left, int factor)
 OptionPosition * Operator, will multiple quantity by given factor More...
 
static OptionPosition operator* (int factor, OptionPosition right)
 OptionPosition * Operator, will multiple quantity by given factor More...
 
static OptionPosition operator+ (OptionPosition left, OptionPosition right)
 OptionPosition + Operator, will add quantities together if they are for the same symbol. More...
 
static OptionPosition operator- (OptionPosition left, OptionPosition right)
 OptionPosition - Operator, will subtract left - right quantities if they are for the same symbol. More...
 
static bool operator== (OptionPosition left, OptionPosition right)
 Option Position == Operator More...
 
static bool operator!= (OptionPosition left, OptionPosition right)
 Option Position != Operator More...
 

Public Attributes

bool HasQuantity => Quantity != 0
 Determines whether or not this position has any quantity More...
 
bool IsUnderlying => !Symbol.HasUnderlying
 Determines whether or not this position is for the underlying symbol More...
 
Symbol Underlying => IsUnderlying ? Symbol : Symbol.Underlying
 Gets the underlying symbol. If this position represents the underlying, then this property is the same as the Symbol property More...
 
PositionSide Side => (PositionSide) Math.Sign(Quantity)
 Gets whether this position is short/long/none More...
 

Properties

int Quantity [get]
 Number of contracts held, can be positive or negative More...
 
Symbol Symbol [get]
 Option contract symbol More...
 
DateTime Expiration [get]
 Option contract expiration date More...
 
decimal Strike [get]
 Option contract strike price More...
 
OptionRight Right [get]
 Option contract right (put/call) More...
 

Detailed Description

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)

Definition at line 27 of file OptionPosition.cs.

Constructor & Destructor Documentation

◆ OptionPosition()

QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.OptionPosition ( Symbol  symbol,
int  quantity 
)

Initializes a new instance of the OptionPosition structure

Parameters
symbolThe option contract symbol
quantityThe number of contracts held

Definition at line 119 of file OptionPosition.cs.

Here is the caller graph for this function:

Member Function Documentation

◆ Empty()

static OptionPosition QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.Empty ( Symbol  symbol)
static

Gets a new OptionPosition with zero Quantity

Here is the caller graph for this function:

◆ Negate()

OptionPosition QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.Negate ( )

Creates a new OptionPosition instance with negative Quantity

Definition at line 128 of file OptionPosition.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WithQuantity()

OptionPosition QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.WithQuantity ( int  quantity)

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

Definition at line 137 of file OptionPosition.cs.

Here is the call graph for this function:

◆ Equals() [1/2]

bool QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.Equals ( OptionPosition  other)

Indicates whether the current object is equal to another object of the same type.

Parameters
otherAn object to compare with this object.
Returns
true if the current object is equal to the other parameter; otherwise, false.

Definition at line 145 of file OptionPosition.cs.

Here is the caller graph for this function:

◆ Equals() [2/2]

override bool QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.Equals ( object  obj)

Indicates whether this instance and a specified object are equal.

Parameters
objThe object to compare with the current instance.
Returns
true if obj and this instance are the same type and represent the same value; otherwise, false.

Definition at line 153 of file OptionPosition.cs.

Here is the call graph for this function:

◆ GetHashCode()

override int QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.GetHashCode ( )

Returns the hash code for this instance.

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

Definition at line 170 of file OptionPosition.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToString()

override string QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.ToString ( )

Returns the fully qualified type name of this instance.

Returns
The fully qualified type name.

Definition at line 180 of file OptionPosition.cs.

◆ operator*() [1/2]

static OptionPosition QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.operator* ( OptionPosition  left,
int  factor 
)
static

OptionPosition * Operator, will multiple quantity by given factor

Parameters
leftOptionPosition to operate on
factorFactor to multiply by
Returns
Resulting OptionPosition

Definition at line 197 of file OptionPosition.cs.

Here is the call graph for this function:

◆ operator*() [2/2]

static OptionPosition QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.operator* ( int  factor,
OptionPosition  right 
)
static

OptionPosition * Operator, will multiple quantity by given factor

Parameters
rightOptionPosition to operate on
factorFactor to multiply by
Returns
Resulting OptionPosition

Definition at line 208 of file OptionPosition.cs.

Here is the call graph for this function:

◆ operator+()

static OptionPosition QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.operator+ ( OptionPosition  left,
OptionPosition  right 
)
static

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

Returns
Resulting OptionPosition

Definition at line 217 of file OptionPosition.cs.

Here is the call graph for this function:

◆ operator-()

static OptionPosition QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.operator- ( OptionPosition  left,
OptionPosition  right 
)
static

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

Returns
Resulting OptionPosition

Definition at line 241 of file OptionPosition.cs.

Here is the call graph for this function:

◆ operator==()

static bool QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.operator== ( OptionPosition  left,
OptionPosition  right 
)
static

Option Position == Operator

Returns
True if they are the same

Definition at line 267 of file OptionPosition.cs.

Here is the call graph for this function:

◆ operator!=()

static bool QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.operator!= ( OptionPosition  left,
OptionPosition  right 
)
static

Option Position != Operator

Returns
True if they are not the same

Definition at line 276 of file OptionPosition.cs.

Here is the call graph for this function:

Member Data Documentation

◆ HasQuantity

bool QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.HasQuantity => Quantity != 0

Determines whether or not this position has any quantity

Definition at line 38 of file OptionPosition.cs.

◆ IsUnderlying

bool QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.IsUnderlying => !Symbol.HasUnderlying

Determines whether or not this position is for the underlying symbol

Definition at line 43 of file OptionPosition.cs.

◆ Underlying

Symbol QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.Underlying => IsUnderlying ? Symbol : Symbol.Underlying

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

Definition at line 59 of file OptionPosition.cs.

◆ Side

PositionSide QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.Side => (PositionSide) Math.Sign(Quantity)

Gets whether this position is short/long/none

Definition at line 112 of file OptionPosition.cs.

Property Documentation

◆ Quantity

int QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.Quantity
get

Number of contracts held, can be positive or negative

Definition at line 48 of file OptionPosition.cs.

◆ Symbol

Symbol QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.Symbol
get

Option contract symbol

Definition at line 53 of file OptionPosition.cs.

◆ Expiration

DateTime QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.Expiration
get

Option contract expiration date

Definition at line 65 of file OptionPosition.cs.

◆ Strike

decimal QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.Strike
get

Option contract strike price

Definition at line 81 of file OptionPosition.cs.

◆ Right

OptionRight QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.Right
get

Option contract right (put/call)

Definition at line 97 of file OptionPosition.cs.


The documentation for this struct was generated from the following file: