Skip to content

M2: strategy engine and optimizer (pages 5-6) - #3

Merged
SecondOrderEdge merged 1 commit into
mainfrom
claude/options-strategy-lab-blueprint-a976d
May 24, 2026
Merged

M2: strategy engine and optimizer (pages 5-6)#3
SecondOrderEdge merged 1 commit into
mainfrom
claude/options-strategy-lab-blueprint-a976d

Conversation

@SecondOrderEdge

Copy link
Copy Markdown
Owner

Summary

Implements M2 — Strategy engine and optimization on top of the merged M1 library.

  • osl.strategy.legsLeg/Strategy dataclasses (OptionType/Side enums) with stock support and signed P&L at the primary expiry (later-dated legs repriced via BSM for calendars/PMCC).
  • osl.strategy.strategies — 22 builders via a ChainContext: long call/put, verticals, covered call, cash-secured put, collar, protective put, straddles/strangles, iron condor/fly, broken-wing butterfly, ratio spread, jade lizard, calendar, diagonal, PMCC.
  • osl.strategy.metrics — breakevens, bounded/unbounded max P/L, POP under four labelled measures (delta proxy, RN closed-form, RN Monte Carlo, empirical bootstrap), EV (closed-form edge + RN MC with 95% CI + empirical), expected shortfall, return-on-risk, aggregated greeks, convexity. POP is never shown without an EV and tail-loss companion.
  • osl.strategy.liquidity — score (spread/OI/volume/ATM) + slippage; zero-bid legs penalized.
  • osl.strategy.enumerate — view-aware candidate enumeration; excludes zero-bid legs by default.
  • osl.strategy.optimizer — nine ranking objectives; pop_capped never ranks unbounded risk first.
  • osl.pricing.monte_carlo — antithetic GBM terminal sampler.
  • osl.viz + pages 5–6 — scatter/radar builders; Strategy Generator (top-N per objective, radar) and Strategy Optimizer (sortable ranking, EV/POP-vs-risk frontiers).

Test plan

  • ruff / black / strict mypy osl — clean
  • pytest138 tests pass, 89% coverage, including on CI's managed standalone interpreter (3.11.13)
  • Acceptance: iron-condor breakevens match the closed form; uncovered short strangle reports ∞ max loss (never a finite number); POP delta/RN/MC agree within 2pp on a long call; a deep-OTM short put spread shows POP > 90% with EV < 0; optimizer ranking is deterministic and objective-dependent; zero-bid contracts excluded from enumeration unless explicitly allowed
  • Streamlit pages 5–6 compile-checked only (no browser in CI)

Honesty notes

  • EV here is risk-neutral (edge vs fair value + RN MC); real-world/GARCH EV and the Probability Lab arrive in M4.
  • POP labels make the measure explicit; the delta proxy is documented as overstating POP.

https://claude.ai/code/session_011QQZCSnQXWFafw3MEnMCHe


Generated by Claude Code

Adds the multi-leg strategy engine on top of M1:

- osl.strategy.legs: Leg/Strategy dataclasses (OptionType/Side enums), stock
  support, signed P&L at the primary expiry with BSM repricing of later legs.
- osl.strategy.strategies: 22 builders via a ChainContext (long call/put,
  verticals, covered call, CSP, collar, protective put, straddles/strangles,
  iron condor/fly, broken-wing butterfly, ratio spread, jade lizard, calendar,
  diagonal, PMCC).
- osl.strategy.metrics: breakevens, bounded/unbounded max P/L, POP under four
  labelled measures (delta proxy, RN closed-form, RN Monte Carlo, empirical),
  EV (closed-form edge + RN MC with 95% CI + empirical), expected shortfall,
  return-on-risk, aggregated greeks, convexity. POP always paired with EV + ES.
- osl.strategy.liquidity: score + slippage; zero-bid penalized.
- osl.strategy.enumerate: view-aware candidate enumeration; excludes zero-bid
  legs by default.
- osl.strategy.optimizer: nine ranking objectives; pop_capped never ranks an
  unbounded-risk position first.
- osl.pricing.monte_carlo: GBM terminal sampler (antithetic).
- osl.viz: scatter + radar builders; pages 5 (Strategy Generator) and 6
  (Strategy Optimizer).

138 tests pass (incl. on CI's managed standalone interpreter); mypy strict
clean; 89% coverage.

https://claude.ai/code/session_011QQZCSnQXWFafw3MEnMCHe
@SecondOrderEdge
SecondOrderEdge merged commit bd5072f into main May 24, 2026
2 checks passed
@SecondOrderEdge
SecondOrderEdge deleted the claude/options-strategy-lab-blueprint-a976d branch May 24, 2026 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants