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 the subscription process is successful, you will receive a continuous stream of real-time market data updates, subject to the limits of your selected tariff plan.

Type: tm

Payload: Fields in an array in order

TypeRequiredDescription
StringtrueMarket ID
IntegertrueTimestamp, aggregation window start time in milliseconds. UNIX epoch format
StringtrueGranularity, defined aggregation time window
IntegertrueThe total amount of executed trades in the defined aggregation time window
StringtrueOpen, the first execution price in the quote currency in the defined aggregation time window
StringtrueHigh, the maximum execution price in the quote currency in the defined aggregation time window
StringtrueLow, the minimum execution price in the quote currency in the defined aggregation time window
StringtrueClose, the last execution price in the quote currency in the defined aggregation time window
StringtrueTrade volume sum in the base currency in the defined aggregation time window
StringtrueVolume 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",
  "t": "request-trade-metrics-subscriptions-add",
  "p": {
    "subscriptions": [
      {
        "granularity": "1m",
        "marketId": "kucoin-eth-btc"
      }
    ]
  }
}
  1. Receive successful response
{
  "traceId": "uy34fw9",
  "t": "response-trade-metrics-subscriptions-add",
  "p": {
    "added": 1,
    "total": 1
  }
}
  1. Then start receiving market data feed you subscribed to:
{
  "t": "tm",
  "p": [
    "kucoin-eth-btc",
    1657837620000,
    "1m",
    9,
    "0.057735",
    "0.057735",
    "0.05772",
    "0.057721",
    "0.8873883",
    "0.057722864417527253852682078409192458363"
  ]
}