A real-time arbitrage opportunity scanner that monitors spot prices across multiple cryptocurrency exchanges simultaneously and logs price discrepancies that meet a configurable profit threshold.
Note: This bot is a logging/detection tool only. It does not place any orders or move any funds.
- Fetches live bid/ask prices from 4 exchanges concurrently using
asyncio - Normalizes ticker symbols across exchanges into a unified format
- Identifies pairs available on more than one exchange
- Detects when the ask price on one exchange is lower than the bid price on another
- Logs every opportunity with the buy exchange, sell exchange, prices, and spread percentage
- Repeats every configurable interval (default: 5 seconds)
| Exchange | Method |
|---|---|
| Bybit | Official SDK (pybit) |
| MEXC | REST API |
| Gate.io | REST API |
| BingX | REST API |
On startup, the bot fetches all available spot pairs from every exchange and finds the intersection — pairs listed on at least two exchanges. This becomes the working list to monitor.
Every cycle, all four exchanges are queried simultaneously using asyncio.gather. Each exchange returns normalized dicts:
{"exchange": "bybit", "symbol": "BTCUSDT", "bid_price": 67200.0, "ask_price": 67205.0}Data is grouped by symbol. For each symbol, exchanges are sorted by:
- Best ask (lowest) — cheapest place to buy
- Best bid (highest) — most expensive place to sell
For each symbol, the spread is calculated:
spread = (best_bid - best_ask) / best_bid
If spread >= Minimum_Arbi (default: 0.5%), it's logged as an opportunity.
Currently logs to console. Designed to be extended with Telegram or other notification systems.
arbitrage_bot/
├── main.py # All logic — Config, Call, Exchange classes, Engine, Notify
└── requirements.txt
Inside main.py, edit the Config class:
class Config:
Check_Arbi_Interval = 5 # Seconds between each scan cycle
Minimum_Arbi = 0.5 # Minimum spread % to log as opportunitygit clone https://github.com/yourusername/arbitrage-scanner.git
cd arbitrage-scanner
pip install -r requirements.txt
python main.pyRequirements:
pybit
requests
Total eligible pairs to trade: 1435
==================================================================================================================================
Arbitrage opportunity Buy BTCUSDT for 67200.0 at gate_io and Sell at bybit for 67850.0 Arbitrage opportunity: 0.958%
Arbitrage opportunity Buy ETHUSDT for 3521.0 at mexc and Sell at bybit for 3548.0 Arbitrage opportunity: 0.761%
- Symbol collision: Some tokens share the same ticker symbol across exchanges but are different assets. Opportunities showing spreads above ~5% are likely false positives caused by this. A contract-address verification layer (via CoinGecko API) would resolve this.
- Transfer delay: Cross-exchange arbitrage requires on-chain fund transfers which take minutes. This scanner is best used to study market inefficiencies, not for high-frequency execution.
- No execution: This is detection only. Adding order placement requires exchange API keys and careful risk management.
- Telegram alerts — integrate
aiograminside theNotifyclass - File logging — replace
printwith Python'sloggingmodule to persist opportunities to disk - Symbol verification — query CoinGecko API to confirm same contract address before flagging as opportunity
- Execution layer — add order placement through each exchange's authenticated API endpoints
Built from scratch as a Python portfolio project covering async programming, multi-API integration, and real-time data normalization.