Candles

Channel Update Frequency: 500ms

Granularity: 60s, 180s, 300s, 900s, 1800s, 3600s, 7200s, 14400s, 21600s, 43200s, 86400s

The candles channel pushes candlestick data for the current candle.

Curl

Request format

{
  "op": "subscribe", 
  "tag": 1,
  "args": ["candles60s:BTC-USD-SWAP-LIN"]
}

Success response format

{
  "event": "subscribe", 
  "channel": ["candles60s:BTC-USD-SWAP-LIN"], 
  "success": True, 
  "tag": "1", 
  "timestamp": "1594313762698"
}

Channel update format

{
  "table": "candle60s",
  "data": [ {
              "marketCode": "BTC-USD-SWAP-LIN",
              "candle": [
                "1594313762698", //timestamp
                "9633.1",        //open
                "9693.9",        //high
                "9238.1",        //low
                "9630.2",        //close
                "45247",         //volume in OX
                "5.3"            //volume in Contracts
              ]
          } ]
}
Python

Request format

import websockets
import asyncio
import json

candles = \
{
  "op": "subscribe",
  "tag": 1,
  "args": ["candles60s:BTC-USD-SWAP-LIN"]
}

url= 'wss://api.ox.fun/v2/websocket'
async def subscribe():
    async with websockets.connect(url) as ws:
        while True:
            if not ws.open:
                print("websocket disconnected")
                ws = await websockets.connect(url)
            response = await ws.recv()
            data = json.loads(response)
            print(data)
            if 'nonce' in data:
                await ws.send(json.dumps(candles))
            elif 'success' in data and data['success'] == 'True':
                continue
asyncio.get_event_loop().run_until_complete(subscribe())

Request Parameters

Parameters
Type
Required
Description

op

STRING

Yes

subscribe

tag

INTEGER or STRING

No

If given it will be echoed in the reply and the max size of tag is 32

args

LIST

Yes

list of individual candle granularity and market candles<granularity>:<marketCode>

Channel Update Fields

Fields
Type
Description

table

STRING

candles<granularity>

data

LIST of dictionary

marketCode

STRING

Market code

candle

LIST of strings

  1. timestamp

  2. open

  3. high

  4. low

  5. close

  6. volume in counter currency

  7. volume in base currency

Last updated