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

Defines options that influence how the matcher operates. More...

Public Member Functions

 OptionStrategyMatcherOptions (IReadOnlyList< OptionStrategyDefinition > definitions, IReadOnlyList< int > maximumCountPerLeg, TimeSpan maximumDuration=default(TimeSpan), int maximumSolutionCount=100, IOptionStrategyDefinitionEnumerator definitionEnumerator=null, IOptionStrategyMatchObjectiveFunction objectiveFunction=null, IOptionPositionCollectionEnumerator positionEnumerator=null)
 Initializes a new instance of the OptionStrategyMatcherOptions class, providing options that control the behavior of the OptionStrategyMatcher More...
 
int GetMaximumLegMatches (int legIndex)
 Gets the maximum number of leg matches to be evaluated. This is to limit evaluating exponential numbers of potential matches as a result of large numbers of unique option positions for the same underlying security. More...
 
IEnumerable< OptionPositionEnumerate (OptionPositionCollection positions)
 Enumerates the specified positions according to the configured IOptionPositionCollectionEnumerator More...
 
OptionStrategyMatcherOptions WithMaximumDuration (TimeSpan duration)
 Specifies the maximum time provided for obtaining an optimal solution. More...
 
OptionStrategyMatcherOptions WithMaximumSolutionCount (int count)
 Specifies the maximum number of solutions to evaluate via the objective function. More...
 
OptionStrategyMatcherOptions WithMaximumCountPerLeg (IReadOnlyList< int > counts)
 Specifies the maximum number of solutions per leg index in a solution. Matching is a recursive process, for example, we'll find a very large number of positions to match the first leg. Matching the second leg we'll see less, and third still even less. This is because each subsequent leg must abide by all the previous legs. This parameter defines how many potential matches to evaluate at each leg. For the first leg, we'll evaluate counts[0] matches. For the second leg we'll evaluate counts[1] matches and so on. By decreasing this parameter we can evaluate more total, complete solutions for the entire portfolio rather than evaluation every single permutation of matches for a particular strategy definition, which grows in absurd exponential fashion as the portfolio grows. More...
 
OptionStrategyMatcherOptions WithObjectiveFunction (IOptionStrategyMatchObjectiveFunction function)
 Specifies a function used to evaluate how desirable a particular solution is. A good implementation for this would be to minimize the total margin required to hold all of the positions. More...
 
OptionStrategyMatcherOptions WithDefinitionEnumerator (IOptionStrategyDefinitionEnumerator enumerator)
 Specifies the order in which definitions are evaluated. Definitions evaluated sooner are more likely to find matches than ones evaluated later. More...
 
OptionStrategyMatcherOptions WithPositionEnumerator (IOptionPositionCollectionEnumerator enumerator)
 Specifies the order in which positions are evaluated. Positions evaluated sooner are more likely to find matches than ones evaluated later. A good implementation for this is its stand-alone margin required, which would encourage the algorithm to match higher margin positions before matching lower margin positiosn. More...
 

Static Public Member Functions

static OptionStrategyMatcherOptions ForDefinitions (params OptionStrategyDefinition[] definitions)
 Creates a new OptionStrategyMatcherOptions with the specified definitions , with no limits of maximum matches per leg and default values for the remaining options More...
 
static OptionStrategyMatcherOptions ForDefinitions (IEnumerable< OptionStrategyDefinition > definitions)
 Creates a new OptionStrategyMatcherOptions with the specified definitions , with no limits of maximum matches per leg and default values for the remaining options More...
 

Public Attributes

IEnumerable< OptionStrategyDefinitionDefinitions => _definitionEnumerator.Enumerate(_definitions)
 The definitions to be used for matching. More...
 

Properties

TimeSpan MaximumDuration [get]
 The maximum amount of time spent trying to find an optimal solution. More...
 
int MaximumSolutionCount [get]
 The maximum number of matches to evaluate for the entire portfolio. More...
 
IReadOnlyList< int > MaximumCountPerLeg [get]
 Indexed by leg index, defines the max matches to evaluate per leg. For example, MaximumCountPerLeg[1] is the max matches to evaluate for the second leg (index=1). More...
 
IOptionStrategyMatchObjectiveFunction ObjectiveFunction [get]
 Objective function used to compare different match solutions for a given set of positions/definitions More...
 

Detailed Description

Defines options that influence how the matcher operates.

Many properties in this type are not implemented in the matcher but are provided to document the types of things that can be added to the matcher in the future as necessary. Some of the features contemplated in this class would require updating the various matching/filtering/slicing functions to accept these options, or a particular property. This is the case for the enumerators which would be used to prioritize which positions to try and match first. A great implementation of the IOptionPositionCollectionEnumerator would be to yield positions with the highest margin requirements first. At time of writing, the goal is to achieve a workable rev0, and we can later improve the efficiency/optimization of the matching process.

Definition at line 35 of file OptionStrategyMatcherOptions.cs.

Constructor & Destructor Documentation

◆ OptionStrategyMatcherOptions()

QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyMatcherOptions.OptionStrategyMatcherOptions ( IReadOnlyList< OptionStrategyDefinition definitions,
IReadOnlyList< int >  maximumCountPerLeg,
TimeSpan  maximumDuration = default(TimeSpan),
int  maximumSolutionCount = 100,
IOptionStrategyDefinitionEnumerator  definitionEnumerator = null,
IOptionStrategyMatchObjectiveFunction  objectiveFunction = null,
IOptionPositionCollectionEnumerator  positionEnumerator = null 
)

Initializes a new instance of the OptionStrategyMatcherOptions class, providing options that control the behavior of the OptionStrategyMatcher

Definition at line 73 of file OptionStrategyMatcherOptions.cs.

Here is the caller graph for this function:

Member Function Documentation

