Lean
$LEAN_TAG$
|
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...
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< OptionStrategyDefinitionMatch > | 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. More... | |
IEnumerable< OptionStrategyDefinitionMatch > | 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. More... | |
override string | ToString () |
Returns a string that represents the current object. More... | |
IEnumerator< OptionStrategyLegDefinition > | GetEnumerator () |
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< OptionStrategyLegDefinition > | 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. More... | |
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.
QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.OptionStrategyDefinition | ( | string | name, |
int | underlyingLots, | ||
IEnumerable< OptionStrategyLegDefinition > | legs | ||
) |
Initializes a new instance of the OptionStrategyDefinition class
name | The definition's name |
underlyingLots | The required number of underlying lots |
legs | Definitions for each option leg |
Definition at line 64 of file OptionStrategyDefinition.cs.
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.
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.
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.
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.
override string QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.ToString | ( | ) |
Returns a string that represents the current object.
Definition at line 204 of file OptionStrategyDefinition.cs.
|
static |
Factory function for creating definitions
Definition at line 212 of file OptionStrategyDefinition.cs.
|
static |
Factory function for creating definitions
Definition at line 220 of file OptionStrategyDefinition.cs.
|
static |
Factory function for creating definitions
Definition at line 228 of file OptionStrategyDefinition.cs.
|
static |
Factory function for creating a call leg definition
Definition at line 238 of file OptionStrategyDefinition.cs.
|
static |
Factory function for creating a put leg definition
Definition at line 248 of file OptionStrategyDefinition.cs.
IEnumerator<OptionStrategyLegDefinition> QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyDefinition.GetEnumerator | ( | ) |
Returns an enumerator that iterates through the collection.
Definition at line 321 of file OptionStrategyDefinition.cs.
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.
|
get |
Gets the definition's name
Definition at line 36 of file OptionStrategyDefinition.cs.
|
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.
|
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.