Skip to content

Bug: position_size typed float but receives None from kelly sizing — downstream TypeError #52

Description

@bradsmithmba

Summary

ScoringEngine._calculate_kelly_sizing explicitly returns None when historical performance data is absent. That None flows into StrategyRecommendation.position_size, which is typed as float. Any downstream code doing arithmetic on recommendation.position_size (e.g., size * capital) raises TypeError.

Evidence

src/models/scoring_engine.py lines 207-208: return None in _calculate_kelly_sizing when history is empty.
src/models/recommendation_engine.py line 329: position_size=scored_strategy.kelly_size
src/models/recommendation_engine.py line 33: position_size: float — not Optional[float].

Fix

Change the type annotation to Optional[float] and document that None means "position size undetermined". Guard all callers that read position_size numerically.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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