◆ GetMaximumLegMatches()

int QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyMatcherOptions.GetMaximumLegMatches ( int  legIndex)

Gets the maximum number of leg matches to be evaluated. This is to limit evaluating exponential numbers of potential matches as a result of large numbers of unique option positions for the same underlying security.

Definition at line 118 of file OptionStrategyMatcherOptions.cs.

◆ Enumerate()

IEnumerable<OptionPosition> QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyMatcherOptions.Enumerate ( OptionPositionCollection  positions)

Enumerates the specified positions according to the configured IOptionPositionCollectionEnumerator

Definition at line 127 of file OptionStrategyMatcherOptions.cs.

◆ ForDefinitions() [1/2]

static OptionStrategyMatcherOptions QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyMatcherOptions.ForDefinitions ( params OptionStrategyDefinition[]  definitions)
static

Creates a new OptionStrategyMatcherOptions with the specified definitions , with no limits of maximum matches per leg and default values for the remaining options

Definition at line 136 of file OptionStrategyMatcherOptions.cs.

Here is the caller graph for this function:

◆ ForDefinitions() [2/2]

static OptionStrategyMatcherOptions QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyMatcherOptions.ForDefinitions ( IEnumerable< OptionStrategyDefinition definitions)
static

Creates a new OptionStrategyMatcherOptions with the specified definitions , with no limits of maximum matches per leg and default values for the remaining options

Definition at line 145 of file OptionStrategyMatcherOptions.cs.

Here is the call graph for this function:

◆ WithMaximumDuration()

OptionStrategyMatcherOptions QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyMatcherOptions.WithMaximumDuration ( TimeSpan  duration)

Specifies the maximum time provided for obtaining an optimal solution.

Definition at line 154 of file OptionStrategyMatcherOptions.cs.

Here is the call graph for this function:

◆ WithMaximumSolutionCount()

OptionStrategyMatcherOptions QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyMatcherOptions.WithMaximumSolutionCount ( int  count)

Specifies the maximum number of solutions to evaluate via the objective function.

Definition at line 170 of file OptionStrategyMatcherOptions.cs.

Here is the call graph for this function:

◆ WithMaximumCountPerLeg()

OptionStrategyMatcherOptions QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyMatcherOptions.WithMaximumCountPerLeg ( IReadOnlyList< int >  counts)

Specifies the maximum number of solutions per leg index in a solution. Matching is a recursive process, for example, we'll find a very large number of positions to match the first leg. Matching the second leg we'll see less, and third still even less. This is because each subsequent leg must abide by all the previous legs. This parameter defines how many potential matches to evaluate at each leg. For the first leg, we'll evaluate counts[0] matches. For the second leg we'll evaluate counts[1] matches and so on. By decreasing this parameter we can evaluate more total, complete solutions for the entire portfolio rather than evaluation every single permutation of matches for a particular strategy definition, which grows in absurd exponential fashion as the portfolio grows.

Definition at line 193 of file OptionStrategyMatcherOptions.cs.

Here is the call graph for this function:

◆ WithObjectiveFunction()

OptionStrategyMatcherOptions QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyMatcherOptions.WithObjectiveFunction ( IOptionStrategyMatchObjectiveFunction  function)

Specifies a function used to evaluate how desirable a particular solution is. A good implementation for this would be to minimize the total margin required to hold all of the positions.

Definition at line 210 of file OptionStrategyMatcherOptions.cs.

Here is the call graph for this function:

◆ WithDefinitionEnumerator()

OptionStrategyMatcherOptions QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyMatcherOptions.WithDefinitionEnumerator ( IOptionStrategyDefinitionEnumerator  enumerator)

Specifies the order in which definitions are evaluated. Definitions evaluated sooner are more likely to find matches than ones evaluated later.

Definition at line 227 of file OptionStrategyMatcherOptions.cs.

Here is the call graph for this function:

◆ WithPositionEnumerator()

OptionStrategyMatcherOptions QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyMatcherOptions.WithPositionEnumerator ( IOptionPositionCollectionEnumerator  enumerator)

Specifies the order in which positions are evaluated. Positions evaluated sooner are more likely to find matches than ones evaluated later. A good implementation for this is its stand-alone margin required, which would encourage the algorithm to match higher margin positions before matching lower margin positiosn.

Definition at line 245 of file OptionStrategyMatcherOptions.cs.

Here is the call graph for this function:

Member Data Documentation

◆ Definitions

IEnumerable<OptionStrategyDefinition> QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyMatcherOptions.Definitions => _definitionEnumerator.Enumerate(_definitions)

The definitions to be used for matching.

Definition at line 58 of file OptionStrategyMatcherOptions.cs.

Property Documentation

◆ MaximumDuration

TimeSpan QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyMatcherOptions.MaximumDuration
get

The maximum amount of time spent trying to find an optimal solution.

Definition at line 40 of file OptionStrategyMatcherOptions.cs.

◆ MaximumSolutionCount

int QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyMatcherOptions.MaximumSolutionCount
get

The maximum number of matches to evaluate for the entire portfolio.

Definition at line 45 of file OptionStrategyMatcherOptions.cs.

◆ MaximumCountPerLeg

IReadOnlyList<int> QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyMatcherOptions.MaximumCountPerLeg
get

Indexed by leg index, defines the max matches to evaluate per leg. For example, MaximumCountPerLeg[1] is the max matches to evaluate for the second leg (index=1).

Definition at line 52 of file OptionStrategyMatcherOptions.cs.

◆ ObjectiveFunction

IOptionStrategyMatchObjectiveFunction QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyMatcherOptions.ObjectiveFunction
get

Objective function used to compare different match solutions for a given set of positions/definitions

Definition at line 63 of file OptionStrategyMatcherOptions.cs.


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