A data acquisition pipeline for exchange orderbook data, written in C++23.
It connects to Kraken's L2 book channel and, on command from a frontend
client, records pairs into per-pair binary files or streams their books live
to the client over a websocket.
data_feed/— the acquisition program (CMake project).example_scripts/— standalone helper scripts (e.g. fetching a Kraken websocket token from Python).third_party/— vendored headers (rapidjson) and the vcpkg install tree.
Nothing is subscribed at start. A client connects to the websocket on
127.0.0.1:8765 and sends protobuf ClientCommands
(proto/market_data.proto): ListPairs for the pairs a venue can stream,
Start / Stop / List for recordings and live feeds, Watch / Unwatch
to stream a live feed's books. See
data_feed/ARCHITECTURE.md.
Each subscription is set up as follows:
| Setting | Value |
|---|---|
| Venue | wss://ws.kraken.com/v2 |
| Channel | book |
| Symbols | any Kraken pair, one subscription per pair |
| Depth | one of Kraken's book depths (10, 25, 100, 500, 1000) |
| Recording | one binary file per pair per venue connection, named by its capture window (e.g. BTCUSD-<start>-<end>.bin) |
| Live feed | protobuf Books to every client watching it |
Each pair gets its own writer lane on its own thread; a write failure only
takes down that pair's lane (and triggers an unsubscribe for it) — the rest
of the feed keeps running. The connection status message and subscription
acknowledgements are consumed during Connect() and printed to the console,
not written to the files.
- CMake 4.0+, Ninja, MinGW-w64 GCC (see
data_feed/CMakePresets.json) - vcpkg with
VCPKG_ROOTset; dependencies are pinned invcpkg.json - Kraken API credentials in the environment:
KRAKEN_API_KEYKRAKEN_PRIVATE_KEY
From data_feed/:
cmake --preset mingw
cmake --build --preset debug # or: --preset release
./build/Debug/data_feed.exeStop with Ctrl+C.