Skip to content

fix(leaderboard): a NULL equity is published as a real $0 #390

Description

@FlyM1ss

Surfaced reviewing #387.

domain/leaderboard/service.py:1447 maps a missing equity to zero before it leaves the server:

"equity": float(pt.get("equity") or 0) * scale,

So "this point was never recorded" and "the account really was at zero" arrive at every client byte-identical. On a base-relative chart a 0 renders as -100%, and that does not misplace one marker — it drags the whole percent axis to the floor and flattens every other curve on the board. The same coercion is on cash and positions_value in the two lines below.

No client can fix this. #387 hardened the landing side to separate absent from zero before it coerces (a finiteNumber helper — note Number(null) is 0 in JS, so the obvious Number.isFinite(Number(x)) guard passes the likeliest malformed shape straight through), but a literal 0 on the wire is indistinguishable from a real wipeout by construction. /app draws the same payload through js/leaderboard.js and has the same exposure.

Suggested shape: emit null for an unrecorded point and let each surface null-fill, which both chart layers already do for a missing timestamp. That is a wire-format change, so it needs the /app side moved in the same PR.

Not currently reachable in prod as far as I checked — the backtester always writes a value, so this is latent rather than live. Filing because it is invisible when it does fire: no error, no log line, and a green suite on both surfaces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions