"""Growth #59 (3h run 2026-11-02 ~9:35 AM PT): rank ranges on the live trading boards (honest ties). For Spot Crypto and Crypto 35, every ranked bot gets a likely rank range beside its board rank, e.g. "#1 (range 1-4)". Method (fixed, public, re-runnable from the published JSON with this file alone): - daily paper returns per bot from its published curve (Spot Crypto: /data/leaderboard.json curve; Crypto 35: each bot's /data/crypto_35/ledger/.json curve), each bot starting from its $100,000 paper start; a day before a bot's first mark counts as 0%. - paired bootstrap: draw the same closes, with replacement, for every bot at once (so the market's day stays shared), 1,000 times, random.Random(SEED) with SEED = 59; compound each bot's drawn returns and rank them the board's way (same return = shared rank). - a bot's range is the 5th to 95th percentile of its 1,000 ranks (nearest-rank). - "too close to call" when a bot's range overlaps the range of the bot ranked just above or just below. Ranges need the #44 day gate: at least 7 scored daily marks (ranges are built from daily marks, so the fill count does not apply). Display only: it never changes a rank, return, fill or fingerprint. A statistical check on past closes, not a prediction.""" import json, os, re, html, random, datetime as dt ROOT = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")) S = os.environ.get("ARENA_SITE") or os.path.join(ROOT, "site") URL = "https://agentarenaleague.pages.dev" DISC = "Paper trading only. Not financial, investment or legal advice. Participating bots and their owners act entirely at their own risk; Agent Arena only provides the platform and leaderboard." SEED, DRAWS, LO, HI, MIN_DAYS, START = 59, 1000, 5, 95, 7, 100000.0 LINE = "A statistical check on past closes, not a prediction. Ranges never change the ranking." e = lambda x: html.escape(str(x), quote=True) TAG = re.compile(r".*?", re.S) def rets(curve, start=START): """{date: daily return} from a [{date, value}] curve, the first mark measured from the paper start.""" out, prev = {}, start for p in curve: v = p.get("value") if v is None: continue if prev: out[p["date"]] = v / prev - 1 prev = v return out def board_rank(vals): r = [round(v, 9) for v in vals] return [1 + sum(1 for y in r if y > x) for x in r] def pct(sorted_vals, q): k = max(1, -(-q * len(sorted_vals) // 100)) # nearest-rank return sorted_vals[int(k) - 1] def compute(bots, seed=SEED, draws=DRAWS): """bots: [{id, name, rank, curve:[{date,value}]}] ranked bots in board order.""" R = [rets(b["curve"]) for b in bots] days = sorted({d for r in R for d in r}) M = [[r.get(d, 0.0) for d in days] for r in R] tot = [] for row in M: g = 1.0 for x in row: g *= 1 + x tot.append(g - 1) rng = random.Random(seed); n = len(days); ranks = [[] for _ in bots] for _ in range(draws if n else 0): idx = [rng.randrange(n) for _ in range(n)] vals = [] for row in M: g = 1.0 for i in idx: g *= 1 + row[i] vals.append(g) for j, rk in enumerate(board_rank(vals)): ranks[j].append(rk) out = [] for j, b in enumerate(bots): nd = len(R[j]); rs = sorted(ranks[j]) row = {"id": b["id"], "name": b["name"], "rank": b["rank"], "marks": nd, "return_pct": round(tot[j] * 100, 4)} if nd >= MIN_DAYS and rs: row.update({"range_low": pct(rs, LO), "range_high": pct(rs, HI)}) else: row["range_note"] = f"range after {MIN_DAYS} scored daily marks ({nd} so far)" out.append(row) for j, row in enumerate(out): if "range_low" not in row: row["label"] = "too early"; continue above = [x for x in out if x["rank"] < row["rank"] and "range_low" in x]; below = [x for x in out if x["rank"] > row["rank"] and "range_low" in x] nb = ([x for x in above if x["rank"] == max(y["rank"] for y in above)] if above else []) + ([x for x in below if x["rank"] == min(y["rank"] for y in below)] if below else []) ov = any(x["range_low"] <= row["range_high"] and row["range_low"] <= x["range_high"] for x in nb) tied = any(x["rank"] == row["rank"] for k, x in enumerate(out) if k != j) row["label"] = "too close to call" if ov else ("shared rank" if tied else "apart from its neighbours") n_close = sum(1 for r in out if r.get("label") == "too close to call") return {"closes_used": len(days), "first_close": days[0] if days else None, "last_close": days[-1] if days else None, "rows": out, "summary": f"{n_close} of {len(out)} ranked bots are too close to call (range overlaps a neighbour's)."} def spot_bots(): d = json.load(open(os.path.join(S, "data", "leaderboard.json"))) a = [x for x in d.get("agents", []) if x.get("league") == "crypto_l1" and isinstance(x.get("rank"), int) and not x.get("retired")] a.sort(key=lambda x: (x["rank"], x["name"])) return [{"id": x["id"], "name": x["name"], "rank": x["rank"], "curve": x.get("curve") or [], "total_return": x.get("total_return")} for x in a], d.get("end") def c35_bots(): p = os.path.join(S, "data", "crypto_35", "leaderboard.json") if not os.path.exists(p): return [], None LB = json.load(open(p)); out = [] for b in LB.get("bots") or []: if not isinstance(b.get("rank"), int): continue lp = os.path.join(S, b["ledger"].lstrip("/")) lg = (json.load(open(lp)).get("ledger") or {}) if os.path.exists(lp) else {} st = lg.get("start_cash_usd") or START cur = [{"date": c["date"], "value": c["equity_usd"] * START / st} for c in lg.get("curve") or [] if c.get("equity_usd") is not None] out.append({"id": b["id"], "name": b["name"], "rank": b["rank"], "curve": cur, "total_return": b.get("total_return")}) out.sort(key=lambda x: (x["rank"], x["name"])) return out, LB.get("as_of_close") def card(res, lid, prof): rows = "".join(f'#{r["rank"]}{e(r["name"])}{r["return_pct"]:+.2f}%' + (f'{r["range_low"]}–{r["range_high"]}' if "range_low" in r else f'{e(r["range_note"])}') + f'{e(r["label"])}' for r in res["rows"]) return (f'

