Skip to content

feat(leaderboard): daily Sharpe with its 95% interval - #704

Merged
FlyM1ss merged 12 commits into
mainfrom
feat/board-daily-sharpe
Oct 31, 2026
Merged

FlyM1ss merged 12 commits into
mainfrom
feat/board-daily-sharpe

Conversation

@FlyM1ss

@FlyM1ss FlyM1ss commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

DO NOT MERGE until the owner has approved the landing copy (docs/superpowers/plans/2026-10-14-live-board-fixes-p7-records.md, Task 7.3 Step 0) and the copy PR (feat(live): Live Leaderboard copy and catching-up badge) and the landing PR (feat(landing): Live Leaderboard copy and Sharpe interval) can merge the same week. From this deploy until the landing PR merges, / shows the new daily Sharpe under its old "annualized from hourly results" tooltip, with no interval.

Do not merge from 22:15 UTC on a weekday until that night's live refresh has finished (the check is in docs/superpowers/plans/2026-10-14-live-board-fixes.md, Merging and records). GitHub starts the 22:30 UTC cron as late as 03:05 UTC, and the refresh keeps running on Render after the workflow run ends. The merge auto-deploys prod, and the restart kills a running refresh, so the sessions it had not checkpointed are billed again on the next night.

  • Live and Competition boards now publish P19 daily Sharpe (one return per US/Eastern trading day, ddof 1, cash rate 0%/yr, ×√252) with its 95% interval (iid standard error), computed at read time from the stored curve. The browser only displays it (D20); guards keep Math.sqrt/stdev out of the board JS.
  • The published Sharpe numbers change meaning: hourly-annualised → daily. Below 5 trading days the value is null and the UI says "Needs 5 trading days (have N)"; undefined is null, never 0 (run.get("sharpe_ratio") or 0 is gone).
  • New payload fields per entry: sharpe_ci_low, sharpe_ci_high, sharpe_days, sharpe_status (ok | insufficient_days | no_variation | undefined | pending); basis block at live_status.sharpe (Live) and sharpe_basis (Competition).
  • Competition E_0 is approximate (its stored seed is the first mark, so day 1 omits the first hour); documented at the call site. calc_metrics and the stored agent_runs.sharpe_ratio are unchanged, so run-level APIs still show the hourly figure until the engine rewrite.
  • Merging to main auto-deploys prod.
  • Review-driven hardening on top of the plan: drift ERRORs are logged once per process per break, not per GET; the daily reader never raises on stored data (non-mapping points, out-of-range stamps, NaT, ints past float range) and logs ERROR when a non-empty curve yields no usable close or the seed is not positive; both boards sort Sharpe by what the cell shows (an old payload's hourly number sorts as absent); no -0.00; no invented "Based on 0 trading days"; Live detail escapes num_trades/snapshot_end.
  • Code-review round 2: a Live row whose stored curve has no point on the month axis (unreadable stamps, NULL equity, after-hours only) is now pending with an ERROR (live.curve_unplottable, once per process), not a ranked flat line reading "Returns never moved". A Live row with no recorded seed takes E_0 from its own first mark (it is not rescaled), not display_capital (day 1 read about -90% for a $10k run). A bad seed is its own status, undefined ("Cannot be computed"), logged from the first close instead of hiding behind "Needs 5 trading days"; so is an account at or below 0 and overflow. liveFormatSharpe delegates to formatBoardSharpe (one wording, no parity copy) and both boards sort through one boardSharpeValue predicate. The home rank row's interval is also in visually hidden text inside the cell. CLAUDE.md's Live-GET rule now says what it forbids (fetch, run recompute, deploy, scheduled refresh), not "compute".

Review notes for the owner

  • Copy (owner-approved 2026-10-31): undefined reads "Cannot be computed" on both boards (it used to share "Returns never moved").
  • Kept as planned, though reviewers flagged them: the Live GET computes Sharpe from stored rows (pure arithmetic, no fetch or spend; CLAUDE.md now says so); calc_metrics/agent_runs.sharpe_ratio stay hourly, so the run APIs, /api/v2/leaderboard, Discord and the SDK publish a second Sharpe under the same name until the engine rewrite (the metrics.py P19 block says so; moving the stored column here would redefine every user's run metric); a median-of-repeats row's interval is that one run's day-to-day noise (plan review focus 6); home sample rows show — (focus 7). P19 counts every session in the window, so a session with no print is a 0% day (pinned by test_live_sessions_before_the_first_print_count_as_idle_days).
  • Still open, tracked in Home rank row: Sharpe interval is unreachable on touch #706: on the home rank row a touch user sees the number without its interval (only title and screen-reader text carry it): a visible sub-line needs a row-height change in styles.css, off-limits here and unverifiable without a browser. / is the landing PR's change.
  • Not verifiable here (no browser in WSL): whether the "95% interval …" sub-line wraps in the 100px Competition Sharpe column. styles.css is off-limits in this PR.

Test plan

  • pytest dashboard/backend/tests -q -p no:cacheprovider locally: 7583 passed, 190 skipped, 25 xfailed on 766984d; the 12 failures are the known local-only ones (test_report_pdf.py x7, no reportlab; test_robinhood_mcp_transport.py x5, mcp 1.28.1 vs pin 1.30.0). git status --short empty afterwards (seed DB untouched).
  • Owner (Task 5.6 Step 4): approve P7 Task 7.3 Step 0 landing copy; P6 and P7 PR B land the same week (order P5, P6, P7 PR B); then gh pr ready.
  • Owner (Task 5.6 Step 5): right before merging, re-check the three cache-busters against main. Expected: js/live-leaderboard.js main=6 / branch=7, js/leaderboard.js main=38 / branch=39, home-page.js main=55 / branch=56. If main moved, rebase and bump again (and the test_frontend_fast_boot.py pins for the last two).
  • Owner (Task 5.6 Step 6): merge outside the 22:15 UTC weekday window.

User-facing docs this makes stale

Not edited here (owner batches these):

  • dashboard/landing/src/components/home/BoardPreview.tsx:649: "annualized from hourly results" tooltip; and the same string in the built bundle dashboard/frontend/assets/index-Dpn97z5M.js.
  • dashboard/landing/src/lib/leaderboard.ts:20-25, :159-169: comments citing run.get("sharpe_ratio") or 0, which this PR removes.
  • dashboard/landing/src/components/home/Race.tsx:139: Sharpe column note.
  • docs/landing-narrative-copy.md:55, :65: "Sharpe" with no basis.
  • docs/source/lab/agent_api.rst:48: GET /api/v2/leaderboard keeps the stored hourly Sharpe, so after this PR it disagrees with the Competition and Live boards. Not wrong, but the bases differ.

🤖 Generated with Claude Code

FlyM1ss and others added 8 commits October 30, 2026 15:06
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oard

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rval

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The boards call daily_sharpe_interval on their GET path. Skip non-mapping
points, out-of-range timestamps, NaT and ints past float range instead of
raising, and log ERROR when a non-empty curve yields no usable close or the
seed is not a positive number, so a broken curve does not pass for
"pending" or "no variation". Pin the baseline side of the Live reader.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both boards sorted on sharpe_ratio alone, so a row showing "—" (an old
payload's hourly number, or an ok row missing a bound) sorted by a hidden
value. Sort keys now follow the formatter. Both formatters also stop
printing "-0.00" and stop inventing "Based on 0 trading days" when the
payload omits sharpe_days. Escape num_trades and snapshot_end in the Live
detail pane.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sink

A board run off the published capital must give the same daily Sharpe
once rescaled (fails if the reader takes the unscaled curve). Hold the two
board formatters together on off-type payload values, and pin each Sharpe
interpolation inside escapeHtml/homeEscape by source, since no fixture can
show a missing escape while the formatters emit only numbers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
agentic-trading-lab Ready Ready Preview Oct 31, 2026 1:39am UTC

A Live row whose stored final value is NULL renders "—" in every cell,
but its Sharpe cell and detail still carried the "Based on N trading
days" tooltip and sorted by the hidden figure. Gate both on the row
having prints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both boards compute daily Sharpe per request, so one unreadable curve or
seed logged the same ERROR on every page load. Log each distinct break
once per process (bounded set), as live.py's _warned_live_config does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ender helper

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Live: a stored curve with no point on the month axis is pending with an
  ERROR (live.curve_unplottable, once per process), not a ranked flat line
  whose Sharpe reads "Returns never moved".
- Live: a row with no recorded seed is not rescaled, so E_0 is its own first
  mark, not display_capital (a $10k run read about -90% on day 1).
- A bad seed is status "undefined", logged from the first close rather than
  behind "Needs 5 trading days"; an account at or below 0 and overflow are
  "undefined" too, not "no_variation".
- liveFormatSharpe delegates to formatBoardSharpe; both boards sort through
  one boardSharpeValue predicate (no string building per comparison).
- Home rank row carries the interval in visually hidden text in the cell.
- CLAUDE.md: the Live GET rule names what it forbids, not "compute".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@FlyM1ss
FlyM1ss marked this pull request as ready for review October 31, 2026 02:40
@FlyM1ss
FlyM1ss merged commit f249507 into main Oct 31, 2026
10 checks passed
@FlyM1ss
FlyM1ss deleted the feat/board-daily-sharpe branch October 31, 2026 02:42
computedocean pushed a commit to computedocean/AgenticTrading that referenced this pull request Oct 31, 2026
Open-Finance-Lab#704 and Open-Finance-Lab#705 each fit under the ceiling against their own base;
merged together they put main at 40,004. Drop one redundant word
(39,994).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — 766984d2 Deployed Oct 31, 2026 by vercel[bot]
Sign up for free to 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.

2 participants