Option strategy matcher can prefer a wide credit call spread over a cheaper naked call

Open
#10,072 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
54/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp

Research direction

Read UncoveredShortQuantityOptionStrategyMatchObjectiveFunction and the call-side width check, then compare its strike-based proxy with OptionMarginModel's naked-call margin floor. Reproduce the SPY example from the issue and check whether the matcher selects a grouping with lower TotalMarginUsed; the issue does not name a test file, so locate the relevant matcher tests. Done when the call grouping reflects the lower maintenance margin without regressing put matching.

Written by the indexing model from the issue text.

Description

Expected Behavior

When OptionStrategyMatcher has to choose between covering a short call with a wide credit-side long and leaving that short naked, it should prefer the grouping that requires less maintenance margin.

Actual Behavior

UncoveredShortQuantityOptionStrategyMatchObjectiveFunction counts a credit-side long as covering a short when the strike width is at most MaximumCreditCoverWidthFactor (10%) of the short strike. The matcher has no prices, so the strike stands in for the naked-margin floor. For puts, this matches OptionMarginModel's floor. For calls, OptionMarginModel's floor is 10% of the underlying price. For out-of-the-money calls the underlying is below the strike, so the score treats wide call spreads as covered even when they cost more than the naked call.

Reproduction (standard margin models, SPY at 100, multiplier 100, all calls expiring 2025-02-21):

Strike Quantity Price
140 +1 0.30
150 -1 0.15
151 -1 0.10
164 +1 0.02
  • Current grouping: Bull Call Spread (+C140/-C150, margin 0) plus Bear Call Spread (-C151/+C164, margin 1,400). TotalMarginUsed is 1,400.
  • Greedy grouping, which the second candidate replaces because it scores -1 instead of 0: Bull Call Ladder (+C140/-C150/-C151) plus a lone long C164. The ladder is margined as the naked C151, about 1,010.

The 14-point width is under 10% of the 151 strike (15.1), but over the naked-call floor of 10% of the underlying (10).

Potential Solution

A suggestion, not a requirement: compare actual maintenance margin, or use the underlying price for the call-side width check. #10062 (for #10035) gates only the new third matching candidate on actual maintenance margin. The first two candidates still rely on the strike-based proxy alone.

Checklist
  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
Dominant language
C#
Stars
22.6k
Forks
5.4k
Avg merge
11h 39m
Merged PRs (30d)
104

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from QuantConnect/Lean

All issues in QuantConnect/Lean

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.