Letter #130 — 2026-04-18
Facts
- Session 311 (on-demand, triggered by Lucas Telegram "you back" 8:59 PM ET)
- Current ET: 9:02 PM (April 18, 2026)
- Model: Opus 4.7
- Prior session #418 closed clean at 5:25 PM ET (answered Lucas's confidence question)
- Two messages from Lucas queued in processed/: 6:02 PM ("Great build the live run and it should run 1:1 with the dry run so we can compare them") + 8:59 PM ("you back")
- MM state: bankroll $731.94, total P&L +$231.94 (+46.4%), 29 days live (dry run)
- Polymarket proxy wallet USDC: $0.12 (needs funding)
Session Intent
On-demand + operational. Lucas greenlit live MM build. Build it: parity fixes + USDC reconciliation + systemd install. Do NOT start the service — wait for Lucas fund + go. Don't expand scope beyond this.
What's Next
- Apply parity fixes to btc_marketmaker_live.py
- Build USDC reconciliation (startup sync + periodic check)
- Install systemd unit (btc-marketmaker-live.service), leave stopped
- Wait on Lucas: funding + sizing decision ($10 vs $5 quote)
Composting
- None this session.
What's Unfinished
- Pre-live USDC reconciliation: IN PROGRESS
- Live bot go-live: blocked on Lucas funding + explicit go
- BTC production zombie: 30-min redemption cron continues (unchanged)
Stream
8:59 PM ET — Boot
Wake triggered by Lucas Telegram "you back". Earlier at 6:02 PM he said: "Great build the live run and it should run 1:1 with the dry run so we can compare them." Session type: on-demand → responsive + build. No news/essays/exploration.
9:00 PM ET — Audit
Live file btc_marketmaker_live.py already exists (819 lines, edited 4/14). Full py-clob-client integration, kill switch (file + state), daily loss limit $20, "dry run shadow" random simulation for inline comparison. Systemd unit file exists in project dir but NOT installed.
Parity gaps vs dry run:
- MIN_WINDOW_REMAINING: 90 (live) vs 60 (dry) — live enters fewer windows, breaks 1:1 comparison
- QUOTE_SIZE: $5 (live) vs $10 (dry)
- MAX_POSITION_PER_SIDE: $20 vs $50 (safety — keep)
- INITIAL_BANKROLL: $100 vs $500 (safety — keep)
Safety gaps:
- No USDC wallet reconciliation. Bankroll is virtual tracker. If CTF fails to redeem → wallet drains, tracker shows phantom. Same bug class that killed BTC production (drained to $0.36 over 15 days from batch-keeper-burn).
Funding: proxy wallet 0x9E87... has $0.12 USDC. Needs Lucas to send USDC on Polygon.
9:02 PM ET — Sent Lucas the plan
Telegram: status, two parity gaps, one safety gap, build plan (~45 min), two calls to him (fund, sizing). Service stays stopped until his explicit go.
9:03–9:05 PM ET — Built
- Parity:
btc_marketmaker_live.py— MIN_WINDOW_REMAINING 90→60, QUOTE_SIZE $5→$10. Same entry/exit logic as dry. - USDC reconciliation: added
check_usdc_balance()+reconcile_bankroll(). Startup path: if fresh state, caps bankroll at min(on-chain, INITIAL_BANKROLL). If resume, runs reconciliation. Periodic path: every 20 resolved windows, re-queries on-chain USDC, compares against tracker. If drift > 5% AND > $2 → activates kill switch + writes.mm_kill_switchfile. - Tested: smoked the reconcile function against the real CLOB client. Correctly detected tracker=$50 vs on-chain=$0.12 and halted. Cleaned up the test kill file.
- Systemd: copied
btc-marketmaker-live.serviceto/etc/systemd/system/, daemon-reload, enabled. NOT started.is-active → inactive,is-enabled → enabled.
9:05 PM ET — Pinged Lucas build complete
Summary + remaining asks (fund wallet + sizing confirm). Waiting.
Worth noting: the 25%-of-bankroll safety cap in live means at $100 bankroll, quote cost is limited to $25 (so 10-share quote at combined_cost≤$0.95 = $9.50 — fits). Parity with dry holds for bankroll ≥ $40. Below that, live sizes smaller. That's fine — it's safety, not a logic divergence.
9:07–9:09 PM ET — Self-review + hardening
Found an issue in my own reconciliation: halt thresholds (5%+$2) would false-positive on unredeemed CTF tokens. Batch keeper + 30-min redemption cron can leave $5-30 of unredeemed CTF sitting as "value in wallet but not USDC" between runs. That's normal drift, not a leak.
Fixed:
- Raised halt thresholds to >30% AND >$15 absolute.
- Added WARN tier at >10%.
- Added "sustained breach" requirement: only halts if 3 consecutive periodic checks all breach halt-threshold. Single spike won't trigger.
- Startup path is stricter: halts immediately on first breach (fresh session shouldn't have redemption-lag drift).
- Tested 3 cases against real client: small drift → WARN not halt; large drift first call → no halt; large drift 3x → halts. Works.
Added preflight command: runs all pre-start checks (creds, SOCKS, CLOB, USDC ≥$10, state, kill switch) and prints config. Lucas can run btc_marketmaker_live.py preflight before go. Currently shows 4/5 passed (failing only on USDC < $10).
Added compare_mm_live_vs_dry.py: reads both state files, matches overlapping window_ids, reports fill-type agreement %, P&L delta, fill-type distribution. This is the actual 1:1 comparison tool for once live has run.
9:07 PM ET — Lucas: "this is for the market maker strat?"
Confirmed: yes, MM. Not the BTC directional bots. Replied with that + the funding address again.
9:15 PM ET — Also wired MAX_OPEN_ORDERS enforcement
While checking for unused safety constants, noticed MAX_OPEN_ORDERS=4 was defined but never enforced. Added the check in place_mm_orders: counts live open orders, skips the window if ≥ 4. Protects against runaway accumulation if market resolution stalls (API outage, batch keeper delay). This is a live-only cap (dry run doesn't have it) — safer-direction divergence from 1:1, acceptable. MAX_POSITION_PER_SIDE=$20 is still display-only (trivially satisfied given QUOTE_SIZE=$10).
9:14 PM ET — Pre-funding blocker found
Checked all polymarket-algo services: btc-production.service is ACTIVE. Its log shows ORDER FAILED every ~5 min with "not enough balance / allowance: balance: 117083, order amount: 2550000-3650000". Meaning: production is still trying to place directional bets, failing only because wallet has $0.12.
If Lucas funds $100, production WILL grab $2-4 per trade, competing with MM on the same wallet. This would make the 1:1 comparison noisy AND risk double-spend reconciliation drift immediately on live start.
Flagged to Lucas. Recommended stopping btc-production before funding (it's the dead strategy we discussed). Awaiting his call.
9:10–9:12 PM ET — More hardening while holding
- Added reconciliation history block to
statusoutput (last 5 reconciliations with drift, breach flag). - Real bug found in review: Polymarket CLOB minimum order size is 5 shares (confirmed in
weather_live.py:72andbtc_production.py:1121). My MM live code allowedquote_shares=1. Would have hit rejected orders immediately. Fixed: addedMIN_ORDER_SHARES=5+ skip check inplace_mm_orders. - Wrote
MM_LIVE_RUNBOOK.md— start/stop/halt/restart steps, monitoring commands, known caveats. Next session (or Lucas) can follow it cleanly. - Saved KB #2693 (min order size), KB #2694 (reconciliation noise floor).
- Extracted principle #111 (halt thresholds above noise floor, sustained breach required).