Skip to main content
The Orderbook class accepts a configuration object during instantiation. While symbol is the only required parameter, you can fine-tune the pipeline, history, and connection settings to match your specific requirements.

Usage

import { Orderbook } from '@krono/core';

const orderbook = new Orderbook({
  symbol: 'BTC/USD',
  depth: 100,
  limit: 50,
  throttleMs: 100,
  reconnect: {
    enabled: true,
    maxAttempts: 5,
    delayMs: 1000
  }
});

Core Settings

symbol
string
required
The trading pair symbol to subscribe to (e.g., BTC/USD, ETH/EUR).
depth
number
default:"1_000"
The subscription depth requested from the Kraken WebSocket.Allowed values: 10, 25, 100, 500, 1000.
A higher depth increases network traffic. Choose the lowest value that satisfies your limit requirement.
limit
number
default:"100"
The maximum number of price levels (asks/bids) kept in the local memory and exposed in snapshots.If limit is lower than depth, the orderbook will crop the data client-side.
tickSize
number
The minimum price increment allowed for the asset pair. This value is used to generate the valid groupingOptions.
spreadGrouping
number
default:"0"
Combines price levels into groups of this size. Useful for visualizing the book or reducing noise.
When the tickSize or symbol changes, the orderbook automatically resets spreadGrouping to match the tickSize to ensure the most granular view by default.

Pipeline & Performance

throttleMs
number
Restricts the frequency of updates. If set, the orderbook will only emit the DataUpdate event once every throttleMs milliseconds, discarding intermediate updates.
debounceMs
number
Delays the update emission until the orderbook has been stable (received no new messages) for debounceMs milliseconds.
debug
boolean
default:"false"
Enables verbose logging to the console. Useful for diagnosing connection issues or pipeline behavior.

History Management

historyEnabled
boolean
default:"false"
When enabled, the orderbook maintains a ring buffer of previous snapshots.
maxHistoryLength
number
The maximum number of historical snapshots to retain in memory. Oldest snapshots are discarded when the limit is reached.

Connection & Reconnection

reconnect
object
Configuration for the automatic reconnection strategy.