For the last couple of months I've been running Polybot — an AI-powered prediction-market trading bot — continuously on a Raspberry Pi 5 sitting on my desk. It scans Polymarket, finds markets where the crowd has priced something obviously wrong, and buys the correct side. Total cost to run: about $21 a month in API fees plus whatever the Pi pulls from the wall.
This post is about how that actually works — the architecture, the async Python patterns, and the operational stuff that makes "runs 24/7 on a $35 computer" a real claim instead of a bumper sticker.
Why a Pi?
I could have dropped it on a $5/month VPS. I chose the Pi for three reasons. First, I wanted the constraint — if the whole bot fits comfortably on 4 ARM cores and 8 GB of RAM, it's going to be lean by construction. Second, everything stays on my own network: no cloud bill creep, no vendor lock-in, no surprise egress fees when the WebSocket feeds get chatty. Third, I can see it. The green light blinking on my desk is a better monitoring tool than any dashboard, because the moment it stops blinking I notice.
The trade-off is that a Pi is not a production environment. It reboots when the power flickers. SD cards wear out. The network can drop. Any bot that ran well on a Pi had to be written assuming everything is unreliable — which, as it turns out, is exactly how you should write trading code anyway.
The architecture that fell out of that constraint
The bot runs three detection tiers in parallel, each optimized for a different speed-vs-depth trade-off:
- The Sniper (45 seconds): polls for new markets, instantly trades obvious mispricings. No AI call, no LLM cost.
- The RSS Fast Lane (2 minutes): 24 news feeds trigger whale-signal analysis when a headline moves.
- The Full Pipeline (5 minutes): three-agent AI sequence — Alpha Scout filters 400+ markets down to 40, Beta Analyst fetches news and whale activity in parallel, Gamma Judge (DeepSeek) estimates true probability and decides BUY_YES / BUY_NO / SKIP.
The insight was that the obvious mispricings don't need AI. "Will Tunisia win the 2026 World Cup?" trading at 50/50 is a button press, not a research project. The Sniper catches those with pattern matching — no tokens spent — and the edge usually corrects in minutes. That leaves the AI pipeline to do the harder work on markets that actually require reasoning.
Three tiers, three very different cost profiles. The Sniper costs $0 per scan. The AI pipeline costs fractions of a cent. That's how the whole bot runs on ~$21/month in API fees while still evaluating hundreds of markets a day.
Everything is async, and that matters on a Pi
The bot is Python 3.11, fully asyncio. There's one event loop and a collection of background tasks — a market scanner, a position monitor, a Telegram listener, a WebSocket order-book feed, a news poller, a whale tracker. None of them block each other.
On a Pi this is not optional. If the market scanner blocks the event loop while it waits on a slow API response, the position monitor can't check for trailing-stop exits, the WebSocket drops behind, and the Telegram bot stops responding to my commands. A single synchronous requests.get() call in the wrong place would cascade into "my bot froze" every few hours. Async means one slow response just yields control — everything else keeps moving.
Some practical patterns that made a real difference:
- Deduplication locks around order placement. If a scan fires twice while the previous order is still confirming, I don't want two positions. An
asyncio.Lockper market prevents it. - FOK (fill-or-kill) semantics on entries. The bot won't hold a partial fill. Either it gets the full position or it walks away — no half-legged trades sitting around.
- Persistent state everywhere. If the Pi reboots mid-scan, the bot has to come back up knowing exactly what positions it holds, what orders are in flight, and what markets it's in a re-entry cooldown on. Everything material goes to disk synchronously.
Risk management in code, not in vibes
A bot that runs 24/7 without supervision will absolutely find a way to lose money if you don't write the guardrails into the code. Polybot's are all config-tunable and enforced at the position-manager level:
- Max 15% of capital per trade, half-Kelly sized and scaled by AI confidence
- 35% stop-loss, 50% take-profit, trailing stop activates at +15% and trails 10% from peak
- 10% daily loss limit — bot halts for the day if hit
- Drawdown protection: once account is down 10%, sizing drops to quarter-Kelly
- 2%/day confidence decay on open positions — forces re-evaluation of stale theses
- 24-hour re-entry cooldown per market so I can't keep buying the same mispricing
All of these are parameters I can tune over Telegram at runtime with /set <param> <value>. Which brings me to the operational side.
Remote monitoring with Telegram
The Pi doesn't have a screen. I manage the bot entirely through a Telegram chat with it. There are about 20 commands, but the ones I actually use every day are small:
/status— portfolio summary: capital, open positions, P&L, last scan time/positions— every open position with entry price, current price, unrealized P&L/pnl— realized P&L broken out by exit reason (take-profit, stop, trailing, thesis-change)/pauseand/resume— stop new entries without touching existing positions/closeall— panic button
Telegram is overkill for this. But it's also perfect. It's already on my phone. It has push notifications. Every command produces a message I can scroll back through later. The bot posts proactively when it enters or exits a position, so I find out about trades before I check the dashboard. A $0 monitoring stack that works from anywhere in the world.
Deploying to the Pi
Deploying is one command:
bash deploy.sh — rsync's the code over SSH, runs a Python syntax check, restarts the systemd service, and does a health check. If the health check fails it rolls back to the previous version. A watchdog.sh script supervises the service and auto-restarts on crash. systemd does the rest.
Between rsync deploys, systemd auto-restart, and persistent state, the bot has survived a handful of crashes, two router reboots, and one power outage without my intervention. That's the bar I was aiming for: if I go on vacation, I don't need to think about it.
What I'd tell you if you wanted to try this
Three things I'd hand to someone starting from scratch:
Write it async from day one. Retrofitting async into a bot that started synchronous is brutal. If you know the bot is going to do more than one thing concurrently — and it will — start with asyncio and never look back.
Paper-trade before you fund. Polybot has been in paper mode since February. That isn't because I'm cautious for its own sake. It's because I want 50+ simulated trades with realistic slippage (300 bps entry / 400 bps exit plus volume-scaled impact) before I'm willing to claim the edge is real. Paper mode also reveals the boring bugs — off-by-one position-sizing errors, stale-price exits that fire on the wrong side — before they cost money.
Write the risk logic first, the signal logic second. I built the position manager, the stop-loss machinery, and the daily loss limits before I wrote a single line of market-scanning code. If the bot tells me it has an edge but the risk code is half-baked, I'm not going to fund it. Putting the guardrails in first makes the signal work feel less like gambling and more like engineering.
What's next
The bot has been paper-trading for two months and the edge on meme-market mispricings has held up across ~200 simulated trades. The next step is live deployment with a small amount of real capital — $300 starting, matching the paper-mode configuration — and seeing whether the simulated slippage model was honest. If it holds for 50+ live trades, I'll scale up. If it doesn't, I go back to the drawing board and figure out which assumption broke.
The architecture I've described here also generalizes. Four of my other trading bots — fdabot (FDA drug approvals), govbot (federal contracts + SEC filings), insiderbot (SEC Form 4 cluster buys), and usdabot (USDA commodity releases) — share the same poll-filter-analyze-trade skeleton. Swap the data feeds, swap the AI prompts, keep the risk engine. That's the real value of getting the architecture right once: the next bot costs a fraction of what the first one did.