market:futures:ohlcv

Subscribes/Unsubscribes to market futures OHLCV data.

Once you're connected to this subscription: wss://ws.amberdata.com/futures, you must provide either the instrument or exchange - one needs to be specified, both cannot be empty.

Request

{
  "jsonrpc" : "2.0",
  "id"      : 1,
  "method"  : "subscribe",
  "params"  : [ "market:futures:ohlcv", { "instrument": "XRPUSDT", "exchange": "binance"} ]
}
ParamTypeDescription
instrumentstringThe asset instrument.
exchangestringThe exchange for which to retrieve asset instruments.

Response

{
    "jsonrpc": "2.0",
    "method": "subscription",
    "params": {
        "subscription": "c17c567a-6bd0-4335-85ed-61197c845f3f",
        "result": {
            "exchange": "binance",
            "instrument": "ADAUSD_PERP",
            "timestamp": 1711570860000,
            "open": 0.6478,
            "high": 0.6478,
            "low": 0.6476,
            "close": 0.6476,
            "volume": 4075.73706105
        }
    }
}
FieldTypeDescription
exchangestringThe exchange name.
instrumentstringThe instrument name.
timestampnumberThe timestamp associated with this record in UTC.
opennumberThe price at which the first trade occurred during the specified period.
highnumberThe highest price at which a trade took place during the period.
lownumberThe lowest price at which a trade occurred during the period.
closenumberThe price at which the last trade occurred during the specified period.
volumenumberThe total quantity traded during the period.

Example

const WebSocket = require('ws');
const ws = new WebSocket('wss://ws.amberdata.com/futures', {headers: {x-api-key:'<api_key>'}});

ws.on('open', () => {
  ws.send(JSON.stringify({
      jsonrpc: '2.0',
      method: 'subscribe',
      params: ['market:futures:ohlcv', {'instrument': 'XRPUSDT', 'exchange': 'binance'}],
      id: 1,
    }));
});

ws.on('message', data => {
  console.log(JSON.stringify(JSON.parse(data), null, 2));
});