@orderly.network/hooks
provides useOrderbookStream
to return formatted data of the orderbook, making it easy for the orderbook to be displayed on the UI. When the symbol
parameter changes, the hook will automatically subscribe for the data of the new symbol, thus no additional handling is required.
useOrderbookStream
returns an array, where the first element is the formatted orderbook data and the second element is an object
conatining some data regarding the orderbook status.
[0]
The orderbook data format is as follows:
level
parameter.allDepths
is an array containing all the different price tick granularities that the current symbol supports.
onDepthChange
is a function that is used when a user changes the price tick granularity display of the orderbook. The hook will aggregate the orderbook levels according to this parameter when providing the orderbook data.