Skip to content

UncoveredShortQuantityOptionStrategyMatchObjectiveFunction

QuantConnect.Securities.Option.StrategyMatcher.UncoveredShortQuantityOptionStrategyMatchObjectiveFunction

Bases: Object, IOptionStrategyMatchObjectiveFunction

Provides an implementation of IOptionStrategyMatchObjectiveFunction that minimizes the total quantity of short option contracts left uncovered, either within their matched strategy (such as the second short leg of a ladder) or unmatched entirely. Uncovered shorts are charged naked option margin, typically an order of magnitude larger than the margin of covered, risk-defined strategies, which makes this quantity a cheap and deterministic proxy for the total margin required to hold the positions.

compute_score

compute_score(
    input: OptionPositionCollection,
    match: OptionStrategyMatch,
    unmatched: OptionPositionCollection,
) -> float

Computes the score as the negated total quantity of uncovered short option contracts, so the solution covering the most short contracts wins and a solution without uncovered shorts scores zero, the maximum. A short leg is covered when its strategy holds, quantity for quantity, the underlying lots with the offsetting sign or long options of the same right which outlive it and whose strike is on the debit side of the short strike or within MaximumCreditCoverWidthFactor of it on the credit side