Skip to content

Real 24h price change derived from candle store #154

Description

@ozpool

Problem

pseudoChange(market) on /markets returns ((hashBase(market) % 1601) - 800) / 100 — a deterministic but completely fake number in [-8%, +8%].

MarketHeader's 24h change works correctly against the local anchor price (first observed value after page load), but that's "change since you opened the tab", not 24h.

Proposal

Once #152 ships, MarketInfo can carry a change24hPct field computed at REST read time:

fn change_24h_pct(market_id: &str) -> Decimal {
    let candles = self.candles_24h(market_id);
    let open = candles.first().map(|c| c.open).unwrap_or_default();
    let close = candles.last().map(|c| c.close).unwrap_or_default();
    if open.is_zero() { return dec!(0); }
    ((close - open) / open) * dec!(100)
}

FE: drop pseudoChange everywhere, read market.change24hPct.

Acceptance

  • /markets table 24h change column shows real numbers.
  • MarketHeader's % matches across page reloads instead of resetting.

Depends on

#152

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

    enhancementNew feature or request

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions