Lean
$LEAN_TAG$
|
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...
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... | |
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.
QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.OptionPosition | ( | Symbol | symbol, |
int | quantity | ||
) |
Initializes a new instance of the OptionPosition structure
symbol | The option contract symbol |
quantity | The number of contracts held |
Definition at line 119 of file OptionPosition.cs.
|
static |
OptionPosition QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.Negate | ( | ) |
Creates a new OptionPosition instance with negative Quantity
Definition at line 128 of file OptionPosition.cs.
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.
bool QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.Equals | ( | OptionPosition | other | ) |
Indicates whether the current object is equal to another object of the same type.
other | An object to compare with this object. |
Definition at line 145 of file OptionPosition.cs.
override bool QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.Equals | ( | object | obj | ) |
Indicates whether this instance and a specified object are equal.
obj | The object to compare with the current instance. |
Definition at line 153 of file OptionPosition.cs.
override int QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.GetHashCode | ( | ) |
Returns the hash code for this instance.
Definition at line 170 of file OptionPosition.cs.
override string QuantConnect.Securities.Option.StrategyMatcher.OptionPosition.ToString | ( | ) |
Returns the fully qualified type name of this instance.
Definition at line 180 of file OptionPosition.cs.
|
static |
OptionPosition * Operator, will multiple quantity by given factor
left | OptionPosition to operate on |
factor | Factor to multiply by |
Definition at line 197 of file OptionPosition.cs.
|
static |
OptionPosition * Operator, will multiple quantity by given factor
right | OptionPosition to operate on |
factor | Factor to multiply by |
Definition at line 208 of file OptionPosition.cs.
|
static |
OptionPosition + Operator, will add quantities together if they are for the same symbol.
Definition at line 217 of file OptionPosition.cs.
|
static |
OptionPosition - Operator, will subtract left - right quantities if they are for the same symbol.
Definition at line 241 of file OptionPosition.cs.
|
static |
Option Position == Operator
Definition at line 267 of file OptionPosition.cs.
|
static |
Option Position != Operator
Definition at line 276 of file OptionPosition.cs.
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.
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.
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.
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.
|
get |
Number of contracts held, can be positive or negative
Definition at line 48 of file OptionPosition.cs.
|
get |
Option contract symbol
Definition at line 53 of file OptionPosition.cs.
|
get |
Option contract expiration date
Definition at line 65 of file OptionPosition.cs.
|
get |
Option contract strike price
Definition at line 81 of file OptionPosition.cs.
|
get |
Option contract right (put/call)
Definition at line 97 of file OptionPosition.cs.