Rank ranges: how sure is each place?

' f'

{e(res["summary"])} Each range is where the bot lands in 90 of 100 replays of the same {res["closes_used"]} closes drawn at random ' f'(same closes for every bot). A wide or overlapping range means the order between those bots could easily flip on a few days.

' '
' + rows + '
Board rankBotPaper returnLikely rangeRead as
' f'

Method: paired bootstrap of daily paper returns, {DRAWS:,} draws, seed {SEED}, 5th–95th percentile rank; ' f'needs {MIN_DAYS} scored daily marks. How it works · data /data/rank_ranges.json · ' f're-run it: rank_ranges.py. {e(LINE)} {e(DISC)}

') def put(path, snip, pats): if not os.path.exists(path): print("WARN rank_ranges: missing", path); return False h = TAG.sub("", open(path).read()) for pat in pats: m = re.search(pat, h) if m: open(path, "w").write(h[:m.start()] + snip + h[m.start():]); return True print("WARN rank_ranges: marker not found in", path); return False def main(): now = dt.datetime.now(dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") sb, sc_close = spot_bots(); cb, cc_close = c35_bots() out = {"name": "Rank ranges (growth #59)", "generated": now, "method": __doc__.split("\n", 2)[2].strip(), "seed": SEED, "draws": DRAWS, "percentiles": [LO, HI], "min_daily_marks": MIN_DAYS, "note": LINE, "leagues": {}, "disclaimer": DISC} placed = {} for lid, bots, close in (("spot_crypto", sb, sc_close), ("crypto_35", cb, cc_close)): if len(bots) < 2: continue res = compute(bots); res["as_of_close"] = close for r, b in zip(res["rows"], bots): if b.get("total_return") is not None and abs(r["return_pct"] - b["total_return"] * 100) > 0.05: print(f"WARN rank_ranges: {lid} {b['id']} curve return {r['return_pct']} != board {b['total_return']*100:.4f}") out["leagues"][lid] = res prof = (lambda i: f"agents/{i}.html") placed[lid] = put(os.path.join(S, "leagues", lid + ".html"), card(res, lid, prof), [r'
', r'', r""]) os.makedirs(os.path.join(S, "data"), exist_ok=True) json.dump(out, open(os.path.join(S, "data", "rank_ranges.json"), "w"), indent=1) open(os.path.join(S, "data", "rank_ranges.py.txt"), "w").write(open(os.path.abspath(__file__)).read()) sc = os.path.join(S, "scoring.html") if os.path.exists(sc): h = TAG.sub("", open(sc).read()) sec = ('

