Lean
$LEAN_TAG$
|
Provides indexing of option contracts More...
Public Member Functions | |
OptionPositionCollection (ImmutableDictionary< Symbol, OptionPosition > positions, ImmutableDictionary< OptionRight, ImmutableHashSet< Symbol >> rights, ImmutableDictionary< PositionSide, ImmutableHashSet< Symbol >> sides, ImmutableSortedDictionary< decimal, ImmutableHashSet< Symbol >> strikes, ImmutableSortedDictionary< DateTime, ImmutableHashSet< Symbol >> expirations) | |
Initializes a new instance of the OptionPositionCollection class More... | |
bool | HasPosition (Symbol symbol) |
Determines if a position is held in the specified symbol More... | |
bool | TryGetPosition (Symbol symbol, out OptionPosition position) |
Retrieves the OptionPosition for the specified symbol if one exists in this collection. More... | |
OptionPositionCollection | Add (OptionPosition position) |
Creates a new collection that is the result of adding the specified position to this collection. More... | |
OptionPositionCollection | Remove (OptionPosition position) |
Creates a new collection that is the result of removing the specified position More... | |
OptionPositionCollection | AddRange (params OptionPosition[] positions) |
Creates a new collection that is the result of adding the specified positions to this collection. More... | |
OptionPositionCollection | AddRange (IEnumerable< OptionPosition > positions) |
Creates a new collection that is the result of adding the specified positions to this collection. More... | |
OptionPositionCollection | RemoveRange (IEnumerable< OptionPosition > positions) |
Creates a new collection that is the result of removing the specified positions More... | |
OptionPositionCollection | Slice (OptionRight right, bool includeUnderlying=true) |
Slices this collection, returning a new collection containing only positions with the specified right More... | |
OptionPositionCollection | Slice (PositionSide side, bool includeUnderlying=true) |
Slices this collection, returning a new collection containing only positions with the specified side More... | |
OptionPositionCollection | Slice (BinaryComparison comparison, decimal strike, bool includeUnderlying=true) |
Slices this collection, returning a new collection containing only positions matching the specified comparison and strike More... | |
OptionPositionCollection | Slice (BinaryComparison comparison, DateTime expiration, bool includeUnderlying=true) |
Slices this collection, returning a new collection containing only positions matching the specified comparison and expiration More... | |
IEnumerable< OptionPosition > | ForSymbols (IEnumerable< Symbol > symbols) |
Returns the set of OptionPosition with the specified symbols More... | |
IEnumerable< OptionPosition > | ForRight (OptionRight right) |
Returns the set of OptionPosition with the specified right More... | |
IEnumerable< OptionPosition > | ForSide (PositionSide side) |
Returns the set of OptionPosition with the specified side More... | |
IEnumerable< OptionPosition > | ForStrike (decimal strike) |
Returns the set of OptionPosition with the specified strike More... | |
IEnumerable< OptionPosition > | ForExpiration (DateTime expiration) |
Returns the set of OptionPosition with the specified expiration More... | |
override string | ToString () |
Returns a string that represents the current object. More... | |
IEnumerator< OptionPosition > | GetEnumerator () |
Returns an enumerator that iterates through the collection. More... | |
Static Public Member Functions | |
static OptionPositionCollection | FromPositions (IEnumerable< OptionPosition > positions) |
Creates a new OptionPositionCollection from the specified enumerable of positions More... | |
static OptionPositionCollection | FromPositions (IEnumerable< IPosition > positions, decimal contractMultiplier) |
Creates a new OptionPositionCollection from the specified enumerable of positions More... | |
static OptionPositionCollection | Create (Symbol underlying, decimal contractMultiplier, IEnumerable< SecurityHolding > holdings) |
Creates a new OptionPositionCollection from the specified holdings , filtering based on the underlying More... | |
static OptionPositionCollection | operator+ (OptionPositionCollection positions, OptionPosition position) |
OptionPositionCollection + Operator More... | |
static OptionPositionCollection | operator- (OptionPositionCollection positions, OptionPosition position) |
OptionPositionCollection - Operator More... | |
Public Attributes | |
Symbol | Underlying => UnderlyingPosition.Symbol ?? Symbol.Empty |
Gets the underlying security's symbol More... | |
int | Count => _positions.Count |
Gets the total count of unique positions, including the underlying More... | |
bool | IsEmpty => _positions.IsEmpty |
Gets whether or not there's any positions in this collection. More... | |
int | UnderlyingQuantity => UnderlyingPosition.Quantity |
Gets the quantity of underlying shares held TODO : Change to UnderlyingLots More... | |
int | UniquePuts => _rights[OptionRight.Put].Count |
Gets the number of unique put contracts held (long or short) More... | |
int | UniqueExpirations => _expirations.Count |
Gets the unique number of expirations More... | |
int | UniqueCalls => _rights[OptionRight.Call].Count |
Gets the number of unique call contracts held (long or short) More... | |
bool | HasUnderlying => UnderlyingQuantity != 0 |
Determines if this collection contains a position in the underlying More... | |
IEnumerable< decimal > | Strikes => _strikes.Keys |
Gets all unique strike prices in the collection, in ascending order. More... | |
IEnumerable< DateTime > | Expirations => _expirations.Keys |
Gets all unique expiration dates in the collection, in chronological order. More... | |
Properties | |
static OptionPositionCollection | Empty [get] |
Gets an empty instance of OptionPositionCollection More... | |
OptionPosition | UnderlyingPosition [get] |
Gets the Underlying position More... | |
Provides indexing of option contracts
Definition at line 29 of file OptionPositionCollection.cs.
QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.OptionPositionCollection | ( | ImmutableDictionary< Symbol, OptionPosition > | positions, |
ImmutableDictionary< OptionRight, ImmutableHashSet< Symbol >> | rights, | ||
ImmutableDictionary< PositionSide, ImmutableHashSet< Symbol >> | sides, | ||
ImmutableSortedDictionary< decimal, ImmutableHashSet< Symbol >> | strikes, | ||
ImmutableSortedDictionary< DateTime, ImmutableHashSet< Symbol >> | expirations | ||
) |
Initializes a new instance of the OptionPositionCollection class
positions | All positions |
rights | Index of position symbols by option right |
sides | Index of position symbols by position side (short/long/none) |
strikes | Index of position symbols by strike price |
expirations | Index of position symbols by expiration |
Definition at line 112 of file OptionPositionCollection.cs.
bool QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.HasPosition | ( | Symbol | symbol | ) |
Determines if a position is held in the specified symbol
Definition at line 187 of file OptionPositionCollection.cs.
bool QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.TryGetPosition | ( | Symbol | symbol, |
out OptionPosition | position | ||
) |
Retrieves the OptionPosition for the specified symbol if one exists in this collection.
Definition at line 197 of file OptionPositionCollection.cs.
|
static |
Creates a new OptionPositionCollection from the specified enumerable of positions
Definition at line 205 of file OptionPositionCollection.cs.
|
static |
Creates a new OptionPositionCollection from the specified enumerable of positions
Definition at line 213 of file OptionPositionCollection.cs.
|
static |
Creates a new OptionPositionCollection from the specified holdings , filtering based on the underlying
Definition at line 230 of file OptionPositionCollection.cs.
OptionPositionCollection QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.Add | ( | OptionPosition | position | ) |
Creates a new collection that is the result of adding the specified position to this collection.
Definition at line 262 of file OptionPositionCollection.cs.
OptionPositionCollection QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.Remove | ( | OptionPosition | position | ) |
Creates a new collection that is the result of removing the specified position
Definition at line 333 of file OptionPositionCollection.cs.
OptionPositionCollection QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.AddRange | ( | params OptionPosition[] | positions | ) |
Creates a new collection that is the result of adding the specified positions to this collection.
Definition at line 341 of file OptionPositionCollection.cs.
OptionPositionCollection QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.AddRange | ( | IEnumerable< OptionPosition > | positions | ) |
Creates a new collection that is the result of adding the specified positions to this collection.
Definition at line 349 of file OptionPositionCollection.cs.
OptionPositionCollection QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.RemoveRange | ( | IEnumerable< OptionPosition > | positions | ) |
Creates a new collection that is the result of removing the specified positions
Definition at line 357 of file OptionPositionCollection.cs.
OptionPositionCollection QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.Slice | ( | OptionRight | right, |
bool | includeUnderlying = true |
||
) |
Slices this collection, returning a new collection containing only positions with the specified right
Definition at line 366 of file OptionPositionCollection.cs.
OptionPositionCollection QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.Slice | ( | PositionSide | side, |
bool | includeUnderlying = true |
||
) |
Slices this collection, returning a new collection containing only positions with the specified side
Definition at line 395 of file OptionPositionCollection.cs.
OptionPositionCollection QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.Slice | ( | BinaryComparison | comparison, |
decimal | strike, | ||
bool | includeUnderlying = true |
||
) |
Slices this collection, returning a new collection containing only positions matching the specified comparison and strike
Definition at line 425 of file OptionPositionCollection.cs.
OptionPositionCollection QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.Slice | ( | BinaryComparison | comparison, |
DateTime | expiration, | ||
bool | includeUnderlying = true |
||
) |
Slices this collection, returning a new collection containing only positions matching the specified comparison and expiration
Definition at line 462 of file OptionPositionCollection.cs.
IEnumerable<OptionPosition> QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.ForSymbols | ( | IEnumerable< Symbol > | symbols | ) |
Returns the set of OptionPosition with the specified symbols
Definition at line 498 of file OptionPositionCollection.cs.
IEnumerable<OptionPosition> QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.ForRight | ( | OptionRight | right | ) |
Returns the set of OptionPosition with the specified right
Definition at line 513 of file OptionPositionCollection.cs.
IEnumerable<OptionPosition> QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.ForSide | ( | PositionSide | side | ) |
Returns the set of OptionPosition with the specified side
Definition at line 524 of file OptionPositionCollection.cs.
IEnumerable<OptionPosition> QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.ForStrike | ( | decimal | strike | ) |
Returns the set of OptionPosition with the specified strike
Definition at line 535 of file OptionPositionCollection.cs.
IEnumerable<OptionPosition> QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.ForExpiration | ( | DateTime | expiration | ) |
Returns the set of OptionPosition with the specified expiration
Definition at line 546 of file OptionPositionCollection.cs.
override string QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.ToString | ( | ) |
Returns a string that represents the current object.
Definition at line 556 of file OptionPositionCollection.cs.
IEnumerator<OptionPosition> QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.GetEnumerator | ( | ) |
Returns an enumerator that iterates through the collection.
Definition at line 570 of file OptionPositionCollection.cs.
|
static |
OptionPositionCollection + Operator
positions | Collection to add to |
position | OptionPosition to add |
Definition at line 636 of file OptionPositionCollection.cs.
|
static |
OptionPositionCollection - Operator
positions | Collection to remove from |
position | OptionPosition to remove |
Definition at line 647 of file OptionPositionCollection.cs.
Symbol QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.Underlying => UnderlyingPosition.Symbol ?? Symbol.Empty |
Gets the underlying security's symbol
Definition at line 51 of file OptionPositionCollection.cs.
int QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.Count => _positions.Count |
Gets the total count of unique positions, including the underlying
Definition at line 56 of file OptionPositionCollection.cs.
bool QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.IsEmpty => _positions.IsEmpty |
Gets whether or not there's any positions in this collection.
Definition at line 61 of file OptionPositionCollection.cs.
int QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.UnderlyingQuantity => UnderlyingPosition.Quantity |
Gets the quantity of underlying shares held TODO : Change to UnderlyingLots
Definition at line 67 of file OptionPositionCollection.cs.
int QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.UniquePuts => _rights[OptionRight.Put].Count |
Gets the number of unique put contracts held (long or short)
Definition at line 72 of file OptionPositionCollection.cs.
int QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.UniqueExpirations => _expirations.Count |
Gets the unique number of expirations
Definition at line 77 of file OptionPositionCollection.cs.
int QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.UniqueCalls => _rights[OptionRight.Call].Count |
Gets the number of unique call contracts held (long or short)
Definition at line 82 of file OptionPositionCollection.cs.
bool QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.HasUnderlying => UnderlyingQuantity != 0 |
Determines if this collection contains a position in the underlying
Definition at line 87 of file OptionPositionCollection.cs.
IEnumerable<decimal> QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.Strikes => _strikes.Keys |
Gets all unique strike prices in the collection, in ascending order.
Definition at line 97 of file OptionPositionCollection.cs.
IEnumerable<DateTime> QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.Expirations => _expirations.Keys |
Gets all unique expiration dates in the collection, in chronological order.
Definition at line 102 of file OptionPositionCollection.cs.
|
staticget |
Gets an empty instance of OptionPositionCollection
Definition at line 34 of file OptionPositionCollection.cs.
|
get |
Gets the Underlying position
Definition at line 92 of file OptionPositionCollection.cs.