P2P Spread Bot: Smart Arbitrage AI
P2P crypto arbitrage lives and dies on speed. The spread between buy and sell offers across exchanges opens, widens, and closes in minutes. In 2021, the traders we were building for were scanning 25 exchanges by hand — refreshing tabs, pasting prices into spreadsheets, and executing before the window collapsed. It was not sustainable.
The problem
Manual P2P price scanning across 25 exchanges is a grind that scales badly. A trader can realistically watch four or five order books at once. At 25, the interesting spreads — the ones between a mid-tier exchange with thin liquidity and a major one with deep order books — go unnoticed. By the time someone spots a gap, someone else has already closed it.
The deeper problem is not just speed. It is risk. A wide spread is not always an opportunity. It can signal a withdrawal freeze, a counterparty about to default, or a payment method that is about to be blocked. A trader who only sees the number, not the context, takes on risk they do not understand. We needed a system that surfaced spreads fast and explained why each one existed.
Approach
We split the work into three layers: an async scraper, a forecasting model, and a risk explainer. Each layer does one thing and hands structured output to the next.
The scraper is built on Python with Selenium and BeautifulSoup. It runs asynchronously across all 25 exchanges, pulling order book snapshots, payment method flags, and counterparty reputation data every three minutes. Selenium handles the exchanges that load prices dynamically; BeautifulSoup parses the static ones. The async design matters — a synchronous loop over 25 exchanges takes longer than the three-minute refresh window, which means you are always looking at stale data.
The forecasting layer uses Prophet, Facebook's time-series library. It takes the historical spread data the scraper has accumulated and predicts where the spread is likely to move in the next cycle. This is not a trading signal on its own — it is a filter. A spread that is wide and predicted to widen is more interesting than one that is wide and already closing.
The risk explainer is where the LLM earns its keep. We feed OpenAI the raw spread data, the Prophet forecast, and the contextual signals — payment method availability, counterparty rating, recent withdrawal status. The model returns a plain-language explanation: why this spread exists, what could go wrong, and whether the opportunity is worth the execution risk. The trader gets a number and a reason, not just a number.
What was built
A Telegram bot that serves as the trader's interface. It pushes alerts when a spread crosses a threshold, responds to queries about specific exchange pairs, and generates a daily summary of closed opportunities. The bot talks to the scraper, the Prophet model, and the OpenAI explainer through a simple internal API. Traders interact in Telegram because that is where they already are — no separate app to install, no dashboard to check.
The stack: Python for the orchestrator and scraper, Selenium and BeautifulSoup for exchange parsing, Prophet for spread forecasting, and OpenAI for risk narration. Everything runs on a single VPS with a cron-driven refresh cycle.
Results
The pilot group saw ROE increase by roughly 6 percentage points over the trial period. The system scanned all 25 exchanges every three minutes, which meant traders were looking at current data, not a snapshot from ten minutes ago. Manual checks dropped to near zero — the bot surfaced the opportunities, and the trader's job shifted from scanning to executing.
The Prophet forecast was the unexpected win. Traders started using the predicted spread direction to time their entries, not just to filter alerts. The risk explanations from OpenAI reduced a specific failure mode: traders no longer chased spreads that looked good but sat on exchanges with frozen withdrawals or flagged payment methods.
Takeaway
Arbitrage is a speed and context problem, not just a math problem. A system that scans fast but does not explain risk produces confident losses. A system that explains risk but scans slowly produces missed opportunities. The useful version does both — fast structured data, a forecast to filter, and an LLM to narrate the risk in terms a trader can act on. The LLM is not making the trade decision. It is translating a pile of signals into a sentence the trader can read in three seconds and decide whether to act.
