Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

High-Performance SSE/SZSE Orderbook Engine

A high-performance C++17 Limit Order Book (LOB) engine designed for the Shanghai (SSE) and Shenzhen (SZSE) stock exchanges. This engine implements the Reduction-based Synthesis Logic, processing strictly ordered ApplSeqNum streams to reconstruct the order book state in real-time.

Features

  • Performance Oriented:
    • Memory Pooling: Custom ObjectPool to minimize allocation overhead and fragmentation.
    • O(1) Lookups: Hash map based order tracking.
    • O(1) Removals: Cached iterators allow removing orders from price levels in constant time.
  • Dual Exchange Support:
    • SSE (Shanghai): Handles "Balance" based updates. Trades reduce "Maker" volume only (Taker is stateless).
    • SZSE (Shenzhen): Standard matching and reduction logic.
  • Robust Verification:
    • Internal Consistency Checks: Validates map integrity, volume sums, and price ordering.
    • Fuzz Testing: Randomized stress tester (fuzz_test) verified with 10,000+ iterations.
    • Scenario Regression: Deterministic tests (test_scenario) for priority, partial fills, and cancellations.

Build Requirements

  • C++17 compliant compiler (Clang/GCC)
  • xmake build system

Building and Running

Build All Targets

xmake build

Run Demo

Runs the main simulation demonstrating SSE logic.

xmake run lob_demo

Run Verification Tests

1. Deterministic Scenario Tests Validates specific business rules (Time-Priority, Cancellations).

xmake run test_scenario

2. Fuzz Testing Runs random stress test with consistency checks.

xmake run fuzz_test

Project Structure

  • include/lob/
    • Engine.h: Core OrderBook class definition.
    • Order.h: Order structure and ObjectPool implementation.
    • Level.h: PriceLevel management.
    • Types.h: Common type definitions.
  • src/
    • Engine.cpp: Implementation of matching and interaction logic.
    • main.cpp: Main entry point for demonstration (Multi-Stock).
    • strategy_demo.cpp: IPC Reader example.
    • fuzz_test.cpp: Generalized fuzz testing suite.
    • test_scenario.cpp: Specific regression scenarios.

New Features

  • Multi-Stock Support: MatchingEngine manages multiple books.
  • IPC: Shared Memory publishing for low-latency strategy access.
    • Run xmake run strategy_demo <instrument_id> while lob_demo is running.

License

MIT

About

A high-performance C++17 Limit Order Book (LOB) engine designed for the Shanghai (SSE) and Shenzhen (SZSE) stock exchanges. This engine implements the Reduction-based Synthesis Logic, processing strictly ordered ApplSeqNum streams to reconstruct the order book state in real-time.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages