Skip to content

fix(api): rank covered calls by reward/risk, not max_profit/1000 (#13)#29

Open
bradsmithmba wants to merge 1 commit into
cloudtrainerwork:masterfrom
bradsmithmba:fix/profit-risk-ratio
Open

fix(api): rank covered calls by reward/risk, not max_profit/1000 (#13)#29
bradsmithmba wants to merge 1 commit into
cloudtrainerwork:masterfrom
bradsmithmba:fix/profit-risk-ratio

Conversation

@bradsmithmba

Copy link
Copy Markdown

Summary

_create_covered_call() set the recommendation's ranking key to a fabricated value:

'profit_risk_ratio': round(max_profit / 1000, 2)  # Simplified ratio for covered calls

get_actionable_recommendations() sorts recommendations by profit_risk_ratio (descending), so covered calls were ordered by raw dollar profit divided by an arbitrary constant rather than by risk-adjusted return. The other three creators — bull call spread, bear put spread, iron condor — already use max_profit / max_loss, so covered calls were being ranked on a different, meaningless scale.

Closes #13.

Fix

Make the covered call consistent with every other strategy:

'profit_risk_ratio': round(max_profit / max_loss, 2) if max_loss > 0 else 0

After the change, all four creators compute profit_risk_ratio the same way (verified by grep — no / 1000 remains).

Out of scope (separate bug)

The covered-call max_profit and max_loss themselves have a per-share vs per-contract unit mismatch (premium + (strike - current_price) * 100 mixes a per-share premium with a 100-share quantity), documented in BUGS_TO_FIX.md. This PR only fixes the ranking ratio's formula; the inputs are tracked separately. The ratio is now computed correctly from whatever max_profit/max_loss are — fixing those is a follow-up.

🤖 Generated with Claude Code

_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 cloudtrainerwork#13

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

profit_risk_ratio is fabricated (max_profit / 1000) and used to rank strategy recommendations

1 participant