Market

Channel Update Frequency: 1s

The market channel pushes live information about the market such as the current market price and the lower & upper sanity bounds as well as reference data related to the market.

The websocket will reply with the shown success response format for each market which has been successfully subscribed to.

If a subscription has been made to market:all, the data array in the message from this channel will contain a JSON list of all markets. Each JSON will contain information for each market seperately. Otherwise the data array will contain a single JSON corresponding to one market per market channel subscription.

Curl

Request format

{
  "op": "subscribe", 
  "tag": 1,
  "args": ["market:all"]
}

OR

{
  "op": "subscribe", 
  "tag": 1,
  "args": ["market:OX-USDT", ........]
}

Success response format

{
  "event": "subscribe", 
  "channel": "<args value>",
  "success": True,
  "tag": "1",
  "timestamp": "1594299886890"
}

Channel update format

{
  "table": "market",
  "data": [ 
      {
          "marketId": "3001000000000",
          "marketCode": "OX-USDT",
          "name": "OX/USDT Spot",
          "referencePair": "OX/USDT",
          "base": "OX",
          "counter": "USDT",
          "type": "SPOT",
          "exclusive": "false",
          "tickSize": "0.001",
          "qtyIncrement": "0.1",
          "marginCurrency": "USDT",
          "contractValCurrency": "OX", 
          "upperPriceBound": "0.0495",
          "lowerPriceBound": "0.041",
          "marketPrice": "0.045",
      }, 
      ........
   ]
}
Python

Request format

import websockets
import asyncio
import json

market = \
{
  "op": "subscribe",
  "tag": 1,
  "args": ["market:all"]
}

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(market))
            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

market:all or a list of individual markets market:<marketCode>

Channel Update Fields

Fields
Type
Description

table

STRING

market

data

LIST of dictionaries

marketPrice

STRING

Mark price

qtyIncrement

STRING

Quantity increment

upperPriceBound

STRING

Upper sanity price bound

lowerPriceBound

STRING

Lower sanity price bound

counter

STRING

type

STRING

marketId

STRING

referencePair

STRING

tickSize

STRING

Tick size

marketPriceLastUpdated

STRING

Millisecond timestamp

contractValCurrency

STRING

name

STRING

marketCode

STRING

marginCurrency

STRING

base

STRING

Last updated