bot-monitor — Log watcher and Telegram alerts
Tails every poly5m / poly15m log, dedupes events, pushes Telegram alerts. Three modes: live monitor, --report stats summary, --pnl reconciliation against CLOB trade history (with --watch loop).
| Strategy type | Utility |
|---|---|
| Asset | All |
| Timeframe | — |
| Market type | All Polymarket markets |
| Minimum capital | $0 |
| Dependencies |
What it does
bot-monitor is the observability backbone for the entire scalper fleet. Run it once and it tails every poly5m and poly15m log file, parses the structured BUY / RESOLVED / EXIT events, dedupes them across restarts, and pushes formatted messages to Telegram. None of the scalping bots emit anything to Telegram on their own, so this process is what makes the fleet visible.
The edge
Centralizing alerts is not a vanity feature. Putting Telegram inside each bot would mean eight processes each holding a HTTPS socket to Telegram, eight dedupe states to keep in sync, and any Telegram outage tying up a bot's main loop. With bot-monitor, the bots write structured lines to disk at zero cost and a single watcher handles dedupe, rate limits, retries, and the (rare) Telegram outage. The bots stay focused on trading.
How it works
The script knows about every bot in the suite via the BOTS registry. For each one it tracks:
logFile: rolling log written by the botstatsFile: JSON the bot updates on every cycleresolvedFile: JSON the bot appends to on resolutionlockFile: PID file so the monitor can tell if a bot is alive
Four modes, selected by CLI flag:
- monitor (default): tail every log file simultaneously. New BUY / WIN / LOSS / EXIT lines get parsed, deduped against the prior tail position, and pushed to Telegram.
- --report: one-shot summary of every bot's balance, PnL, win count, loss count, open positions. Sent to Telegram and stdout. Good from cron once a day.
- --pnl: queries Polymarket's trade-history API for the wallet and reconciles every fill against the bot's self-reported PnL. Catches drift between optimistic logging and on-chain reality.
- --pnl --watch: same as --pnl but loops every 5 minutes.
The --reset flag wipes the dedupe state and re-emits the next event from each log, useful when alerts have drifted out of sync with reality.
Sample output
[25/05/2026, 15:57:14] [Resolution] 15m-sniper: WIN btc-updown-15m-2026-05-25-1557 → $4.85 | Bal: $26.35 [25/05/2026, 15:58:02] [Resolution] 15m-v6: EXIT btc-updown-15m-2026-05-25-1545 → loss $-4.21 [25/05/2026, 15:58:02] TG sent ✓ [25/05/2026, 16:02:14] [Resolution] 15m-sniper: WIN btc-updown-15m-2026-05-25-1600 → $5.12 | Bal: $31.47
Design targets
- Zero data loss: the dedupe state file (
data/monitor-state.json) is written atomically after every Telegram send - One Telegram call per resolution event, with HTTP 429 handling
- Survives restarts mid-event: re-reading the log from offset 0 is safe, dedupe drops what was already sent
- Heartbeat every 60s in monitor mode so you can tell the monitor itself is alive
FAQ
Why are the bots themselves not sending Telegram?
Earlier versions did. The result was double-sends after restarts, missed sends during Telegram outages that blocked the bot's main loop, and inconsistent message format across bots. Splitting it out fixed all three.
Do I need this if I only run one bot?
Probably yes. Even with one bot, the --pnl reconciliation catches log/reality drift you would otherwise only notice once a week when you reconcile manually. And you don't have to re-implement Telegram glue in the bot itself.
What's included
poly5m/bot-monitor.jspoly5m/scripts/monitor-run.sh(auto-restart wrapper)- README with Telegram bot setup, dedupe-state recovery, and a pm2 ecosystem.config.js example
Configuration
| Flag | Default | Description |
|---|---|---|
| --bot v4 | — | Monitor only specific bots, comma-separated (e.g. v4,v2). Default monitors all. |
| --report | — | One-shot stats dump → Telegram + stdout. Useful from cron. |
| --pnl | — | Verify realized PnL against the CLOB trade history. |
| --pnl --watch | — | Continuous PnL verification, polls every 5 minutes. |
| --date 2026-02-19 | — | Limit --pnl check to a single date. |
| --all | — | Include closed/archived bots in --pnl output. |
| --reset | — | Reset alert dedupe state. Re-emits the next event from each log. |
Related bots
poly5m-v4 — Split-window momentum BTC scalper
Buy-both-sides Gabagool on 5-min BTC. Picks up cheap YES + NO at $0.49 or less, locks profit when pair stays below $0.98. CLOB v2 / pUSD, polls books every 2s from 10s to 260s.
poly15m-v6 — Enhanced orderbook signal BTC scalper
Polymarket book + Chainlink RTDS + CVD + OFI + chop filter + trained meta-model. Needs 3 of 8 confirmation layers before FOK taker at $0.52. Quarter-Kelly with drawdown scaling, holds to resolution.
poly15m-sniper — Resolution sniper for 15-minute BTC markets
LIVEResolution sniper for 15-minute BTC binaries. Polls the book every 2s during the final 10s (T-15s to T-5s), fires FOK at up to $0.95 when one side trades mid ≥ $0.90. Goes 100% of cash per snipe.