BOOT_PORTFOLIO.BATv1.0

systems project // active development

Order Book [ Phase 04 // Core Matching Engine ]

I am building a correctness-first electronic limit order book in modern C++ because apparently my idea of a relaxing side project is asking, "what if a queue had opinions about fairness, latency, and the memory hierarchy?"

This is explicitly a current work in progress. It is not done, not polished, and not pretending to be a production exchange. The goal is to understand the infrastructure underneath modern markets: matching orders, preserving price-time priority, and designing data structures that do not make the CPU file a formal complaint.

As it grows, I am planning to add benchmarking, profiling, unit tests, market data feeds, replay tools, and progressively more performance-focused experiments. Less "hot stock tip," more "let me build the tiny engine room where the market plumbing lives."

C:\MARKET\LOB>matching_engine.exe

[DONE] define orders and price levels

[DONE] store bids and asks in price priority

[DONE] preserve FIFO within each price level

[DONE] index active orders by ID

[ACTIVE] implement matching and trade generation

[QUEUED] test, replay, benchmark, and profile (before bragging about speed)

awaiting next commit

SIM_DEPTHprice-time priority
BEST BID 101.24SPREAD 0.01BEST ASK 101.25
Bid SizeBidAskAsk Size
420 101.24 101.25 180
310 101.23 101.26 260
780 101.22 101.27 640
150 101.21 101.28 390
900 101.20 101.29 710
SYSTEM ARCHITECTURETARGET BEHAVIOUR PREVIEW // MATCHING CYCLE

Inspect a component or submit an order to trace its path through the system. Order storage is the completed milestone; matching and trade generation are the next implementation phase, so this trace previews target behaviour rather than the live C++ engine.

A conceptual request flow from order submission through validation, matching, the order book, optional trade generation, and a submission result. This browser illustration does not execute the C++ project.

BROWSER SIMULATION // FIXED TICK 0.01 // NOT C++ EXECUTION
Illustrative browser simulation ready. Type HELP for commands.
Architecture explorer ready.
ORDER STORAGE // COMPLETEPHASE 03
PRICE LEVELSBids high โ†’ low // Asks low โ†’ high
QUEUEstd::list<Order> // FIFO
ACTIVE INDEXstd::unordered_map<OrderId, OrderLocation>

Opposite price ordering keeps the best bid and ask at the front of their respective maps. Orders at each price retain FIFO priority, while the active-order index avoids scanning the entire book during cancellation and fill cleanup.

BEST PRICEO(1)
PRICE LEVELO(log P)
ACTIVE IDAVG O(1)
TOP-D SNAPSHOTO(D)
SOURCE AVAILABLEGITHUB_REMOTE

Browse the C++ implementation, tests, benchmarks, and build setup.

[ OPEN GITHUB REPOSITORY ]