From a26fea66e7ee50dd52bd0990fb4ad2caab57b988 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Wed, 10 Jun 2026 13:25:41 -0500 Subject: [PATCH] fix(strategies): remove IRON_BUTTERFLY enum alias that shadowed BUTTERFLY MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit StrategyType defined both BUTTERFLY = "butterfly" and IRON_BUTTERFLY = "butterfly". Identical values make IRON_BUTTERFLY a silent alias of BUTTERFLY (StrategyType.IRON_BUTTERFLY is StrategyType.BUTTERFLY), so the two collapse to one dict key — using both in a probabilities/metrics dict silently drops one entry. The codebase canonically identifies the iron butterfly as BUTTERFLY (IronButterflyStrategy.get_strategy_type returns it; the factory registry, regime mappings, recommendation engine, and API all key on BUTTERFLY). IRON_BUTTERFLY was referenced only in tests/models/test_scoring_engine.py. Remove the redundant alias and point that test at the canonical BUTTERFLY. Enum member count is unchanged (16) since the alias was never a distinct member. A separate, larger cleanup could rename BUTTERFLY -> IRON_BUTTERFLY to better reflect the implementation, but that is out of scope here. Closes #4 Co-Authored-By: Claude Opus 4.8 --- src/strategies/base.py | 6 +++++- tests/models/test_scoring_engine.py | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/strategies/base.py b/src/strategies/base.py index a54ec66..9396a3b 100644 --- a/src/strategies/base.py +++ b/src/strategies/base.py @@ -49,8 +49,12 @@ class StrategyType(Enum): # Complex strategies IRON_CONDOR = "iron_condor" + # BUTTERFLY is the canonical member for the iron butterfly strategy + # (see IronButterflyStrategy.get_strategy_type and the factory registry). + # A second IRON_BUTTERFLY = "butterfly" member previously aliased BUTTERFLY + # (identical value), so the two were the same object and collided as dict + # keys. Removed to eliminate the silent shadowing. BUTTERFLY = "butterfly" - IRON_BUTTERFLY = "butterfly" class StrategyCategory(Enum): diff --git a/tests/models/test_scoring_engine.py b/tests/models/test_scoring_engine.py index d9a18e9..a5041b2 100644 --- a/tests/models/test_scoring_engine.py +++ b/tests/models/test_scoring_engine.py @@ -28,7 +28,7 @@ def sample_probabilities(self): StrategyType.IRON_CONDOR: 0.35, StrategyType.BULL_CALL_SPREAD: 0.25, StrategyType.LONG_STRADDLE: 0.20, - StrategyType.IRON_BUTTERFLY: 0.15, + StrategyType.BUTTERFLY: 0.15, StrategyType.BEAR_PUT_SPREAD: 0.05 } @@ -66,7 +66,7 @@ def sample_risk_metrics(self): 'volatility': 0.35, 'backtest_samples': 75 }, - StrategyType.IRON_BUTTERFLY: { + StrategyType.BUTTERFLY: { 'max_drawdown': 0.10, 'var_95': 0.04, 'win_rate': 0.65, @@ -95,7 +95,7 @@ def sample_expected_returns(self): StrategyType.IRON_CONDOR: 0.12, StrategyType.BULL_CALL_SPREAD: 0.15, StrategyType.LONG_STRADDLE: 0.20, - StrategyType.IRON_BUTTERFLY: 0.08, + StrategyType.BUTTERFLY: 0.08, StrategyType.BEAR_PUT_SPREAD: 0.10 }