Skip to content

insights: an all-wins profit factor reads "—" (unknown) on Rules but "Infinity" in the CLI #979

Closed

Description

@eaitbrahim

Found while reviewing PR #975 (round 1, O2). This is not new: it was there before that PR.

What happens. A rule with winning trades and no losing ones has an infinite profit factor (stats.summarize returns Decimal("Infinity") when gross loss is 0 and gross profit is above 0).

  • keel insights summary prints profit_factor=Infinity.
  • The Rules view shows "—" with state unknown, because payload.ratio() turns any non-finite value into absent().
  • The gate card's realized_rr on an all-wins record shows "—" too. The CLI says rr=n/a (no losses yet) there.

Why it matters. This is the reverse of #965. Instead of an unknown shown as zero, a known value (no losses so far) is shown as unknown, and the page and the CLI disagree.

Fix (display only).

  • On the page, render an infinite profit factor as something like "∞ (no losses yet)" with a neutral state, not unknown.
  • In the CLI, pick one wording for both places, for example profit_factor=n/a (no losses yet) to match rr.
  • Gate verdicts are unaffected: check_floors reads the engine's own values.

Test. An all-wins record's profit factor reads the same reason on the page and in the CLI, and its page state is not unknown.

Activity

  1. self-assigned this
    on Oct 12, 2026
  2. eaitbrahim commented on Oct 12, 2026

    @eaitbrahim
    ContributorAuthor

    A related case, from PR #975 review round 2 (O2): when every closed trade is a scratch (gross profit = gross loss = 0), stats.summarize returns profit_factor = Decimal(0) (stats.py:205-210). The CLI then prints profit_factor=0.00 and the Rules view shows "0.00", but 0/0 is unknown, not zero. An all-losses profit factor of 0.00 is a real measurement; an all-scratch one is not. Worth fixing in the same display change.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions