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
Type | Required | Description |
---|---|---|
String | true | Market ID |
Integer | true | Timestamp, aggregation window start time in milliseconds. UNIX epoch format |
String | true | Granularity, defined aggregation time window |
Integer | true | The total amount of executed trades in the defined aggregation time window |
String | true | Open, the first execution price in the quote currency in the defined aggregation time window |
String | true | High, the maximum execution price in the quote currency in the defined aggregation time window |
String | true | Low, the minimum execution price in the quote currency in the defined aggregation time window |
String | true | Close, the last execution price in the quote currency in the defined aggregation time window |
String | true | Trade volume sum in the base currency in the defined aggregation time window |
String | true | Volume weighted average price in the defined aggregation time window. sum(volume * price) / sum(volume) |
Example
- Subscribe to one market with
1m
granularity:
{
"traceId": "uy34fw9",
"t": "request-trade-metrics-subscriptions-add",
"p": {
"subscriptions": [
{
"granularity": "1m",
"marketId": "kucoin-eth-btc"
}
]
}
}
- Receive successful response
{
"traceId": "uy34fw9",
"t": "response-trade-metrics-subscriptions-add",
"p": {
"added": 1,
"total": 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"
]
}