Skip to content

About

Ultra-Low Latency Market Making Bot using C++.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

15 stars

Watchers

1 watching

Forks

Repository files navigation

PinnacleMM Logo

Ultra-Low Latency Market Making System

License C++ Release Build Status Performance

Getting Started  •   Architecture  •   Order Routing  •   Performance Benchmarks  •   API Reference  •   Exchange Connectors  •   Multi-Instrument

PinnacleMM is a high-performance, production-grade market making system designed for high-frequency trading in cryptocurrency markets. Built primarily in C++ with a focus on ultra-low latency, this system achieves microsecond-level execution speeds while maintaining robust risk management capabilities.

Key Features

  • Ultra-Low Latency Core: C++20 engine with lock-free data structures and nanosecond-precision timing
  • Dynamic Market Making: Adaptive bid-ask spreads with intelligent inventory and position management
  • Live Exchange Connectivity: Coinbase Pro WebSocket feeds and institutional FIX protocol support (Interactive Brokers, Coinbase, Kraken, Binance)
  • Smart Order Routing: Multi-venue execution with BEST_PRICE, TWAP, VWAP, and MARKET_IMPACT algorithms
  • ML-Enhanced Trading: Neural network spread optimization, Hidden Markov Model regime detection, market impact prediction, and reinforcement learning parameter adaptation
  • Risk Management: Lock-free pre-trade checks, position/exposure limits, circuit breaker, real-time VaR, and a 16-type alerting system
  • Multi-Instrument Trading: Simultaneous multi-symbol trading with cross-exchange arbitrage detection and cross-market correlation analysis
  • Advanced Backtesting: Historical data replay with Monte Carlo analysis and A/B testing
  • Observability: Real-time web dashboard (--enable-visualization) and structured JSONL data export (--json-log)
  • Crash Recovery: Memory-mapped persistence with disaster recovery and backup tooling
  • Enterprise Security: AES-256 encrypted credentials, input validation, audit logging, rate limiting, and certificate pinning
  • Production Deployment: Docker images and a production-ready Kubernetes StatefulSet

System Architecture

PinnacleMM follows a modular, layered architecture:

  • Core Engine Layer: Ultra-low latency components handling order book and execution
  • Risk Layer: Pre-trade checks, circuit breaker, VaR engine, alerting, and disaster recovery
  • Strategy Layer: Pluggable strategies for different market making approaches
  • Exchange Layer: Multi-protocol connectivity (WebSocket, FIX) with simulation capabilities
  • Persistence Layer: Memory-mapped file system for crash recovery

Read more about the system architecture.

Getting Started

Prerequisites

  • C++20 compatible compiler (GCC 10+, Clang 10+, or MSVC 2019+)
  • CMake 3.14+
  • Boost libraries 1.72+
  • OpenSSL (secure credential handling)
  • nlohmann_json (configuration handling)
  • spdlog and fmt (auto-downloaded at pinned versions if not installed)

Quick Start

# Clone and setup
git clone https://github.com/chizy7/PinnacleMM.git
cd PinnacleMM

# Native execution (recommended for development) — auto-builds if needed
scripts/run-native.sh                     # Simulation mode
scripts/run-native.sh test                # Run test suite
scripts/run-native.sh benchmark           # Run performance benchmarks

# Docker execution (recommended for production)
scripts/run-docker.sh                     # Simulation mode

Pre-built Docker images are available at ghcr.io/chizy7/pinnaclemm. See the Scripts Reference for all script commands, options, and container usage.

Manual Build

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_BENCHMARKS=ON ..
make -j$(nproc || sysctl -n hw.ncpu)

Running PinnacleMM

Simulation Mode

cd build && ./pinnaclemm --mode simulation --symbol BTC-USD

# With ML strategy and real-time dashboard
./pinnaclemm --mode simulation --enable-ml --enable-visualization

Live Trading Mode

# One-time credential setup (AES-256 encrypted, master password protected)
scripts/run-native.sh --setup-credentials

# Start live trading
cd build && ./pinnaclemm --mode live --exchange coinbase --symbol BTC-USD --verbose

See Security & API Key Management for credential details.

Backtest Mode

# Runs against historical data (auto-generates synthetic data if no CSV found)
cd build && ./pinnaclemm --mode backtest --symbol BTC-USD

Backtest mode prints a detailed performance report (Sharpe ratio, drawdown, win rate) and saves JSON results. See the Advanced Backtesting Guide for custom data and parameters.

For all command-line options, run modes, multi-instrument setups, and the visualization dashboard, see the Getting Started Guide.

REST Performance and Chart Queries

When visualization is enabled, the REST API provides the latest performance snapshot and retained performance history:

GET /api/v1/strategies/{strategy_id}/performance

Supported performance parameters are start and end timestamp bounds (inclusive, Unix epoch nanoseconds) and an optional limit. Requests without these parameters return the latest snapshot as an object. Requests with any of them return an array of matching snapshots in chronological order. limit keeps the newest N matches and must be greater than zero.

GET /api/v1/strategies/primary_strategy/performance?start=100&end=300&limit=50

Chart data is available through:

GET /api/v1/strategies/{strategy_id}/charts/{metric}

Supported metrics are pnl, position, sharpe_ratio, max_drawdown, win_rate, total_trades, ml_accuracy, and prediction_time; an unknown metric returns 400 Bad Request. Chart requests support range values such as 30m, 1h, and 1d, or explicit start and end timestamp bounds. Explicit bounds take precedence over range, and the window defaults to the last hour. Invalid or reversed ranges return 400 Bad Request.

Chart points are derived from the retained performance history, which is bounded by the configured maxHistorySize. While visualization is enabled, a performance sample is recorded once per dataCollectionIntervalMs (1 second by default), so the default history of 10,000 samples covers roughly 2.7 hours. Live samples populate pnl, position, total_trades, and the ML fields when --enable-ml is set. sharpe_ratio, max_drawdown, and win_rate need per-trade realized PnL that the live strategy does not track, so they read 0 in live samples.

Performance

  • Order Book Update Latency: <1 μs
  • Order Execution Latency: <50 μs end-to-end
  • Pre-Trade Risk Check: ~750 ns (lock-free)
  • Circuit Breaker Check: ~5 ns (single atomic load)
  • ML Prediction Latency: 1–3 μs (neural network inference)
  • Throughput: 100,000+ messages per second
  • Recovery Time: <5 seconds for full system recovery
  • Memory Footprint: <100 MB for core engine

See Performance Benchmarks for methodology and full results.

Documentation

Core System

Risk Management & Production Operations

Machine Learning & Analytics

Multi-Instrument & Optimization

Exchange Integration & Testing

Technology Stack

  • Core Engine: C++20, lock-free algorithms, std::atomic
  • Build System: CMake
  • Testing: Google Test, Google Benchmark
  • Networking: Boost.Beast (WebSocket), hffix (FIX protocol)
  • Machine Learning: Custom neural networks, Hidden Markov Models, reinforcement learning
  • Visualization: HTML5/JavaScript frontend with Chart.js and D3.js
  • Security: OpenSSL, AES-256-CBC encryption, PBKDF2 key derivation
  • Configuration: nlohmann/json
  • Deployment: Docker, Kubernetes

Contributing

Contributions are welcome! Please read the Contributing Guide for development setup, coding standards, pre-commit hooks, and the pull request process. All participants are expected to follow our Code of Conduct.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

For questions, feedback, or collaboration opportunities:

About

Ultra-Low Latency Market Making Bot using C++.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

15 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages