This hook requires the
OrderbookProvider to be present in your component tree to provide the underlying Orderbook instance.Import
Usage
Parameters
This hook does not accept any parameters. It automatically connects to theOrderbook instance provided by the nearest context provider.
Return Type
State
string
The current trading pair symbol (e.g., “BTC/USD”).
number
default:25
The maximum number of visible price levels returned in the data updates.
10 | 25 | 100 | 500 | 1000
default:500
The subscription depth requested from the Kraken WebSocket.
number[]
A generated list of 9 user-friendly grouping steps (1x, 2x, 5x, 10x… of tickSize).
number
The step size for price grouping (aggregation). Defaults to 0 (no grouping).
number | undefined
default:1000
The interval in milliseconds used to throttle outgoing data updates.
number | undefined
The interval in milliseconds used to debounce outgoing data updates.
boolean
default:true
Whether the instance is currently recording historical snapshots.
number
default:86400
The maximum number of snapshots stored in the history buffer.
boolean
default:false
Whether verbose logging is enabled for the orderbook instance.
Actions
(v: string) => void
Updates the trading pair. Note: This will clear existing data and trigger a new WebSocket subscription.
(v: 10 | 25 | 100 | 500 | 1000) => void
Updates the Kraken subscription depth. Triggers a WebSocket re-subscription.
(v: number) => void
Adjusts the number of levels filtered from the local cache. Does not trigger a re-subscription.
(v: number) => void
Updates the base increment. This regenerates the groupingOptions.
(v: number) => void
Updates the price aggregation step size.
(v: number | undefined) => void
Configures the throttle interval for the update pipeline.
(v: number | undefined) => void
Configures the debounce interval for the update pipeline.
(v: boolean) => void
Toggles the recording of historical snapshots.
(v: number) => void
Resizes the internal history buffer.
Examples
Performance Tuning
Switch between throttling for high-frequency updates or debouncing for a “calmer” UI experience.Depth vs. Limit Management
depth controls how much data we request from Kraken, while limit controls how much we actually show in the UI.
Related
Orderbook Core
Explore the underlying class logic and event emitters.
useOrderbookConnection
Access and modify the orderbook websocket connection.
useAssetPairs
Find valid symbols to pass to
setSymbol.Kraken API
Explore the
book channel streams level 2 order book docs.
