From 1d17ea179ac227bf8b9a7412e01959d270271f90 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Wed, 10 Jun 2026 13:54:52 -0500 Subject: [PATCH] fix(api): rank covered calls by reward/risk, not max_profit/1000 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _create_covered_call() set profit_risk_ratio = max_profit / 1000, a fabricated constant. Recommendations are sorted by profit_risk_ratio, so covered calls were ranked by raw dollar profit scaled by an arbitrary divisor rather than by risk-adjusted return — inconsistent with the bull call, bear put, and iron condor creators, which already use max_profit / max_loss. Use max_profit / max_loss (guarded for max_loss == 0) so all strategies rank on the same reward-to-risk basis. Note: the covered-call max_profit/max_loss themselves have a separate per-share vs per-contract unit mismatch (documented in BUGS_TO_FIX.md); that is tracked separately and not addressed here. Closes #13 Co-Authored-By: Claude Opus 4.8 --- src/api/enhanced_strategy_recommender.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/api/enhanced_strategy_recommender.py b/src/api/enhanced_strategy_recommender.py index 3c68d49..a7d8068 100644 --- a/src/api/enhanced_strategy_recommender.py +++ b/src/api/enhanced_strategy_recommender.py @@ -513,7 +513,10 @@ def _create_covered_call(self, symbol: str, current_price: float, }, 'current_price': current_price, 'days_to_expiration': self._days_to_expiration(expiration), - 'profit_risk_ratio': round(max_profit / 1000, 2) # Simplified ratio for covered calls + # Reward-to-risk ratio, consistent with the spread strategies above. + # (Previously max_profit / 1000, a fabricated constant that ranked by + # raw dollar profit rather than risk-adjusted return.) + 'profit_risk_ratio': round(max_profit / max_loss, 2) if max_loss > 0 else 0 } # Helper methods