Skip to content

achaljhawar/quantamatch

Repository files navigation

QuantaMatch

Ask DeepWiki

QuantaMatch is a C++20 cryptocurrency matching engine with a small REST API for order entry and a WebSocket feed for market data and trades.

It implements strict price-time priority (FIFO at each price level) and supports limit, market, ioc, and fok orders.

Quick Start

Build

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build

Run

The app takes the config file path as the first argument:

./build/src/matching_engine_app config.yaml

By default (see config.yaml) the server starts on:

  • REST: http://localhost:8180
  • WebSocket: ws://localhost:8181

Test

Fastest way to run tests locally:

./build/tests/matching_engine_tests

If you prefer ctest, use a generous timeout:

ctest --test-dir build --output-on-failure --timeout 600

REST API (Cheat Sheet)

  • GET /health
  • GET /symbols
  • POST /orders
  • GET /orders/{id}
  • DELETE /orders/{id}
  • GET /orders?limit=&offset=&symbol=&status=
  • GET /bbo/{symbol}
  • GET /book/{symbol}?depth=10
  • GET /trades?limit=&offset=&symbol=
  • GET /stats/{symbol}

Example order:

curl -X POST http://localhost:8180/orders \
  -H "Content-Type: application/json" \
  -d '{
    "symbol": "BTC-USDT",
    "side": "buy",
    "order_type": "limit",
    "price": "50000",
    "quantity": "1.5"
  }'

WebSocket

Connect to ws://localhost:8181 and subscribe:

{"action":"subscribe","channel":"bbo","symbol":"BTC-USDT"}
{"action":"subscribe","channel":"depth","symbol":"BTC-USDT"}
{"action":"subscribe","channel":"trades","symbol":"BTC-USDT"}

Configuration

The default config is config.yaml. Ports, symbols, tick/lot sizes, logging, persistence, and fee rates are configured there. See docs/CONFIGURATION.md for the schema and examples.

Project Layout

apps/    - main executable entrypoint
bench/   - benchmarks
include/ - public headers (mirrors src/)
src/     - implementation
tests/   - unit + integration tests
docs/    - architecture + API + dev/deploy guides
example/ - runnable example scripts

About

a low latency cryptocurrency order matching engine

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors