Skip to content

feat(peg): OHLC per-minute gauges + worst-case headline metric - #349

Merged
Flotapponnier merged 1 commit into
devfrom
feat/peg-ohlc-worst-case-metrics
Jun 9, 2026
Merged

feat(peg): OHLC per-minute gauges + worst-case headline metric#349
Flotapponnier merged 1 commit into
devfrom
feat/peg-ohlc-worst-case-metrics

Conversation

@Flotapponnier

Copy link
Copy Markdown
Collaborator

Summary

Fix A of the methodology improvements proposed by a Coinpaprika data
team reviewer. Switches stablecoin-peg from per-minute median to
per-minute MAX deviation, so sub-minute depeg wicks (e.g. USDC at $0.87
for 5 seconds during SVB) stop disappearing into the median.

What changed

Harness (Go):

  • New gauges in metrics.go: peg_deviation_worst_bps, peg_minute_max_bps, _min_bps, _open_bps, _close_bps
  • aggregator.gocloseMinuteLocked() now computes OHLC across every venue sample within the 60s bucket and emits all five gauges alongside the existing median

YAML (benchmarks/stablecoin-peg.yml):

  • All 3 provider queries (USDC, USDT, DAI) point at peg_deviation_worst_bps
  • Methodology section explains the OHLC switch + the rationale
  • Comment block updated to list all new metrics

What did NOT change

  • peg_deviation_bps (legacy median) stays live for backward compat
  • Histogram + cross-venue gap + depeg flag unchanged
  • No outlier rule changes here (separate PR — Fix B)
  • No site code changes (Next.js side resolves metrics dynamically from YAML)

Test plan

  • Harness binary builds clean (go build ./... from harnesses/stablecoin-peg/)
  • Deploy to Railway, scrape /metrics, confirm all 5 new gauges emit non-zero values per stable
  • Verify peg_deviation_worst_bps >= peg_deviation_bps for every minute (max >= median)
  • Bench page on staging shows updated leaderboard with the new headline
  • Prometheus query quantile_over_time(0.99, peg_deviation_worst_bps[24h]) returns valid numbers within ~24h of deploy

Switches stablecoin-peg leaderboard from per-minute median to per-minute
max deviation so sub-minute depeg wicks no longer get smoothed away.
New metrics alongside existing peg_deviation_bps:
- peg_deviation_worst_bps (PRIMARY): per-minute max |price-1| in bps
- peg_minute_max_bps / _min_bps / _open_bps / _close_bps: full OHLC bar
YAML provider queries swapped to peg_deviation_worst_bps. Legacy
peg_deviation_bps gauge retained for backward compat.
Methodology recommendation from Coinpaprika data team review.
@Flotapponnier
Flotapponnier merged commit d044d9b into devJun 9, 2026
1 check failed
@Flotapponnier
Flotapponnier deleted the feat/peg-ohlc-worst-case-metrics branch June 9, 2026 21:42
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@Flotapponnier