Lean  $LEAN_TAG$
QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection Class Reference

Provides indexing of option contracts More...

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

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< OptionPositionForSymbols (IEnumerable< Symbol > symbols)
 Returns the set of OptionPosition with the specified symbols More...
 
IEnumerable< OptionPositionForRight (OptionRight right)
 Returns the set of OptionPosition with the specified right More...
 
IEnumerable< OptionPositionForSide (PositionSide side)
 Returns the set of OptionPosition with the specified side More...
 
IEnumerable< OptionPositionForStrike (decimal strike)
 Returns the set of OptionPosition with the specified strike More...
 
IEnumerable< OptionPositionForExpiration (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< OptionPositionGetEnumerator ()
 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...
 

Detailed Description

Provides indexing of option contracts

Definition at line 29 of file OptionPositionCollection.cs.

Constructor & Destructor Documentation

◆ OptionPositionCollection()

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

Parameters
positionsAll positions
rightsIndex of position symbols by option right
sidesIndex of position symbols by position side (short/long/none)
strikesIndex of position symbols by strike price
expirationsIndex of position symbols by expiration

Definition at line 112 of file OptionPositionCollection.cs.

Member Function Documentation

◆ HasPosition()

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.

Here is the call graph for this function:

◆ TryGetPosition()

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.

Here is the caller graph for this function:

◆ FromPositions() [1/2]

static OptionPositionCollection QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.FromPositions ( IEnumerable< OptionPosition positions)
static

Creates a new OptionPositionCollection from the specified enumerable of positions

Definition at line 205 of file OptionPositionCollection.cs.

Here is the call graph for this function:

◆ FromPositions() [2/2]

static OptionPositionCollection QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.FromPositions ( IEnumerable< IPosition positions,
decimal  contractMultiplier 
)
static

Creates a new OptionPositionCollection from the specified enumerable of positions

Definition at line 213 of file OptionPositionCollection.cs.

Here is the call graph for this function:

◆ Create()

static OptionPositionCollection QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.Create ( Symbol  underlying,
decimal  contractMultiplier,
IEnumerable< SecurityHolding holdings 
)
static

Creates a new OptionPositionCollection from the specified holdings , filtering based on the underlying

Definition at line 230 of file OptionPositionCollection.cs.

Here is the call graph for this function:

◆ Add()

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.

Here is the caller graph for this function:

◆ Remove()

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.

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

◆ AddRange() [1/2]

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.

Here is the caller graph for this function:

◆ AddRange() [2/2]

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.

◆ RemoveRange()

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.

Here is the caller graph for this function:

◆ Slice() [1/4]

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.

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

◆ Slice() [2/4]

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.

◆ Slice() [3/4]

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.

Here is the call graph for this function:

◆ Slice() [4/4]

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.

Here is the call graph for this function:

◆ ForSymbols()

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.

◆ ForRight()

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.

◆ ForSide()

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.

◆ ForStrike()

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.

◆ ForExpiration()

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.

◆ ToString()

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

Returns a string that represents the current object.

Returns
A string that represents the current object.

Definition at line 556 of file OptionPositionCollection.cs.

◆ GetEnumerator()

IEnumerator<OptionPosition> QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.GetEnumerator ( )

Returns an enumerator that iterates through the collection.

Returns
An enumerator that can be used to iterate through the collection.

Definition at line 570 of file OptionPositionCollection.cs.

◆ operator+()

static OptionPositionCollection QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.operator+ ( OptionPositionCollection  positions,
OptionPosition  position 
)
static

OptionPositionCollection + Operator

Parameters
positionsCollection to add to
positionOptionPosition to add
Returns
OptionPositionCollection with the new position added

Definition at line 636 of file OptionPositionCollection.cs.

Here is the call graph for this function:

◆ operator-()

static OptionPositionCollection QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.operator- ( OptionPositionCollection  positions,
OptionPosition  position 
)
static

OptionPositionCollection - Operator

Parameters
positionsCollection to remove from
positionOptionPosition to remove
Returns
OptionPositionCollection with the position removed

Definition at line 647 of file OptionPositionCollection.cs.

Here is the call graph for this function:

Member Data Documentation

◆ Underlying

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.

◆ Count

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.

◆ IsEmpty

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.

◆ UnderlyingQuantity

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.

◆ UniquePuts

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.

◆ UniqueExpirations

int QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.UniqueExpirations => _expirations.Count

Gets the unique number of expirations

Definition at line 77 of file OptionPositionCollection.cs.

◆ UniqueCalls

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.

◆ HasUnderlying

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.

◆ Strikes

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.

◆ Expirations

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.

Property Documentation

◆ Empty

OptionPositionCollection QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.Empty
staticget
Initial value:
ImmutableDictionary<Symbol, OptionPosition>.Empty,
ImmutableDictionary<OptionRight, ImmutableHashSet<Symbol>>.Empty,
ImmutableDictionary<PositionSide, ImmutableHashSet<Symbol>>.Empty,
ImmutableSortedDictionary<decimal, ImmutableHashSet<Symbol>>.Empty,
ImmutableSortedDictionary<DateTime, ImmutableHashSet<Symbol>>.Empty
)

Gets an empty instance of OptionPositionCollection

Definition at line 34 of file OptionPositionCollection.cs.

◆ UnderlyingPosition

OptionPosition QuantConnect.Securities.Option.StrategyMatcher.OptionPositionCollection.UnderlyingPosition
get

Gets the Underlying position

Definition at line 92 of file OptionPositionCollection.cs.


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