Skip to content

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

@bradsmithmba

Description

@bradsmithmba

Summary

src/api/enhanced_strategy_recommender.py computes profit_risk_ratio by dividing max_profit by the literal constant 1000. This is not a meaningful financial metric. Recommendations are sorted by this value, so the ranking is driven by a fabricated number.

Location

src/api/enhanced_strategy_recommender.py, line ~516:

profit_risk_ratio = round(max_profit / 1000, 2)

And later, recommendations are sorted:

recommendations.sort(key=lambda r: r.profit_risk_ratio, reverse=True)

Why this is wrong

A meaningful profit/risk ratio should be max_profit / max_loss (reward-to-risk). Dividing by the constant 1000 produces a ratio that scales with the absolute dollar value of max profit, not with how it compares to the potential loss. Two strategies with the same reward-to-risk profile but different position sizes will rank differently, and a high-dollar-risk strategy with large gross profit will rank above a lower-risk strategy with better actual reward/risk.

The existing max_profit calculation also has a known unit mismatch bug (see Issue #3 in BUGS_TO_FIX.md), so this ratio is doubly wrong: wrong formula applied to wrong inputs.

Correct fix

profit_risk_ratio = round(max_profit / max_loss, 2) if max_loss > 0 else float('inf')

Also fix the upstream max_profit and max_loss unit mismatch (covered call mixes per-share premium with 100-multiplied capital gain) before relying on this ratio for ranking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions