fix(api): rank covered calls by reward/risk, not max_profit/1000 (#13)#29
Open
bradsmithmba wants to merge 1 commit into
Open
fix(api): rank covered calls by reward/risk, not max_profit/1000 (#13)#29bradsmithmba wants to merge 1 commit into
bradsmithmba wants to merge 1 commit into
Conversation
_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>
This was referenced Jun 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_create_covered_call()set the recommendation's ranking key to a fabricated value:get_actionable_recommendations()sorts recommendations byprofit_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 usemax_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:
After the change, all four creators compute
profit_risk_ratiothe same way (verified by grep — no/ 1000remains).Out of scope (separate bug)
The covered-call
max_profitandmax_lossthemselves have a per-share vs per-contract unit mismatch (premium + (strike - current_price) * 100mixes a per-share premium with a 100-share quantity), documented inBUGS_TO_FIX.md. This PR only fixes the ranking ratio's formula; the inputs are tracked separately. The ratio is now computed correctly from whatevermax_profit/max_lossare — fixing those is a follow-up.🤖 Generated with Claude Code