Market-making execution bot for binary prediction markets with adaptive pricing, inventory management, and risk controls. Rust implementations.
Quant Execution Bot - Rust Implementation
A high-performance market-making execution bot for binary event contracts (prediction markets) implemented in Rust.
๐ Features
- Adaptive Spread Management: Dynamically adjusts spreads based on order flow imbalance and inventory
- Inventory Skew: Shades mid prices to manage accumulated positions
- Risk Controls: Inventory limits, exposure limits, and drawdown tracking
- Mean Reversion: Mid prices slowly revert toward fair value (0.5)
- Deterministic Simulation: Reproducible results with seeded RNG
๐ Project Structure
quantbotrust/
โโโ Cargo.toml # Project dependencies
โโโ src/
โ โโโ main.rs # Entry point and simulation orchestrator
โ โโโ market_state.rs # Market state container and trade recording
โ โโโ market_maker.rs # Core quoting logic and adaptation algorithms
โ โโโ execution_engine.rs # Simulation driver and order flow generator
โ โโโ logger.rs # CSV report writer
โโโ simulation_report.csv # Final metrics (generated)
โโโ trace.json # Time-series data (generated)
๐ ๏ธ Build & Run
Prerequisites
- Rust 1.70+ (install via rustup)
Build
cargo build --release
Run
cargo run --release
Expected Output
๐ Quant Execution Bot - Rust Implementation
============================================
๐ Running simulation with 200 steps...
โ
Simulation complete. Report written to: simulation_report.csv โ
Trace data written to: trace.json
๐ Final Market States:
๐ช inflationgt20 { ... } ๐ช teamxwins { ... } ๐ช electioncandidatea { ... }
๐ Summary Statistics:
Total PnL: 565.4478 Total Fills: 1189 ...
๐ Output Files
| File | Description | |------|-------------| | simulation_report.csv | Final metrics for all markets (PnL, fills, drawdown, etc.) | | trace.json | Step-by-step time-series data for analysis |
๐ช Simulated Markets
| Market | Initial Mid | Description | |--------|-------------|-------------| | inflationgt20 | 0.30 | "Will inflation exceed 20%?" | | electioncandidatea | 0.55 | "Will Candidate A win?" | | teamxwins | 0.50 | "Will Team X win?" |
๐ง Configuration
Modify market parameters in main.rs:
let mut market = MarketState::new("my_market", 0.50);
market.inventory_limit = 200.0; // Max inventory
market.exposure_limit = 10000.0; // Max exposure
market.spread = 0.05; // Initial spread
๐ Performance
- Zero-copy operations where possible
- Efficient HashMap-based market lookups
- Deterministic PRNG (ChaCha8) for reproducibility
- Release mode optimizations
- Memory-safe with no garbage collection overhead
๐ License
MIT