Token trading

Contract Price API

Receive the latest OKEX contract data
Resource Description
ok_sub_futureusd_X_ticker_Y Subscribe Contract Market Price

websocket.send("{'event':'addChannel','channel':'ok_sub_futureusd_X_ticker_Y'}");

Example

# Request 
{'event':'addChannel','channel':'ok_sub_futureusd_btc_ticker_this_week'}
# Response
[{
    "data":{
        "limitHigh": "1030.3",
        "vol": 276406,
        "last": 998.05,
        "sell": 998.05,
        "buy": 997.61,
        "unitAmount": 100,
        "hold_amount": 180178,
        "contractId": 20170324034,
        "high": 1049.18,
        "low": 973.15,
        "limitLow": "968.1"
    },
    "channel":"ok_sub_futureusd_btc_ticker_this_week"
}]

返回值说明

limitHigh(string):maximum buy price
limitLow(string):minimum sell price
vol(double):trade volumes within 24 hours
sell(double):sell one price
unitAmount(double):union amount
hold_amount(double):position
contractId(long):contract id
high(double):the highest price within 24 hours
low(double):the lowest price within 24 hours

ok_sub_futureusd_X_kline_Y_Z Subscribe Contract Candlestick Chart Data

websocket.send("{'event':'addChannel','channel':'ok_sub_futureusd_X_kline_Y_Z'}");

Example

# Request 
{'event':'addChannel','channel':'ok_sub_futureusd_btc_kline_this_week_1min'}
# Response
[{
    "data":[
        [
            "1490340480000",
            "998.96",
            "998.96",
            "998.96",
            "998.96",
            "12.0",
            "1.201249299271"
        ]
    ],
    "channel":"ok_sub_futureusd_btc_kline_this_week_1min"
}]

Returned Value Description

[time, open price, highest price, lowest price, close price, volume]
[string, string, string, string, string, string]
ok_sub_futureusd_X_depth_Y Subscribe Contract Market Depth(Incremental)

websocket.send("{'event':'addChannel','channel':'ok_sub_futureusd_X_depth_Y'}");

Example

