OHLCV&VWAP

OHLCV data is the API equivalent to the candlesticks that are usually displayed on graphical charts. OHLCV is an aggregated form of market data calculated using raw trades data. The Volume-Weighted Average Price (VWAP) is a trading benchmark that gives the average price a security has traded throughout the defined time period, these are based on both volume and price.

Subscription

After websocket connection is established, you will need to send a request message with details of your subscription.

A full list of supported markets is available through the REST dictionary endpoint. Allowed granularity values are 1h and 1m.

Add markets

Allows the addition of markets to a subscription within the websocket connection.

Request

Type: request-trade-metrics-subscriptions-add

Payload:

{
  "subscriptions":[
    {
      "granularity":"1m",
      "marketId":"kucoin-eth-btc"
    }
  ]
}
Response

Type: response-trade-metrics-subscriptions-add

Payload:

{
  "added": 1,
  "total": 5
}

Remove markets

Allows the removal of markets from a subscription within the websocket connection.

Request

Type: request-trade-metrics-subscriptions-remove

Payload:

{
  "subscriptions":[
    {
      "granularity":"1m",
      "marketId":"kucoin-eth-btc"
    }
  ]
}
Response

Type: response-trade-metrics-subscriptions-remove

Payload:

{
  "removed": 1,
  "total": 4
}

Data

If everything is correct during subscription, we will provide you with a continuous stream of real-time market data updates according to your tariff limits.

Type: tm

Payload:

Field NameTypeRequiredDescription
gStringtrueGranularity, defined aggregation time window
tsIntegertrueTimestamp, aggregation window start time in milliseconds. UNIX epoch format
mStringtrueMarket ID
oStringtrueOpen, the first execution price in the quote currency in the defined aggregation time window
hStringtrueHigh, the maximum execution price in the quote currency in the defined aggregation time window
lStringtrueLow, the minimum execution price in the quote currency in the defined aggregation time window
cStringtrueClose, the last execution price in the quote currency in the defined aggregation time window
vStringtrueTrade volume sum in the base currency in the defined aggregation time window
tIntegertrueThe total amount of executed trades in the defined aggregation time window
vwStringtrueVolume weighted average price in the defined aggregation time window. sum(volume * price) / sum(volume)

Example

  1. Subscribe to one market with 1m granularity:
{
  "traceId":"uy34fw9",
  "type":"request-trade-metrics-subscriptions-add",
  "payload": {
    "subscriptions":[
      {
        "granularity":"1m",
        "marketId":"kucoin-eth-btc"
      }
    ]
  }
}
  1. Receive successful response
{
  "traceId":"uy34fw9",
  "type":"response-trade-metrics-subscriptions-add",
  "payload": {
    "added": 1,
    "total": 1
  }
}
  1. Then start receiving market data feed you subscribed to:
{
    "type": "tm",
    "payload": {
        "g": "1m",
        "ts": 1657837620000,
        "m": "kucoin-eth-btc",
        "o": "0.057735",
        "h": "0.057735",
        "l": "0.05772",
        "c": "0.057721",
        "v": "0.8873883",
        "t": 9,
        "vw": "0.057722864417527253852682078409192458363"
    }
}