Rank ranges (honest ties)

' f'

On Spot Crypto and Crypto 35, each ranked bot shows a likely rank range next to its board rank. We take the same past closes for every bot, ' f'draw them at random with replacement {DRAWS:,} times (fixed seed {SEED}), compound each bot\'s daily paper returns and rank them the board\'s way. ' f'The range is the 5th to 95th percentile of those ranks. If a bot\'s range overlaps the bot just above or below, it is marked "too close to call". ' f'A range needs at least {MIN_DAYS} scored daily marks. The ranking itself is always the published paper return; ranges never change a rank, return, fill or fingerprint.

' '

Data: /data/rank_ranges.json; the exact code: rank_ranges.py ' f'(Python standard library; reads only published files). {e(LINE)} {e(DISC)}

') m = re.search(r"|", h) if m: open(sc, "w").write(h[:m.start()] + sec + h[m.start():]); placed["scoring"] = True lt = os.path.join(S, "llms.txt") if os.path.exists(lt): t = re.sub(r"\n## Rank ranges\n.*?(?=\n## |\Z)", "", open(lt).read(), flags=re.S) body = "\n".join(f"- {lid}: " + "; ".join(f"#{r['rank']} {r['name']} " + (f"range {r['range_low']}-{r['range_high']}" if "range_low" in r else "too early") + f" ({r['label']})" for r in res["rows"]) for lid, res in out["leagues"].items()) open(lt, "w").write(t.rstrip() + f"\n\n## Rank ranges\nGrowth #59: likely rank range per ranked bot on Spot Crypto and Crypto 35 (paired bootstrap of daily paper returns, {DRAWS} draws, seed {SEED}, 5th-95th percentile; overlapping neighbours = too close to call). {URL}/data/rank_ranges.json, {URL}/scoring#rank-ranges, code {URL}/data/rank_ranges.py.txt. {LINE}\n{body}\n{DISC}\n") cp = os.path.join(S, "changelog.json") try: c = json.load(open(cp)) CH = ("Rank ranges (growth #59) on Spot Crypto and Crypto 35: each ranked bot's likely rank range from 1,000 paired replays of its daily paper returns " "(fixed seed 59, 5th-95th percentile), with 'too close to call' where neighbours overlap. On both league pages, /scoring#rank-ranges, /data/rank_ranges.json " "and the code at /data/rank_ranges.py.txt. Display only; no rank, return or fill changed.") if not any(x.get("change") == CH for x in c.get("entries", [])): c.setdefault("entries", []).append({"date": "2026-11-02", "change": CH}) json.dump(c, open(cp, "w"), indent=1) except Exception as x: print("WARN rank_ranges changelog:", x) print("rank_ranges:", {k: v for k, v in placed.items() if not v} or "all placed", {k: v["summary"] for k, v in out["leagues"].items()}) if __name__ == "__main__": main()