A comprehensive collection of high-frequency trading (HFT) market making bots for cryptocurrency exchanges. This repository provides production-ready templates in multiple languages with both single-exchange and multi-exchange architectures.
crypto-hft-market-making-trading-profitable-system/
├── cpp-single-exchange/ # C++ Single Exchange HFT Bot
├── cpp-multi-exchange/ # C++ Multi-Exchange HFT Bot
├── rust-single-exchange/ # Rust Single Exchange HFT Bot
├── rust-multi-exchange/ # Rust Multi-Exchange HFT Bot
├── python-single-exchange/ # Python Single Exchange Bot
└── python-multi-exchange/ # Python Multi-Exchange Bot
- Market Making: Automated bid/ask quoting with spread management
- Inventory Management: Position-aware pricing with skew adjustments
- Risk Management: Position limits, loss limits, kill switches
- Multiple Strategies: Basic MM, Inventory-Adjusted, Avellaneda-Stoikov
- Consolidated Order Book: Unified view across all venues
- NBBO Tracking: National Best Bid/Offer calculation
- Cross-Exchange Arbitrage: Detect and execute price discrepancies
- Smart Order Routing: Route to best price or lowest latency
- Instant Hedging: Hedge fills on alternate exchanges
- Binance (Spot & Futures)
- Bybit (Spot & Perpetuals)
- OKX (Spot, Futures, Swaps)
- Extensible architecture for adding more
| Feature | C++ | Rust | Python |
|---|---|---|---|
| Latency | ~1-10μs | ~1-10μs | ~100-1000μs |
| Memory Safety | Manual | Guaranteed | GC |
| Async I/O | io_uring/epoll | tokio | asyncio |
| Lock-Free Queues | ✅ | ✅ | ❌ |
| Memory Pools | ✅ | ✅ | ❌ |
| Best For | Production HFT | Production HFT | Research/Prototyping |
cd cpp-single-exchange
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j$(nproc)
./market_makercd rust-single-exchange
cargo build --release
cargo run --releasecd python-single-exchange
pip install -e .
python -m src.mainAll implementations support configuration via:
- Environment variables for API credentials
- JSON config files for strategy parameters
Example environment setup:
export BINANCE_API_KEY="your_key"
export BINANCE_API_SECRET="your_secret"
export BYBIT_API_KEY="your_key"
export BYBIT_API_SECRET="your_secret"- Quote bid/ask around fair value (mid-price)
- Fixed spread with configurable parameters
- Simple position limits
- Skew quotes based on current inventory
- Reduces position when inventory is high
- More aggressive pricing to unload inventory
- Optimal market making under inventory risk
- Reservation price based on inventory and risk aversion
- Volatility-aware spread calculation
- Time-decay adjustments
All implementations include:
- Position Limits: Maximum position size per symbol
- Order Limits: Size, value, and rate limits
- Loss Limits: Per-trade, daily, and drawdown limits
- Kill Switch: Automatic trading halt on breaches
- Price Deviation: Reject orders far from mid-price
- L2/L3 order book representation
- Efficient updates (O(log n) for sorted structures)
- Spread and mid-price calculations
- WebSocket for real-time market data
- REST API for order management
- HMAC-SHA256 request signing
- Rate limiting and error handling
- Event-driven architecture
- Configurable parameters
- Signal integration (optional)
| Use Case | Recommended |
|---|---|
| Production HFT (latency-critical) | C++ or Rust |
| Institutional deployment | C++ Multi-Exchange |
| Modern codebase with safety | Rust |
| Research & Backtesting | Python |
| Prototype development | Python |
| Learning HFT concepts | Python (most readable) |
This software is for educational purposes only.
- Trading cryptocurrencies involves substantial risk of loss
- Past performance does not guarantee future results
- Always test thoroughly on testnet before live trading
- Use at your own risk
MIT License
Contributions are welcome! Please read the contributing guidelines before submitting PRs.
Note: These are template implementations. Production deployment requires:
- Thorough testing and backtesting
- Security hardening
- Monitoring and alerting
- Proper infrastructure (colocation, low-latency networks)
- Regulatory compliance in your jurisdiction