Subscribes/Unsubscribes to market options Order Book Events data.
Once you're connected to this subscription: wss://ws.amberdata.com/options, every subscription message must include an explicit instrument
. This is mandatory across all market types.
- You must always specify the
instrument
. - For Futures and Options, you must also include the
exchange
field.
See here for more details and examples.
Request
{
"jsonrpc" : "2.0",
"id" : 1,
"method" : "subscribe",
"params" : [ "market:options:order:events", { "instrument": "BTC-30SEP22-50000-P", "exchange": "deribit" } ]
}
Param | Type | Description |
---|---|---|
instrument | string | The asset instrument. |
exchange | string | The exchange for which to retrieve asset instruments. |
Response
{
"jsonrpc": "2.0",
"method": "subscription",
"params": {
"subscription": "74212dc1-f25e-41b5-a3ae-f239d5155b6b",
"result": {
"exchange": "deribit",
"instrument": "BTC-12APR24-71000-C",
"timestamp": 1711571405282,
"exchangeTimestamp": 1711571404974,
"exchangeTimestampNanoseconds": 0,
"receivedTimestamp": 1711571405282,
"receivedTimestampNanoseconds": 184986,
"isBid": false,
"sequence": 68116490254,
"data": [
[
0.0485,
0.3,
null
],
[
0.049,
62.2,
null
],
[
0.0495,
9.6,
null
]
]
}
}
}
Field | Type | Description | |
---|---|---|---|
exchange | string | The exchange. | |
instrument | string | The instrument. | |
timestamp | number | The time at which the order book event took place. | |
exchangeTimestamp | number | Timestamp that the exchange returned. | |
exchangeTimestampNanoseconds | number | Nanoseconds part of exchangeTimestamp . | |
receivedTimestamp | number | Timestamp when Amberdata received order book event. | |
receivedTimestampNanoseconds | number | Nanoseconds part of receivedTimestamp . | |
isBid | boolean | true if the order is a bid, false otherwise. | |
sequence | `number \ | null` | A unique identifier for the order book event. |
data[0] | number | The price level of the order(s). | |
data[1] | number | The quantity of the contract(s) at that price level. | |
data[2] | `number \ | null` | The number of individual orders at the specified price level. |
Example
const WebSocket = require('ws');
const ws = new WebSocket('wss://ws.amberdata.com/options', {headers: {x-api-key:'<api_key>'}});
ws.on('open', () => {
ws.send(JSON.stringify({
jsonrpc: '2.0',
method: 'subscribe',
params: ['market:options:order:events', {'instrument': 'BTC-30SEP22-50000-P', 'exchange': 'deribit'}],
id: 1,
}));
});
ws.on('message', data => {
console.log(JSON.stringify(JSON.parse(data), null, 2));
});