kraken-book 0.1.0

WASM-compatible orderbook engine for Kraken
Documentation

WASM-compatible orderbook engine for Kraken WebSocket API v2

This crate provides the core orderbook data structures and checksum validation. It is designed to compile to both native and WASM targets.

Features

  • Level 2 (L2): Aggregated price levels with checksum validation
  • Level 3 (L3): Order-level tracking with FIFO queue semantics

Critical WASM Constraints

  • NO std::time::Instant (panics in WASM)
  • NO tokio (doesn't compile to WASM)
  • NO networking code

L2 Example

use kraken_book::{Orderbook, OrderbookState};
use kraken_types::BookData;

let mut book = Orderbook::new("BTC/USD");
assert_eq!(book.state(), OrderbookState::Uninitialized);

L3 Example

use kraken_book::l3::{L3Book, L3Order, L3Side};
use rust_decimal_macros::dec;

let mut book = L3Book::new("BTC/USD", 10);
book.add_order(L3Order::new("order1", dec!(100), dec!(1)), L3Side::Bid);

if let Some(pos) = book.queue_position("order1") {
    println!("Position: {}, Qty ahead: {}", pos.position, pos.qty_ahead);
}