Learning how market makers make money
Mini-Market-Making Bot
I built this bot to understand how market makers operate and it's trading BTC/USD. For market data it uses Binance's WebSocket, simulates quote posting, and streams live P&L through FastAPI.
Tech: Docker, FastAPI, SQLAlchemy, Python 3.11
Two containers with shared storage
The system is split into a bot container and an API container. The bot handles data feeds, strategy, and simulation. The API serves endpoints. They share a SQLite volume, so the API can restart without disrupting the trading loop.
Inside the simulator
The order book lives in memory as bid/ask dictionaries. The execution engine reconciles stealth fills and partial fills against external best bid/ask. Trades get unique IDs, and I used Decimal for math, storing as FLOAT for the MVP.
From laptop to cloud
Local dev is docker compose up. For Fly.io, I added a fly.toml and multi-stage Dockerfile. The VM runs both containers with a 1 GB volume for the database. It assumes no latency for trading sim, but could be extended with a more robust engine.
Wanna get in touch?
I'm always open to discussing anything related to what I'm building.
Email me