The sharps table's P&L was reconstructed from won×entry×size and diverged
from PM /profit by up to 10x, with sign flips — four root causes found by
decomposing outliers against PM:
1. bets pull capped at 2000 rows/180d -> high-volume wallets truncated
(ewww1: 740 of 4088 positions cached -> k shown vs k real)
2. both-sides (hedged) markets: one-per-market dedup dropped the paired
side (suraxy: -k of dropped losing legs -> overcount)
3. initialValue=0 on big longshot winners -> mis-sized reconstruction
4. corrupt near-epoch res_t rows polluting sums
Fix: All-Time/Conv/30d P&L are now the sum of Polymarket's OWN realizedPnl
per closed position over FULL history (cache.closed_exits, extended to store
realized_pnl; smart_money.closed_exits captures it + relaxes the avg/tb
guard). This is the wallet's realized track record — what a copier mirroring
buy/sell/hold banks — and sums to PM. Immune to all four bugs (each asset is
its own realized row; no size/entry/res_t needed). Win% = share of closed
positions that made money. Verified vs PM: ewww1 1.00x, KBO30 0.0x->0.97x,
suraxy 2.7x->1.03x, sign flip fixed; oliman2 1.63x is correct-by-design
(realized track record vs PM's open-book unrealized marks). README gotcha 11
rewritten; dashboard tooltips reframed off the copy-ceiling language.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Per the data-completeness call: closed_exits pulls each wallet's ENTIRE
closed-position history, not a 180d window. smart_money.closed_exits returns
(exits, reached_end) — reached_end True only when the pull hits the true
start of history (empty/short page), so the cache's flag tells a
finished backfill from an interrupted one and a killed deep pull re-completes
instead of falsely reporting done. One-time deep cost, amortized by the
incremental cache (later runs page only new closes). Verified: imwalkinghere
full 65d lifetime (879 exits, its real age not a cap), complete=True, 2nd
call 0.00s.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The row cap was the wrong instrument — it could truncate a hyperactive
wallet's window (compromising data) while the real fix is bounding by DATE.
cache.closed_exits now pulls exactly the 180d window the bets cache scores,
so the exit overlay COMPLETELY covers every bet the sharps/backtest stats
touch. Tracks oldest_ts so an interrupted backfill re-completes instead of
falsely reporting done; once complete, refreshes only page new closes.
since_ts (180d/30d per caller) is the real bound — this fixes completeness
AND the runtime stall (the old since_ts=0 pulled all-history). Verified:
imwalkinghere full window in 9s, 2nd call 0.00s cached.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The 25k-row (500-page) full-history backfill × 90 sharp wallets stalled the
daily pipeline for 4+ hours on its first uncached pass. 4000 rows (80 pages)
covers the 30d backtest and most of the 180d display window; the exits cache
is incremental so the horizon extends on later runs. Extreme scalpers keep a
hold-to-res ceiling on their deepest history (honest, and none are followed).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
_handle_their_buy referenced their_prev in the fresh-OPEN branch but only
assigned it in the is_add branch — every new position crashed with
UnboundLocalError the moment the their-bet ceiling landed 2026-07-06. The
webhook/heartbeat try/except swallowed it as 'handler error', so the bot
logged FOLLOW then silently placed NOTHING (last real fill 07-05 23:17;
live Fly logs show FOLLOW ArbTrader ... -> heartbeat error: their_prev).
This is the primary cause of 'live bot missing bets'. Fix: hoist their_prev
above the if/else so both branches see the signal's prior position.
Also (the user's two asks):
- copybot on_wallet_activity: a QUALIFYING bet we were too slow to catch
(webhook missed / bot down / fast market resolved before we polled) is now
recorded as a missed bet 'too slow to follow (Nm late)' instead of silently
dropped; below-floor dust stays console-only. Filter runs before the stale
gate so we know if it would have qualified.
- sync_floors.py rewritten: PIN each paper-bot wallet's floor to the trusted
cache p80 (identical to the backtest's conv_thr), written to
copybot.paper.json, wired into daily.sh + committed. Kills the boot-time
data-api floor drift (fortuneking $1,498 boot vs $892 backtest) that made
the live bot filter out bets the backtest kept.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The key does not belong in any committed file — the worker reads the RPC
from ALCHEMY_RPC_URL env (or the gitignored config.json locally). Rotating
the key is the real fix (it hit the public repo history); this removes it
from HEAD.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
config.live.json is gitignored (holds the key) so the Fly worker can't see
it. This committed twin carries the synced 8-wallet follow set + $5 test
caps + separate feed/fills; the worker reads it and injects the key via
LIVE_PRIVATE_KEY env (copybot 1.2). Mac path: cp to config.live.json, fill
the key. Fixes 'stale shisan888 follow set' + the cloud-config gap.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
copybot.py:
- 1.1 feed_path/fill_log are config-driven (live run won't clobber the
paper book's feed or fills ledger)
- 1.2 LIVE_PRIVATE_KEY / LIVE_FUNDER_ADDRESS / LIVE_SIGNATURE_TYPE env
overrides (Fly worker has no gitignored config.live.json)
- 1.4 chain_cash_gap(): live-only book-cash vs CLOB USDC balance, logged
as ⚠ CASH≠CHAIN (the real-money ledger_drift)
- 1.5 geo-gate is FATAL in live mode — unauth order probe; refuses to arm
from a 403-geo-blocked box before the confirm phrase (verified: refuses
from this US Mac)
- 1.6 mirror-exit retry: FAK sells that fill 0 on thin books retry each
backstop poll, ⚠ EXIT STUCK alert after 10 unfilled attempts
discord_daily.py: --ping retries 4x (5/10/15s) — launchd wakes the Mac to
run daily.sh and the heads-up ping was racing DNS/WiFi coming up after
sleep (getaddrinfo 'nodename nor servname'); the end-of-run digest always
landed, only the start ping lost the race.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
/closed-positions serves 50-row pages regardless of limit; stepping by the
requested size truncated every wallet's exit history to its most recent ~50
closes (1% coverage for hyperactive wallets) — sold-mirroring was silently
falling back to the hold-to-res ceiling almost everywhere. Now: page by
returned size, cache exits incrementally in duckdb (immutable events —
deep backfill once, a page or two per refresh; title/outcome columns for
display). Deep-exit 30d replay: $18,270 (+1727%), 259W/79L/29R/284S,
misses 253 -> 1 (mirrored exits recycle capital as fast as the signal does).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
smart_money.closed_exits() is now the shared implementation (backtest +
sharps): close time from /closed-positions, exit price reconstructed from
realized P&L. validate_timing's conv/conv30/all-time/realized tallies count
a bet the wallet sold pre-resolution at its exit price (conv_sold /
conv30_sold / all_sold fields) instead of pretending it rode to resolution.
Beyond the ~4000-row data horizon exits fall back to hold-to-res.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The replay held everything to resolution while the live bot mirrors exits —
two different strategies wearing one dashboard. Now, when a followed wallet
fully closed a position pre-resolution, the replay sells there too: close
time from /closed-positions, exit price reconstructed as
avgPrice + realizedPnl/totalBought, exit taker fee + slippage haircut paid.
Complete in-window round trips on unresolved markets (entered AND exited —
previously invisible to the replay) are included; on-chain-resolved conds
are excluded from round-trip synthesis so redeems can't masquerade as
sells. Sold legs count apart from W/L/R (they're price events, not
outcomes): 30d now 226W/55L/84R/31S, $12,730 (+1173%) — mirrored exits
bank the wallets' early profit-taking that hold-to-resolution left behind.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>