Skip to content

OptionStrategyMatcher

QuantConnect.Securities.Option.StrategyMatcher.OptionStrategyMatcher

OptionStrategyMatcher(
    options: OptionStrategyMatcherOptions,
)

Bases: Object

Matches OptionPositionCollection against a collection of OptionStrategyDefinition according to the OptionStrategyMatcherOptions provided.

Initializes a new instance of the OptionStrategyMatcher class

Parameters:

Name Type Description Default
options OptionStrategyMatcherOptions

Specifies definitions and other options controlling the matcher

required

options

Specifies options controlling how the matcher operates

match_once

match_once(
    positions: OptionPositionCollection,
) -> OptionStrategyMatch

Using the definitions provided in options, attempts to match all positions. The resulting OptionStrategyMatch presents a single, valid solution for matching as many positions as possible. A fixed set of candidate solutions is evaluated and the one scoring highest against the configured OptionStrategyMatcherOptions.objective_function is selected, so short positions are grouped into covered strategies instead of being charged naked option margin whenever the positions allow it. On equal scores, the solution produced by the configured definition enumeration order is preserved.