# Request
{'event':'addChannel','channel':'ok_sub_futureusd_btc_depth_this_week'}
# Response
[
    {
        "data": {
            "timestamp": 1490337551299,
            "asks": [
                [
                    "996.72",
                    "20.0",
                    "2.0065",
                    "85.654",
                    "852.0"
                ]
            ],
            "bids": [
                [
                    "991.67",
                    "6.0",
                    "0.605",
                    "0.605",
                    "6.0"
                ]
        },
        "channel": "ok_sub_futureusd_btc_depth_this_week"
    }
]

Returned Value Description

timestamp(long): Server timestamp
asks(array): Ask depth Array index(string) [Price, Amount(Contract), Amount(Coin),Cumulant(Coin),Cumulant(Contract)]
bids(array): Bid depth Array index(string) [Price, Amount(Contract), Amount(Coin),Cumulant(Coin),Cumulant(Contract)]

Incremental data return (Return full data for the first query)
Delete (BTC/LTC amount is 0)
Edit (Same price, different amount)
Add (Price inexist)
bids([double, double]): Bid depth
asks([double, double]): Ask depth
timestamp: Server timestamp

ok_sub_futureusd_X_depth_Y_Z Subscribe Contract Market Depth(Full)

websocket.send("{'event':'addChannel','channel':'ok_sub_futureusd_X_depth_Y_Z%>'}");

Example

# Request 
{'event':'addChannel','channel':'ok_sub_futureusd_btc_depth_this_week_20'}
# Response
[
    {
        "data": {
            "timestamp": 1490337551299,
            "asks": [
                [
                    "996.72",
                    "20.0",
                    "2.0065",
                    "85.654",
                    "852.0"
                ]
            ],
            "bids": [
                [
                    "991.67",
                    "6.0",
                    "0.605",
                    "0.605",
                    "6.0"
                ]
        },
        "channel": "ok_sub_futureusd_btc_depth_this_week_20"
    }
]

Returned Value Description

timestamp(long): Server timestamp
asks(array): Ask depth Array index(string) [Price, Amount(Contract), Amount(Coin),Cumulant(Coin),Cumulant(Contract)]
bids(array): Bid depth Array index(string) [Price, Amount(Contract), Amount(Coin),Cumulant(Coin),Cumulant(Contract)]
					
ok_sub_futureusd_X_trade_Y Subscribe Contract Trade Record

websocket.send("{'event':'addChannel','channel':'ok_sub_futureusd_X_trade_Y'}");

Example

# Request 
{'event':'addChannel','channel':'ok_sub_futureusd_btc_trade_this_week'}
# Response
[
    {
        "data": [
            [
                "732916869",
                "999.49",
                "12.0",
                "15:25:03",
                "ask",
                "1.2006"
            ],
            [
                "732916871",
                "999.49",
                "2.0",
                "15:25:03",
                "ask",
                "0.2001"
            ],
            [
                "732916899",
                "999.49",
                "2.0",
                "15:25:04",
                "ask",
                "0.2001"
            ]
        "channel": "ok_sub_futureusd_btc_trade_this_week"
    }
]
                            

Returned Value Description

[tid, price, amount, time, type,amountbtc]
[string, string, string, string, string, string,string]
ok_sub_futureusd_X_index Subscribe Contract Index Price

websocket.send("{'event':'addChannel','channel':'ok_sub_futureusd_X_index'}");

Example

# Request
{'event':'addChannel','channel':'ok_sub_futureusd_btc_index'}
# Response
[
    {
        "data": {
            "timestamp": "1490341322021",
            "futureIndex": "998.0"
        },
        "channel": "ok_sub_futureusd_btc_index"
    }
]
                            

Returned Value Description

futureIndex: current future index price
timestamp: server timestamp
X_forecast_price Estimated futures delivery price

Example

# Response
[{
    "channel": "btc_forecast_price",
    "timestamp":"1490341322021",
    "data": "998.8"
}]

Returned Value Description

Estimated futures delivery price
data(string): Estimated delivery price
timestamp(string): timestamp
Hint: This does not need to be subscribed and will be automatically returned 1 hour prior to delivery.

Contract Trade API

Easily place contract orders on OKEX
Resource Description
login Login(Personal Information)

Example

# Request
{"event":"login","parameters":{"api_key":"xxx","sign":"xxx"}}
# Response
[
    {
        "binary": 0,
        "channel": "login",
        "data": {
            "result": true
        }
    }
]

Request Parameters

Parameter Name Description

api_key

apiKey of the user

sign

signature of request parameters

Description

The data will return when it changed. These types need not be subscribed.
eg:ok_sub_futureusd_trades,ok_sub_futureusd_userinfo,ok_sub_futureusd_positions
ok_futureusd_trade Place Contract order

websocket.send("{'event':'addChannel','channel':'ok_futureusd_trade','parameters': {'api_key':'XXXX','sign':'XXXX','symbol':'btc_usd','contract_type':'this_week', 'price':'356.5','amount':'2','type':'1','match_price':'0','lever_rate':'20'}}");

Example

# Request
{
    'event': 'addChannel',
    'channel': 'ok_futureusd_trade',
    'parameters': {
        'api_key': 'XXXX',
        'sign': 'XXXX',
        'symbol': 'btc_usd',
        'contract_type': 'this_week',
        'price': '356.5',
        'amount': '2',
        'type': '1',
        'match_price': '0',
        'lever_rate': '20'
    }
} 
# Response
[
    {
        "data":{
            "result":true,
            "order_id":5017287829
        },
        "channel":"ok_futureusd_trade"
    }
]

Returned Value Description

order_id(long): order ID
result(boolean):  request result

Request Parameters

Parameter Name Description

api_key

apiKey of the user

sign

signature of request parameters

symbol

btc_usd   ltc_usd   eth_usd   etc_usd   bch_usd

contract_type

contract type: this_week next_week quarter

price

order price

amount

order quantity

type

1: open long position 2: open short position 3: liquidate long position 4: liquidate short position

match_price

match best counter party price? 0: No 1: Yes If yes, the 'price' field is invalidated

lever_rate

leverage rate value:10/20 (10 by default)

ok_futureusd_cancel_order Cancel Order

websocket.send("{'event':'addChannel','channel':'ok_futureusd_cancel_order','parameters': {'api_key':'XXXX','sign':'XXXX','symbol':'btc_usd','order_id':'125433027','contract_type':'this_week'}}");

Example

# Request
{
    'event': 'addChannel',
    'channel': 'ok_futureusd_cancel_order',
    'parameters': {
        'api_key': 'XXXX',
        'sign':'XXXX',
        'symbol': 'btc_usd',
        'order_id': '125433027',
        'contract_type': 'this_week'
    }
}
# Response
[
    {
        "data":{
            "result":true,
            "order_id":"5017402127"
        },
        "channel":"ok_futureusd_cancel_order"
    }
]

Returned Value Description

order_id(string): order ID
result(boolean):  request result

Request Parameters

Parameter Name Description

api_key

apiKey of the user

sign

signature of request parameters

symbol

btc_usd   ltc_usd   eth_usd   etc_usd   bch_usd

order_id

order ID

contract_type

contract type: this_week next_week quarter

ok_futureusd_userinfo Get User Account Info

websocket.send("{'event':'addChannel','channel':'ok_futureusd_userinfo','parameters': {'api_key':'XXXX','sign':'XXXX'}}");

Example

# Request
{
    'event':'addChannel',
    'channel':'ok_futureusd_userinfo',
    'parameters':{
        'api_key':'XXXX',
        'sign':'XXXX'
    }
}
# Response
in fixed margin, return:
[{
    "channel": "ok_futureusd_userinfo",
    "data": {
        "info": {
            "btc": {
                "balance": 0.00000673,
                "contracts": [{
                    "available": 0.00000673,
                    "balance": 0,
                    "bond": 0,
                    "contract_id": 20150327013,
                    "contract_type": "quarter",
                    "freeze": 0,
                    "profit": 0,
                    "unprofit": 0
                }],
                "rights": 0.00000673
            },
            "ltc": {
                "balance": 0.00007773,
                "contracts": [{
                    "available": 16.5915,
                    "balance": 0,
                    "bond": 0.70871722,
                    "contract_type": "this_week",
                    "contractid": 20150130115,
                    "freeze": 0,
                    "profit": 17.30020414,
                    "unprofit": -1.8707
                }, {
                    "available": 0.00007773,
                    "balance": 0.03188496,
                    "bond": 0,
                    "contract_type": "quarter",
                    "contractid": 20150327116,
                    "freeze": 0,
                    "profit": -0.03188496,
                    "unprofit": 0
                }],
                "rights": 0.00007773
            }
        },
        "result": true
    }
}]

in cross margin, return:
[{
    "channel": "ok_futureusd_userinfo",
    "data": {
        "info": {
            "btc": {
                "account_rights": 1,
                "keep_deposit": 0,
                "profit_real": 3.33,
                "profit_unreal": 0,
                "risk_rate": 10000
            },
            "ltc": {
                "account_rights": 2,
                "keep_deposit": 2.22,
                "profit_real": 3.33,
                "profit_unreal": 2,
                "risk_rate": 10000
            }
        },
        "result": true
    }
}]

Returned Value Description

in cross margin :
account_rights(double):Account Equity
keep_deposit(double):Margin
profit_real(double):realized
profit_unreal(double):Un Realized
risk_rate(double):Margin Ratio(Cross-margin margin ratio = equity/margin – x; BTC: 10x leverage, x = 0.1, 20x leverage, x = 0.2; LTC 10x leverage, x = 0.2, 20x leverage, x = 0.4)

in fixed margin
balance(double):account balance
available(double):available fund
balance(double):contract balance
bond(double):fixed margin
contract_id(long):contract id
contract_type(string):contract type
freeze(double):frozen
profit(double):realized
unprofit(double):Un Realized

Request Parameters

Parameter Name Description

api_key

apiKey of the user

sign

signature of request parameters

ok_futureusd_orderinfo Get User Contract Order

websocket.send("{'event':'addChannel','channel':'ok_futureusd_orderinfo','parameters': {'api_key':'XXXX','sign':'XXXX','symbol':'ltc_usd','order_id':'20914907', 'contract_type':'this_week','status':'1','current_page':'1','page_length':'1'}}");

Example

# Request
{
    'event': 'addChannel',
    'channel': 'ok_futureusd_orderinfo',
    'parameters': {
        'api_key': 'XXXX',
        'sign': 'XXXX',
        'symbol': 'ltc_usd',
        'order_id': '20914907',
        'contract_type': 'this_week',
        'status': '1',
        'current_page': '1',
        'page_length': '1'
    }
}
# Response
[{
    "channel": "ok_futureusd_orderinfo",
    "data": {
        "orders": [{
            "amount": 1,
            "contract_name": "LTC0130",
            "create_date": 1422504149000,
            "deal_amount": 0,
            "fee": 0,
            "lever_rate": 10,
            "order_id": 107344334,
            "price": 1.5,
            "price_avg": 0,
            "status": 0,
            "symbol": "ltc_usd",
            "type": 1,
            "unit_amount": 10
        }],
        "result": true
    }
}]

Returned Value Description

amount(double): order quantity
contract_name(string): contract name
created_date(long): order time
deal_amount(double): filled quantity
fee(double): transaction fee
order_id(long): order ID
price(double): order price
price_avg(double): average price
status(int): -1 = cancelled, 0 = unfilled, 1 = partially filled, 2 = fully filled, 4 = cancel request in process
symbol(int): btc_usd   ltc_usd   eth_usd   etc_usd   bch_usd
type(int): order type 1: open long, 2: open short, 3: close long, 4: close short
unit_amount(double): contract par value
lever_rate(double):leverage rate value, 10 or 20, default 10

Request Parameters

Parameter Name Description

api_key

apiKey of the user

sign

signature of request parameters

symbol

btc_usd   ltc_usd   eth_usd   etc_usd   bch_usd

order_id

order ID -1:return all unfilled orders, otherwise return the order that the ID specifies

contract_type

contract type: this_week next_week quarter

status

query by order status 1: unfilled 2: filled

current_page

current page number

page_length

number of orders per page, maximum 50

ok_sub_futureusd_trades Subscribe Contract Trade Records

Example

# Response
[{
        "data":{
            amount:1
            contract_id:20170331115,
            contract_name:"LTC0331",
            contract_type:"this_week",
            create_date:1490583736324,
            create_date_str:"2017-03-27 11:02:16",
            deal_amount:0,
            fee:0,
            lever_rate:20,
            orderid:5058491146,
            price:0.145,
            price_avg:0,
            status:0,
            system_type:0,
            type:1,
            unit_amount:10,
            user_id:101
        },
        "channel":"ok_sub_futureusd_trades"
    }
]

Returned Value Description

amount (double): order quantity
contract_id (long): contract ID
create_date_str(string): create date
create_date(long):	create date
contract_name (string): contract name
contract_type(string): contract type
deal_amount(string) : filled quantity
fee (string): transaction fee
orderid (long) : order ID
price(double) : order price
price_avg (double) : average price
status (int):  -1 = cancelled, 0 = unfilled, 1 = partially filled, 2 = fully filled, 4 = cancel request in process
type (int): order type 1: open long, 2: open short, 3: close long, 4: close short
unit_amount(double) : contract par value
lever_rate (double): leverage rate

Request Parameters

Parameter Name Description

api_key

apiKey of the user

sign

signature of request parameters

ok_sub_futureusd_userinfo Contract User Info

Example

# Response
Fix Margin Model Account Info
 [{
        "data":{
            "balance":10.16491751,
            "symbol":"ltc_usd",
            "contracts":[
                {
                    "bond":0.50922987,
                    "balance":0.50922987,
                    "profit":0,
                    "freeze":1.72413792,
                    "contract_id":20170331115,
                    "available":6.51526374
                },
                {
                    "bond":0,
                    "balance":0,
                    "profit":0,
                    "freeze":1.64942529,
                    "contract_id":20170407135,
                    "available":6.51526374
                },
                {
                    "bond":0,
                    "balance":0,
                    "profit":0,
                    "freeze":0.27609056,
                    "contract_id":20170630116,
                    "available":6.51526374
                }
            ]
        },
        "channel":"ok_sub_futureusd_userinfo"
    }]
The Cross Margin Account Info

[{
	"data":{
		"balance":0.2567337,
		"symbol":"btc_usd",
		"keep_deposit":0.0025,
		"profit_real":-0.00139596,
		"unit_amount":100
	},
	"channel":"ok_sub_futureusd_userinfo"
}]

Returned Value Description

The Cross Margin Account Info

balance(double): Balance
symbol(double):Currency
keep_deposit(double):Margin
profit_real(double):RPL
unit_amount(double):Par value

Fix Margin Model Account Info

balance: account balance
available(double):available fund
balance(double): contract balance
bond(double):fixed margin
contract_id(long): contract id
contract_type(string): contract type
freeze(double):frozen
profit(double):realized
unprofit(double):Un Realized

Description

There is no need to subscribe to the login, compatible with the old subscription, the old subscription is equivalent to the login operation.
Response:
[{"data":{"result":"true"},"channel":"login"}]
				
ok_sub_futureusd_positions Contract User Position Info
# Response
The Cross Margin Account Info
[{
        "data":{
            "positions":[
                {
                    "position":"1",
                    "contract_name":"BTC0630",
                    "costprice":"994.89453079",
                    "bondfreez":"0.0025",
                    "avgprice":"994.89453079",
                    "contract_id":20170630013,
                    "position_id":27782857,
                    "eveningup":"0",
                    "hold_amount":"0",
                    "margin":0,
                    "realized":0
                },
                {
                    "position":"2",
                    "contract_name":"BTC0630",
                    "costprice":"1073.56",
                    "bondfreez":"0.0025",
                    "avgprice":"1073.56",
                    "contract_id":20170630013,
                    "position_id":27782857,
                    "eveningup":"0",
                    "hold_amount":"0",
                    "margin":0,
                    "realized":0
                }
            ],
            "symbol":"btc_usd",
            "user_id":101
        },
        "channel":"ok_sub_futureusd_positions"
}]
Fix Margin Model Account Info

[{
	"data":{
		"positions":[
			{
				"position":"1",
				"profitreal":"0.0",
				"contract_name":"LTC0407",
				"costprice":"0.0",
				"bondfreez":"1.64942529",
				"forcedprice":"0.0",
				"avgprice":"0.0",
				"lever_rate":10,
				"fixmargin":0,
				"contract_id":20170407135,
				"balance":"0.0",
				"position_id":27864057,
				"eveningup":"0.0",
				"hold_amount":"0.0"
			},
			{
				"position":"2",
				"profitreal":"0.0",
				"contract_name":"LTC0407",
				"costprice":"0.0",
				"bondfreez":"1.64942529",
				"forcedprice":"0.0",
				"avgprice":"0.0",
				"lever_rate":10,
				"fixmargin":0,
				"contract_id":20170407135,
				"balance":"0.0",
				"position_id":27864057,
				"eveningup":"0.0",
				"hold_amount":"0.0"
			}
		"symbol":"ltc_usd",
		"user_id":101
	}]

Returned Value Description

The Cross Margin Account Info

position(string): position 1 long 2 short
contract_name(string): contract name
costprice(string): cost price
bondfreez(string): freezed bond
avgprice(string): average open price
contract_id(long): contract id
position_id(long): position id
hold_amount(string): hold amount
eveningup(string): evening up
margin(double): margin
realized(double):real profit

Fix Margin Model Account Info

contract_id(long): contract id
contract_name(string): contract name
avgprice(string): average open price
balance(string): account (contract) balance
bondfreez(string): freezed bond
costprice(string): cost price
eveningup(string): evening up
forcedprice(string):  forced price
position(string): position 1 long 2 short
profitreal(string):  real profit
fixmargin(double): fixed margin
hold_amount(string): hold amount
lever_rate(double): lever rate
position_id(long): position id
symbol(string): btc_usd   ltc_usd   eth_usd   etc_usd   bch_usd
user_id(long):user_id

Description

There is no need to subscribe to the login, compatible with the old subscription, the old subscription is equivalent to the login operation.
Response:
[{"data":{"result":"true"},"channel":"login"}]
				

Spot Price API

Receive the latest OKEx Spot data
Resource Description
ok_sub_spot_X_ticker  New Subscribe Price Ticker

websocket.send("{'event':'addChannel','channel':'ok_sub_spot_X_ticker'}");

Example

# Request
{'event':'addChannel','channel':'ok_sub_spot_bch_btc_ticker'}
# Response
[
    {
        "binary": 0,
        "channel": "ok_sub_spot_bch_btc_ticker",
        "data": {
            "high": "10000",
            "vol": "185.03743858",
            "last": "111",
            "low": "0.00000001",
            "buy": "115",
            "change": "101",
            "sell": "115",
            "dayLow": "0.00000001",
            "dayHigh": "10000",
            "timestamp": 1500444626000
        }
    }
]

Returned Value Description

buy(double): best bid
high(double): highest price
last(double): latest price
low(double): lowest price
sell(double): best ask
timestamp(long): timestamp
vol(double: volume(the most recent 24 hours)
ok_sub_spot_X_depth  New Subscribe Market Depth(Increment)

websocket.send("{'event':'addChannel','channel':'ok_sub_spot_X_depth'}");

Example

# Request
{'event':'addChannel','channel':'ok_sub_spot_bch_btc_depth'}
# Response
[
    {
        "binary": 0,
        "channel": "ok_sub_spot_bch_btc_depth",
        "data": {
            "asks": [],
            "bids": [
                [
                    "115",
                    "1"
                ],
                [
                    "114",
                    "1"
                ],
                [
                    "1E-8",
                    "0.0008792"
                ]
            ],
            "timestamp": 1504529236946
        }
    }
]

Returned Value Description

Incremental data return (Return full data for the first query)
Delete (BTC/LTC amount is 0)
Edit (Same price, different amount)
Add (Price inexist)

bids([string, string]):bids depth
asks([string, string]):asks depth
timestamp(long): server timestamp
ok_sub_spot_X_depth_Y  New Subscribe Market Depth(Full)

websocket.send("{'event':'addChannel','channel':'ok_sub_spot_X_depth_Y'}");

Example

# Request
{'event':'addChannel','channel':'ok_sub_spot_bch_btc_depth_5'}
# Response
[
    {
        "binary": 0,
        "channel": "ok_sub_spot_bch_btc_depth_5",
        "data": {
            "asks": [],
            "bids": [
                [
                    "115",
                    "1"
                ],
                [
                    "114",
                    "1"
                ],
                [
                    "1E-8",
                    "0.0008792"
                ]
            ],
            "timestamp": 1504529432367
        }
    }
]

Returned Value Description

bids[string, string]: bids depth
asks[string, string]: asks depth
timestamp(long): server timestamp
ok_sub_spot_X_deals  New Subscribe Trade Records

Example

# Request
{'event':'addChannel','channel':'ok_sub_spot_bch_btc_deals'}
# Response
[{
    "channel":"ok_sub_spot_bch_btc_deals",
    "data":[["1001","2463.86","0.052","16:34:07","ask"]]
}]

Returned Value Description

[tid, price, amount, time, type]
[string, string, string, string, string]
ok_sub_spot_X_kline_Y  New Subscribe Candlestick Chart Data

websocket.send("{'event':'addChannel','channel':'ok_sub_spot_X_kline_Y'}");

Example

# Request
{'event':'addChannel','channel':'ok_sub_spot_bch_btc_kline_1min'}
# Response
[{
    "channel":"ok_sub_spot_bch_btc_kline_1min",
    "data":[
        ["1490337840000","995.37","996.75","995.36","996.75","9.112"],
        ["1490337840000","995.37","996.75","995.36","996.75","9.112"]
    ]
}]

Returned Value Description

[time, open price, highest price, lowest price, close price, volume]
[string, string, string, string, string, string]

Spot Trade API

Easily place spot orders on OKEx
Resource Description
login  New Login(Personal Information)

Example

# Request
{"event":"login","parameters":{"api_key":"xxx","sign":"xxx"}}
# Response
[
    {
        "binary": 0,
        "channel": "login",
        "data": {
            "result": true
        }
    }
]

Request Parameters

Parameter Name Description

api_key

apiKey of the user

sign

signature of request parameters

Description

The data will return when it changed. These types need not be subscribed.
eg:ok_sub_spot_X_order,ok_sub_spot_X_balance
ok_spot_order  New Place Orders

websocket.send("{'event':'addChannel','channel':'ok_spot_order','parameters': {'api_key':'XXXX','sign':'XXXX','symbol':'bch_btc','type':'buy','price':'50','amount':'0.02'}}");

Example

# Request
{
    'event':'addChannel',
    'channel':'ok_spot_order',
    'parameters':{
        'api_key':'XXXX',
        'sign':'XXXX',
        'symbol':'bch_btc',
        'type':'buy',
        'price':'50',
        'amount':'0.02'
    }
}
# Response
[
    {
        "binary": 0,
        "channel": "ok_spot_order",
        "data": {
            "result": true,
            "order_id": 6189
        }
    }
]

Returned Value Description

order_id(long):order id
result(boolean):execute result

Request Parameters

Parameter Name Description

api_key

apiKey of the user

sign

signature of request parameters

symbol

ltc_btc eth_btc etc_btc bch_btc btc_usdt eth_usdt ltc_usdt etc_usdt bch_usdt etc_eth bt1_btc bt2_btc btg_btc qtum_btc hsr_btc neo_btc gas_btc qtum_usdt hsr_usdt neo_usdt gas_usdt

type

order Type: limit order (buy/sell) market order (buy_market/sell_market)

price

order price [limit order buy (required): price between 0~1,000,000 | market order buy (required): BTC:price bigger than (0.01 * best ask price) / LTC :price bigger than (0.1 * best ask price) / ETH :price bigger than (0.01 * best ask price)]

amount

order quantity:[limit order sell (required): BTC quantity not less than 0.01 / LTC quantity not less than 0.1 / ETH quantity not less than 0.01| market order sell (required): BTC quantity not less than 0.01 / LTC quantity not less than 0.1 / ETH quantity not less than 0.01]

ok_spot_cancel_order  New Cancel Order

websocket.send("{'event':'addChannel','channel':'ok_spot_cancel_order','parameters': {'api_key':'XXXX','sign':'XXXX','symbol':'bch_btc','order_id':'125433027'}}");

Example

# Request 
{
    'event':'addChannel',
    'channel':'ok_spot_cancel_order',
    'parameters':{
        'api_key':'XXXX',
        'sign':'XXXX',
        'symbol':'bch_btc',
        'order_id':'125433027'
    }
}
# Response
[
    {
        "binary": 0,
        "channel": "ok_spot_cancel_order",
        "data": {
            "result": true,
            "order_id": "125433027"
        }
    }
]

Returned Value Description

order_id(long):order id
result(boolean):execute result

Request Parameters

Parameter Name Description

api_key

apiKey of the user

sign

signature of request parameters

symbol

ltc_btc eth_btc etc_btc bch_btc btc_usdt eth_usdt ltc_usdt etc_usdt bch_usdt etc_eth bt1_btc bt2_btc btg_btc qtum_btc hsr_btc neo_btc gas_btc qtum_usdt hsr_usdt neo_usdt gas_usdt

order_id

order Id

ok_spot_userinfo  New Get User Account Info

websocket.send("{'event':'addChannel','channel':'ok_spot_userinfo','parameters': {'api_key':'XXXX','sign':'XXXX'}}");

Example

# Request 
{
    'event':'addChannel',
    'channel':'ok_spot_userinfo',
    'parameters':{
        'api_key':'XXXX',
        'sign':'XXXX'
    }
}
# Response
[
    {
        "binary": 0,
        "channel": "ok_spot_userinfo",
        "data": {
            "result": true,
            "info": {
                "funds": {
                    "free": {
                        "btc": "5927.8506057903954517",
                        "bch": "49982.615135298639",
                        "bcs": "60000",
                        "etc": "40000",
                        "eth": "30000",
                        "ltc": "20001.09989"
                    },
                    "freezed": {
                        "btc": "7228",
                        "bch": "0",
                        "bcs": "0",
                        "etc": "0",
                        "eth": "0",
                        "ltc": "0"
                    }
                }
            }
        }
    }
]

Returned Value Description

free: available fund
freezed: frozen fund

Request Parameters

Parameter Name Description

api_key

apiKey of the user

sign

signature of request parameters

ok_spot_orderinfo  New Get Order Info

websocket.send("{'event':'addChannel','channel':'ok_spot_orderinfo','parameters': {'api_key':'XXXX','sign':'XXXX','symbol':'bch_btc','order_id':'20914907'}}");

Example

# Request
{
    'event':'addChannel',
    'channel':'ok_spot_orderinfo',
    'parameters':{
        'api_key':'XXXX',
        'sign':'XXXX',
        'symbol':'bch_btc',
        'order_id':'20914907'
    }
}
# Response
[
    {
        "binary": 0,
        "channel": "ok_spot_orderinfo",
        "data": {
            "result": true,
            "orders": [
                {
                    "symbol": "bch_btc",
                    "amount": "0.10000000",
                    "price": "1.00000000",
                    "avg_price": 0,
                    "create_date": 1504529828000,
                    "type": "buy",
                    "deal_amount": 0,
                    "order_id": 6189,
                    "status": -1
                }
            ]
        }
    }
]

Returned Value Description

amount(double): order quantity
create_date(double): order time
avg_price(double): average transaction price
deal_amount(double): filled quantity
order_id(long): order ID
orders_id(long): order ID (Deprecated)
price(double): order price
status(int): -1 = cancelled, 0 = unfilled, 1 = partially filled, 2 = fully filled, 4 = cancel request in process,5 = cancel request in process
symbol(string):ltc_btc  eth_btc  etc_btc  bch_btc  btc_usdt  eth_usdt  ltc_usdt  etc_usdt  bch_usdt  etc_eth  bt1_btc  bt2_btc  btg_btc qtum_btc hsr_btc neo_btc gas_btc qtum_usdt hsr_usdt neo_usdt gas_usdt
type(string): buy_market = market buy order, sell_market = market sell order

Request Parameters

Parameter Name Description

api_key

apiKey of the user

sign

signature of request parameters

symbol

ltc_btc eth_btc etc_btc bch_btc btc_usdt eth_usdt ltc_usdt etc_usdt bch_usdt etc_eth bt1_btc bt2_btc btg_btc qtum_btc hsr_btc neo_btc gas_btc qtum_usdt hsr_usdt neo_usdt gas_usdt

order_id

order ID

ok_sub_spot_X_order  New Trade Record

Example

# Response
[
    {
        "base": "bch",
        "binary": 0,
        "channel": "ok_sub_spot_bch_btc_order",
        "data": {
            "symbol": "bch_btc",
            "tradeAmount": "1.00000000",
            "createdDate": "1504530228987",
            "orderId": 6191,
            "completedTradeAmount": "0.00000000",
            "averagePrice": "0",
            "tradePrice": "0.00000000",
            "tradeType": "buy",
            "status": 0,
            "tradeUnitPrice": "113.00000000"
        },
        "product": "spot",
        "quote": "btc",
        "type": "balance"
    }
]

Returned Value Description

createdDate(string): created date
orderId(long): order ID
tradeType(string): trade type (buy: buy;sell: sell;buy_market: buy at market price;sell_market: sell at market price)
sigTradeAmount(string):quantity in a single transaction
sigTradePrice(string):rate in a single transaction
tradeAmount(string):for market sell orders: total sell quantity, for limit orders: order quantity
tradeUnitPrice(string):for market buy orders: total buy amount, for limit orders: order rate
symbol(string):ltc_btc  eth_btc  etc_btc  bch_btc  btc_usdt  eth_usdt  ltc_usdt  etc_usdt  bch_usdt  etc_eth  bt1_btc  bt2_btc  btg_btc qtum_btc hsr_btc neo_btc gas_btc qtum_usdt hsr_usdt neo_usdt gas_usdt
completedTradeAmount(string): filled 'tradeAmount'
tradePrice(string): filled amount
averagePrice(string): average transaction price
unTrade(string): unfilled amount in usd for market order, unfilled coin quantity for limit order
status(int): -1: cancelled, 0: pending, 1: partially filled, 2: fully filled, 4: cancel request in process

Description

There is no need to subscribe to the login, compatible with the old subscription, the old subscription is equivalent to the login operation.
Response:
[
    {
        "binary": 0,
        "channel": "login",
        "data": {
            "result": true
        }
    }
]
ok_sub_spot_X_balance  New User Account Info

Example

# Response
[
    {
        "base": "bch",
        "binary": 0,
        "channel": "ok_sub_spot_bch_btc_balance",
        "data": {
            "info": {
                "free": {
                    "btc": 5814.850605790395
                },
                "freezed": {
                    "btc": 7341
                }
            }
        },
        "product": "spot",
        "quote": "btc",
        "type": "order"
    }
]

Returned Value Description

free: available fund
freezed: frozen fund

Description

There is no need to subscribe to the login, compatible with the old subscription, the old subscription is equivalent to the login operation.
Response:
[
    {
        "binary": 0,
        "channel": "login",
        "data": {
            "result": true
        }
    }
]
提示

请先登录

客服+852 5808 5768
在线咨询 在线咨询
在线留言 发起提问
聊天室
OKEX聊天室
请遵守聊天室规则!详情>>
客服+852 5808 5768
聊天室规则 X