# enewhuis/liquibook architecture

> Architecture diagram of the GitHub repository enewhuis/liquibook, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/enewhuis/liquibook
- Repository: https://github.com/enewhuis/liquibook

## Overview

Liquibook is a header-only C++ order-matching engine. Its principal workflow accepts order submissions and cancel/replace requests, matches compatible orders, and reports outcomes to the calling application. Optional stop, all-or-none, and immediate-or-cancel behavior is handled during matching; depth tracking aggregates open limit orders and can notify listeners of depth and BBO changes. The repository also documents manual order-entry and market-data publisher/subscriber examples. Some matching and example wiring is unsampled, so the graph omits uncertain internal links.

Main entry points: [`src/book/order_book.h`](https://github.com/enewhuis/liquibook/blob/master/src/book/order_book.h) (Order book), [`src/book/depth_order_book.h`](https://github.com/enewhuis/liquibook/blob/master/src/book/depth_order_book.h) (Depth order book), [`src/simple/simple_order_book.h`](https://github.com/enewhuis/liquibook/blob/master/src/simple/simple_order_book.h) (Simple order book), [`examples/depth_feed_publisher/depth_feed_publisher.cpp`](https://github.com/enewhuis/liquibook/blob/master/examples/depth_feed_publisher/depth_feed_publisher.cpp) (Depth feed publisher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_matching["Order matching"]
  node_book["Order book<br/>[order_book.h]"]
  node_tracker["Order tracker<br/>[order_tracker.h]"]
  node_price["Price ordering<br/>[comparable_price.h]"]
end

subgraph group_events["Depth and events"]
  node_callback["Callback events<br/>[callback.h]"]
  node_depthbook["Depth order book<br/>[depth_order_book.h]"]
  node_depth["Aggregated depth<br/>[depth.h]"]
  node_level["Depth levels<br/>[depth_level.h]"]
  node_listeners["Depth and BBO listeners<br/>[depth_listener.h]"]
end

subgraph group_adapters["Order adapter"]
  node_simplebook["Simple order book"]
  node_simpleorder["Simple order<br/>[simple_order.h]"]
end

subgraph group_examples["Example applications"]
  node_manual["Manual order entry"]
  node_publisher["Depth feed publisher"]
  node_subscriber["Depth feed subscriber"]
end

node_client(("Trading application"))
node_marketdata(("Market data consumer"))
node_quickfast{{"QuickFAST"}}

node_client -->|"submits or modifies"| node_book
node_book -->|"tracks orders"| node_tracker
node_book -->|"orders prices"| node_price
node_book -->|"queues outcomes"| node_callback
node_depthbook -->|"extends matching"| node_book
node_depthbook -->|"updates aggregates"| node_depth
node_depth -->|"maintains levels"| node_level
node_depthbook -->|"notifies changes"| node_listeners
node_simplebook -->|"extends depth book"| node_depthbook
node_simplebook -->|"updates order state"| node_simpleorder
node_manual -->|"submits requests"| node_simplebook
node_publisher -->|"submits orders"| node_simplebook
node_publisher -.->|"encodes market data"| node_quickfast
node_quickfast -.->|"decodes feed"| node_subscriber
node_subscriber -->|"publishes feed"| node_marketdata
node_manual -->|"displays notifications"| node_client
node_publisher -->|"publishes updates"| node_marketdata

click node_book "https://github.com/enewhuis/liquibook/blob/master/src/book/order_book.h"
click node_tracker "https://github.com/enewhuis/liquibook/blob/master/src/book/order_tracker.h"
click node_price "https://github.com/enewhuis/liquibook/blob/master/src/book/comparable_price.h"
click node_callback "https://github.com/enewhuis/liquibook/blob/master/src/book/callback.h"
click node_depthbook "https://github.com/enewhuis/liquibook/blob/master/src/book/depth_order_book.h"
click node_depth "https://github.com/enewhuis/liquibook/blob/master/src/book/depth.h"
click node_level "https://github.com/enewhuis/liquibook/blob/master/src/book/depth_level.h"
click node_listeners "https://github.com/enewhuis/liquibook/blob/master/src/book/depth_listener.h"
click node_simplebook "https://github.com/enewhuis/liquibook/blob/master/src/simple/simple_order_book.h"
click node_simpleorder "https://github.com/enewhuis/liquibook/blob/master/src/simple/simple_order.h"
click node_manual "https://github.com/enewhuis/liquibook/blob/master/examples/mt_order_entry/mt_order_entry_main.cpp"
click node_publisher "https://github.com/enewhuis/liquibook/blob/master/examples/depth_feed_publisher/depth_feed_publisher.cpp"
click node_subscriber "https://github.com/enewhuis/liquibook/blob/master/examples/depth_feed_publisher/depth_feed_subscriber.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_book,node_tracker,node_price toneBlue
class node_callback,node_depthbook,node_depth,node_level,node_listeners toneAmber
class node_simplebook,node_simpleorder toneMint
class node_manual,node_publisher,node_subscriber toneRose
class node_client,node_marketdata,node_quickfast toneIndigo
```

## Components

### Order matching

- [Order book](https://github.com/enewhuis/liquibook/blob/master/src/book/order_book.h): `src/book/order_book.h`
- [Order tracker](https://github.com/enewhuis/liquibook/blob/master/src/book/order_tracker.h): `src/book/order_tracker.h`
- [Price ordering](https://github.com/enewhuis/liquibook/blob/master/src/book/comparable_price.h): `src/book/comparable_price.h`

### Depth and events

- [Callback events](https://github.com/enewhuis/liquibook/blob/master/src/book/callback.h): `src/book/callback.h`
- [Depth order book](https://github.com/enewhuis/liquibook/blob/master/src/book/depth_order_book.h): `src/book/depth_order_book.h`
- [Aggregated depth](https://github.com/enewhuis/liquibook/blob/master/src/book/depth.h): `src/book/depth.h`
- [Depth levels](https://github.com/enewhuis/liquibook/blob/master/src/book/depth_level.h): `src/book/depth_level.h`
- [Depth and BBO listeners](https://github.com/enewhuis/liquibook/blob/master/src/book/depth_listener.h): `src/book/depth_listener.h`

### Order adapter

- [Simple order book](https://github.com/enewhuis/liquibook/blob/master/src/simple/simple_order_book.h): `src/simple/simple_order_book.h`
- [Simple order](https://github.com/enewhuis/liquibook/blob/master/src/simple/simple_order.h): `src/simple/simple_order.h`

### Example applications

- [Manual order entry](https://github.com/enewhuis/liquibook/blob/master/examples/mt_order_entry/mt_order_entry_main.cpp): `examples/mt_order_entry/mt_order_entry_main.cpp`
- [Depth feed publisher](https://github.com/enewhuis/liquibook/blob/master/examples/depth_feed_publisher/depth_feed_publisher.cpp): `examples/depth_feed_publisher/depth_feed_publisher.cpp`
- [Depth feed subscriber](https://github.com/enewhuis/liquibook/blob/master/examples/depth_feed_publisher/depth_feed_subscriber.cpp): `examples/depth_feed_publisher/depth_feed_subscriber.cpp`

### Other components

- **Trading application**
- **Market data consumer**
- **QuickFAST**

## Connections

- Trading application → Order book: submits or modifies
- Order book → Order tracker: tracks orders
- Order book → Price ordering: orders prices
- Order book → Callback events: queues outcomes
- Depth order book → Order book: extends matching
- Depth order book → Aggregated depth: updates aggregates
- Aggregated depth → Depth levels: maintains levels
- Depth order book → Depth and BBO listeners: notifies changes
- Simple order book → Depth order book: extends depth book
- Simple order book → Simple order: updates order state
- Manual order entry → Simple order book: submits requests
- Depth feed publisher → Simple order book: submits orders
- Depth feed publisher → QuickFAST: encodes market data
- QuickFAST → Depth feed subscriber: decodes feed
- Depth feed subscriber → Market data consumer: publishes feed
- Manual order entry → Trading application: displays notifications
- Depth feed publisher → Market data consumer: publishes updates
