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

Provides a definitional object for an OptionStrategy. This definition is used to 'match' option positions via OptionPositionCollection. The OptionStrategyMatcher utilizes a full collection of these definitional objects in order to match an algorithm's option position holdings to the set of strategies in an effort to reduce the total margin required for holding the positions. More...

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

Classes

class  Builder
 Builder class supporting fluent syntax in constructing OptionStrategyDefinition. More...
 

Public Member Functions

 OptionStrategyDefinition (string name, int underlyingLots, IEnumerable< OptionStrategyLegDefinition > legs)
 Initializes a new instance of the OptionStrategyDefinition class More...
 
OptionStrategy CreateStrategy (IReadOnlyList< OptionStrategyLegDefinitionMatch > legs)
 Creates the OptionStrategy instance using this definition and the provided leg matches More...
 
bool TryMatchOnce (OptionStrategyMatcherOptions options, OptionPositionCollection positions, out OptionStrategyDefinitionMatch match)
 Attempts to match the positions to this definition exactly once, by evaluating the enumerable and taking the first entry matched. If not match is found, then false is returned and match will be null. More...
 
IEnumerable< OptionStrategyDefinitionMatchMatch (OptionPositionCollection positions)
 Determines all possible matches for this definition using the provided positions . This includes OVERLAPPING matches. It's up to the actual matcher to make decisions based on which matches to accept. This allows the matcher to prioritize matching certain positions over others. More...
 
IEnumerable< OptionStrategyDefinitionMatchMatch (OptionStrategyMatcherOptions options, OptionPositionCollection positions)
 Determines all possible matches for this definition using the provided positions . This includes OVERLAPPING matches. It's up to the actual matcher to make decisions based on which matches to accept. This allows the matcher to prioritize matching certain positions over others. More...
 
override string ToString ()
 Returns a string that represents the current object. More...
 
IEnumerator< OptionStrategyLegDefinitionGetEnumerator ()
 Returns an enumerator that iterates through the collection. More...
 

Static Public Member Functions

static OptionStrategyDefinition Create (string name, int underlyingLots, params OptionStrategyLegDefinition[] legs)
 Factory function for creating definitions More...
 
static OptionStrategyDefinition Create (string name, params OptionStrategyLegDefinition[] legs)
 Factory function for creating definitions More...
 
static OptionStrategyDefinition Create (string name, params Func< Builder, Builder >[] predicates)
 Factory function for creating definitions More...
 
static OptionStrategyLegDefinition CallLeg (int quantity, params Expression< Func< IReadOnlyList< OptionPosition >, OptionPosition, bool >>[] predicates)
 Factory function for creating a call leg definition More...
 
static OptionStrategyLegDefinition PutLeg (int quantity, params Expression< Func< IReadOnlyList< OptionPosition >, OptionPosition, bool >>[] predicates)
 Factory function for creating a put leg definition More...
 

Public Attributes

int LegCount => Legs.Count + (UnderlyingLots == 0 ? 0 : 1)
 Gets the total number of legs, INCLUDING the underlying leg if applicable. This is used to perform a coarse filter as the minimum number of unique positions in the positions collection. More...
 

Properties

string Name [get]
 Gets the definition's name More...
 
int UnderlyingLots [get]
 Gets the number of underlying lots required to match this definition. A lot size is equal to the contract's multiplier and is usually equal to 100. More...
 
IReadOnlyList< OptionStrategyLegDefinitionLegs [get]
 Gets the option leg definitions. This list does NOT contain a definition for the required underlying lots, due to its simplicity. Instead the required underlying lots are defined via the UnderlyingLots property of the definition. More...
 

Detailed Description

Provides a definitional object for an OptionStrategy. This definition is used to 'match' option positions via OptionPositionCollection. The OptionStrategyMatcher utilizes a full collection of these definitional objects in order to match an algorithm's option position holdings to the set of strategies in an effort to reduce the total margin required for holding the positions.

Definition at line 31 of file OptionStrategyDefinition.cs.

Constructor & Destructor Documentation

◆ OptionStrategyDefinition()

QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.OptionStrategyDefinition ( string  name,
int  underlyingLots,
IEnumerable< OptionStrategyLegDefinition legs 
)

Initializes a new instance of the OptionStrategyDefinition class

Parameters
nameThe definition's name
underlyingLotsThe required number of underlying lots
legsDefinitions for each option leg

Definition at line 64 of file OptionStrategyDefinition.cs.

Here is the caller graph for this function:

Member Function Documentation

◆ CreateStrategy()

