← Projects

TitaniumBOE-Sim Cboe BOE Protocol Simulator

Exchange-side simulator for Cboe's BOE binary protocol, with a price-time matching engine, trading bots, REST API and WebSocket in a single JAR.

Stack
Java 21 · Javalin · RocksDB · WebSocket · Docker
Status
Completed
Year
2025

What BOE is

BOE (Binary Order Entry) is the protocol participants use to send orders to Cboe's U.S. options markets. It isn't text: every message is an exact sequence of bytes in Little Endian, with fixed-size fields, prices with 4 implied decimals, and optional fields announced through bitfields. Above you can send an order to the book and then see its bytes, encoded the same way the simulator does it.

What I built

An exchange-side simulator, written from the v2.11.90 specification: it accepts TCP connections, authenticates sessions, receives BOE orders and matches them in a price-time priority matching engine. Around that:

  • Three bots (market maker, trend follower and random trader) that keep the book active.
  • A REST API and WebSocket for market data and trading.
  • Interactive API docs (OpenAPI with Scalar) served from the same JAR.
  • RocksDB persistence: users, trades and orders survive a restart, and live orders go back into the book.

Under the hood

  • Every TCP connection runs on its own Java 21 virtual thread: blocking I/O code that is easy to read, without paying for an OS thread per client.
  • Matching is synchronized per symbol, not globally: AAPL and MSFT match in parallel without blocking each other.
  • Writes to RocksDB go through an asynchronous queue: the client gets its acknowledgment without waiting on disk.
  • Messages form a sealed-class hierarchy, so the compiler knows every possible type.

How close it is to the spec

I reviewed the simulator section by section against the v2.11.90 specification and fixed every difference I found. The spec's own hexadecimal examples are used as tests, and when an example contradicts its tables I log it as an erratum instead of copying it. What it complies with today:

  • Every message code, the 1 s / 5 s heartbeat, and login with its reject codes.
  • Sequenced and unsequenced messages, with replay of what was missed on reconnect.
  • The optional fields the client asks for at login (return bitfields), message by message.
  • Day, IOC, FOK, GTC and GTD orders; reserve, minimum quantity and stop orders; self-trade prevention.
  • Cancel and Modify with their priority rules, mass cancel, Purge Orders, risk lockouts and Reset Risk.

What it doesn't have, answering with the reject the spec defines: auctions, complex orders, crosses and market-maker quotes. It doesn't use option series symbology yet either: the book trades symbols like AAPL.

Measured numbers

With the repository's load test, on a 16-core machine and a freshly started server for each run:

  • 500 simultaneous TCP connections, none refused.
  • Order Acknowledgment P99 between 2.5 and 4.0 ms (900 orders per run, across 10 sessions, all acknowledged).
  • About 4,600 REST requests per second on public endpoints.
  • More than 600 automated tests, all green.

The P99 is measured after the connection, login and REST phases, which warm up the JIT. Measuring latency alone on a cold server, the P99 lands between 7.2 and 13.9 ms.

While measuring I found the load test itself was out of date: it expected the old session codes and sent orders for a symbol the server rejects, so logins and latency hadn't been measured in a while. I fixed it before publishing these numbers. The memory phase is still not useful: it measures the client's heap, not the server's, so I don't publish that number.

The bottleneck

Login doesn't reach the target I had set (200 per second): it sits at around 50. Every password is checked with BCrypt at cost 12, which takes on the order of 200 ms of CPU per attempt; with 16 cores, the ceiling is around 60 logins per second. It's a deliberate cost: lowering it would make a brute-force attack cheaper.

See it running