Skip to content

fix(risk-metrics): zero-volatility Sharpe is -inf, which serializes to null and crashes the renderer #230

Open

Description

@AojdevStudio

On main (d845531), RiskCalculator._calculate_sharpe divides by returns.std(). A flat price series gives std == 0 and a Sharpe of -inf. Pydantic's JSON output turns -inf into null, and the risk renderer then raises TypeError on the null.

Found by the second-model review of the comment-sweep analysis branch, which reproduced it on both the base and the branch. The branch names the outcome (_zero_risk_sharpe) but keeps the -inf value.

Fix: define an explicit contract for an unavailable or unbounded ratio, for example None with a reason field, and test its JSON round trip through every consumer.

Activity

  1. pullfrog commented on Oct 14, 2026

    @pullfrog
  2. linear-code commented on Oct 14, 2026

    @linear-code
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