OptionStrategy QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.CreateStrategy ( IReadOnlyList< OptionStrategyLegDefinitionMatch legs)

Creates the OptionStrategy instance using this definition and the provided leg matches

Definition at line 74 of file OptionStrategyDefinition.cs.

◆ TryMatchOnce()

bool QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.TryMatchOnce ( OptionStrategyMatcherOptions  options,
OptionPositionCollection  positions,
out OptionStrategyDefinitionMatch  match 
)

Attempts to match the positions to this definition exactly once, by evaluating the enumerable and taking the first entry matched. If not match is found, then false is returned and match will be null.

Definition at line 97 of file OptionStrategyDefinition.cs.

Here is the call graph for this function:

◆ Match() [1/2]

IEnumerable<OptionStrategyDefinitionMatch> QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.Match ( OptionPositionCollection  positions)

Determines all possible matches for this definition using the provided positions . This includes OVERLAPPING matches. It's up to the actual matcher to make decisions based on which matches to accept. This allows the matcher to prioritize matching certain positions over others.

Definition at line 108 of file OptionStrategyDefinition.cs.

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

◆ Match() [2/2]

IEnumerable<OptionStrategyDefinitionMatch> QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.Match ( OptionStrategyMatcherOptions  options,
OptionPositionCollection  positions 
)

Determines all possible matches for this definition using the provided positions . This includes OVERLAPPING matches. It's up to the actual matcher to make decisions based on which matches to accept. This allows the matcher to prioritize matching certain positions over others.

Definition at line 118 of file OptionStrategyDefinition.cs.

Here is the call graph for this function:

◆ ToString()

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

Returns a string that represents the current object.

Returns
A string that represents the current object.

Definition at line 204 of file OptionStrategyDefinition.cs.

◆ Create() [1/3]

static OptionStrategyDefinition QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.Create ( string  name,
int  underlyingLots,
params OptionStrategyLegDefinition[]  legs 
)
static

Factory function for creating definitions

Definition at line 212 of file OptionStrategyDefinition.cs.

Here is the call graph for this function:

◆ Create() [2/3]

static OptionStrategyDefinition QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.Create ( string  name,
params OptionStrategyLegDefinition[]  legs 
)
static

Factory function for creating definitions

Definition at line 220 of file OptionStrategyDefinition.cs.

Here is the call graph for this function:

◆ Create() [3/3]

static OptionStrategyDefinition QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.Create ( string  name,
params Func< Builder, Builder >[]  predicates 
)
static

Factory function for creating definitions

Definition at line 228 of file OptionStrategyDefinition.cs.

◆ CallLeg()

static OptionStrategyLegDefinition QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.CallLeg ( int  quantity,
params Expression< Func< IReadOnlyList< OptionPosition >, OptionPosition, bool >>[]  predicates 
)
static

Factory function for creating a call leg definition

Definition at line 238 of file OptionStrategyDefinition.cs.

Here is the call graph for this function:

◆ PutLeg()

static OptionStrategyLegDefinition QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.PutLeg ( int  quantity,
params Expression< Func< IReadOnlyList< OptionPosition >, OptionPosition, bool >>[]  predicates 
)
static

Factory function for creating a put leg definition

Definition at line 248 of file OptionStrategyDefinition.cs.

Here is the call graph for this function:

◆ GetEnumerator()

IEnumerator<OptionStrategyLegDefinition> QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.GetEnumerator ( )

Returns an enumerator that iterates through the collection.

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

Definition at line 321 of file OptionStrategyDefinition.cs.

Member Data Documentation

◆ LegCount

int QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.LegCount => Legs.Count + (UnderlyingLots == 0 ? 0 : 1)

Gets the total number of legs, INCLUDING the underlying leg if applicable. This is used to perform a coarse filter as the minimum number of unique positions in the positions collection.

Definition at line 56 of file OptionStrategyDefinition.cs.

Property Documentation

◆ Name

string QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.Name
get

Gets the definition's name

Definition at line 36 of file OptionStrategyDefinition.cs.

◆ UnderlyingLots

int QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.UnderlyingLots
get

Gets the number of underlying lots required to match this definition. A lot size is equal to the contract's multiplier and is usually equal to 100.

Definition at line 42 of file OptionStrategyDefinition.cs.

◆ Legs

IReadOnlyList<OptionStrategyLegDefinition> QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.Legs
get

Gets the option leg definitions. This list does NOT contain a definition for the required underlying lots, due to its simplicity. Instead the required underlying lots are defined via the UnderlyingLots property of the definition.

Definition at line 49 of file OptionStrategyDefinition.cs.


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