Skip to content

Keep covered credit spreads from leaving naked shorts - #10038

Open
mkzung wants to merge 1 commit into
QuantConnect:masterfrom
mkzung:bug-10035-covered-credit-spreads
Open

mkzung wants to merge 1 commit into
QuantConnect:masterfrom
mkzung:bug-10035-covered-credit-spreads

Conversation

@mkzung

@mkzung mkzung commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Description

Favor strategies with balanced option legs in the fallback matching pass. A ladder with surplus longs can otherwise consume the cover needed by another short, leaving a defined-risk spread book charged naked option margin.

The first matching pass and tie behavior are unchanged, preserving genuine ladder books. This follows the approach proposed in #10035.

Related Issue

Fixes #10035.

Motivation and Context

Two covered credit spreads can be regrouped into a ladder plus a naked short. In the added portfolio scenarios, the required margin is 13,000 before the fix and 6,000 after it, matching the combined strike widths.

Requires Documentation Change

No.

How Has This Been Tested?

Clean checkout and fresh build, .NET 10.0.400 on macOS arm64 with Python 3.12. All 5,591 Common.Securities tests pass, with 4 skipped.

The six added cases cover put/call books with overlapping or disjoint strikes and portfolio margin for both rights. Restoring the original matching code fails all six; restoring the fix passes the full set again. Existing ladder and debit-spread tests pass.

The objective function and its strike-width heuristic are unchanged.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code follows the code style of this project.
  • I have read CONTRIBUTING.md.
  • I have added tests to cover my changes.
  • All new and existing tests in Common.Securities passed.
  • My branch follows the naming convention bug-<issue#>-<description>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant