Session Management API

Session Management API Receive the latest OKCoin contract data
Resource Description
LOGON(A) Logon

Description

LOGON(A) is the first message sent by the client to the exchange and is used to initiate a session. If authentication succeeds, the exchange should echo the message back to the client. If authentication fails, the exchange should send a LOGOUT(5) message with an appropriate reason.

Request Parameters

Tag Name Required Comments

108  

HeartBtInt

  Yes  

Used to declare the timeout interval in seconds for generating heartbeats(same value used by both sides). The value should be agreed upon by both sides and specified by the logon initiator and echoed back by the logon acceptor. Default value: 30

141

ResetSeqNumFlag

No

Indicates whether both sides should reset sequence numbers

553

Username

Yes

API authenticated 'apiKey'

554

Password

Yes

API authenticated 'secretKey'

LOGOUT(5) Logout

Description

LOGOUT(5) can be sent by either party in order to terminate a session. The sending party should always wait for the echo of the logout request before they close the socket. Closing connections in any other way is considered abnormal behavior.

Request Parameters

Tag Name Required Comments

58

Text

No

Free format text string specifying the logout reason.

8500

LogoutReason

No

Indicates logout reason. While this fied is not required, it is recommended to always specify a reason when sending a logout message to client.
0 -- client initiated logout
1 -- invalid credentials
2 -- timeout
3 -- server error

HEARTBEAT(0) Heartbeat

Description

When either end of a FIX connection has not sent or received any data for [HeartBtInt] seconds (as specified in the Logon (A) message), it will transmit a Heartbeat (0) message. When either end of a FIX connection has not received any data for [HeartBtInt] seconds, it will transmit a Test Request Message (1). If there is still no response, the session should be considered lost and corrective action should be initiated.

Request Parameters

Tag Name Required Comments

112

TextReqID

No

Required when the heartbeat is the result of a TestRequest (1) message.

553

Username

Yes

required, should be set to 'apiKey'

554

Password

Yes

required, should be set to 'secretKey'

TEST REQUEST(1) Test Request

Description

The Test Request (1) message forces a heartbeat from the opposing application. The opposing application responds with a Heartbeat (0) containing the original TestReqID.

Request Parameters

Tag Name Required Comments

112

TextReqID

Yes

Mirrors the original request ID.

RESEND REQUEST(2) Resend Request

Description

The Resend Request (2) message is used by either party to initiate the retransmission of messages. This function is utilized if a sequence number gap is detected, if the receiving application lost a message, or as a function of the initialization process.

Request Parameters

Tag Name Required Comments

7

BeginSeqNo

Yes

16

EndSeqNo

Yes

REJECT(3) Reject

Description

The Reject (3) message should be issued when a message is received but cannot be properly processed due to a session-level or data structure rule violation. An example of when a reject may be appropriate would be the receipt of a message with invalid basic data (e.g. missing tags) which successfully passes decryption, CheckSum <10> and BodyLength <9> checks. As a rule, messages should be forwarded to the trading application for business level rejections whenever possible.

Request Parameters

Tag Name Required Comments

45

RefSeqNum

Yes

MsgSeqNum of the rejected message

371

RefTagID

No

The tag number of the FIX field being referenced.

372

RefMsgType

No

The MsgType<35> of the FIX message being referenced.

373

SessionRejectReason

No

Code to identity reason for rejection. Values: 查询拒绝原因代码:
0 = Invalid tag number
1 = Required tag missing
2 = Tag not defined for this message type
3 = Undefined tag
4 = Tag specified without a value
5 = Value is incorrect (out of range) for this tag
6 = Incorrect data format for value
7 = Decryption problem
8 = Signature<89> problem
9 = CompID problem
10 = SendingTime<52> accuracy problem
11 = Invalid MsgType<35>
12 = XML validation error
13 = Tag appears more than once
14 = Tag specified out of required order
15 = Repeating group fields out of order
16 = Incorrect NumInGroup count for repeating group
17 = Non "data" value includes field delimiter (SOH character)
99 = Other

58

Text

No

Text reason explaining the reason for rejection

Spot Price API

Price API Receive the latest OKCoin Spot market data
Resource Description
MARKET DATA REQUEST(V) Market Data Request

Description

Market Data Request (V) is used by the trading platform to request market data in the snapshot or the incremental form. OKCoin will generally send this message in three different configurations:
1. Order book requests (market depth) (NoMDEntryTypes<267> = 2, MDEntryType<269> are 0 and 1)
2. Live trades request (order record) (NoMDEntryTypes<267>=1, MDEntryType<269>Yes2)
3. 24h ticker request (NoMDEntryTypes<267> =6, MDEntryType<269>Yes 4,5,7,8,9,B)

Request Example

In order to request a snapshot of both sides of the order book, followed by a stream of incremental order book updates for the BTC/USD pair, OKCoin would send the following message:
8=FIX.4.4|9=144|35=V|34=2|49=234abcxyzc|52=20140411-13:49:41.295|56=EXCHANGE|262=md1397224181279|263=1|264=100|146=1 |55=BTC/USD|267=2|269=0|269=1|10=249| 

Request Parameters

Tag Name Required Comments

146

< NoRelatedSym >

Yes

Repeating group NoRelatedSym, always 1

>=55

Symbol

Yes

Symbol, BTC/USD or LTC/USD

262

MDReqID

Yes

Unique ID assigned to this request.

263

SubscriptionRequestType

Yes

0 = Snapshot
1 = Snapshot + Subscribe
2 Unsubscribe

264

MarketDepth

Yes

Applicable only to order book snapshot requests. Should be ignored otherwise. 0 = Full Book

265

MDUpdateType

No

Subscribe Type
0 = Full Refresh
1 = Incremental Refresh
Comments:
Order book requests (MDUpdateType<265> are 0 or 1)
Live trade request (MDUpdateType<265> is 1)
24h ticker request (MDUpdateType<265> is 0)

267

Yes

Repeating group NoMDEntryTypes. Number of entry types in the request.

=>269

MDEntryType

Yes

OKCoin will assess this tag with one or more of the following values:
0 = Bid (Bid side of the order book)
1 = Offer (Ask side of the order book)
2 = Trade (Live trades)
4 = Opening price<44>;
5 = Closing Price<44>;
7 = Trading Session High Price<44>;
8 = Trading Session Low Price<44>;
9 = Trading Session VWAP Price<44>;
B = Trade Volume

MARKET DATA REQUEST REJECT(Y) Market Data Request Reject

Description

If a Market Data Request (V) message is not accepted, the exchange should respond with a Market Data Request Reject (Y) message.

Request Parameters

Tag Name Required Comments

58

Text

No

Free format text string

262

MDReqID

Yes

ID of the original request

281

MDReqRejReason

Yes

OKCoin will assess this tag with one or more of the following values:
0 = Unknown symbol
1 = Duplicate MDReqID<262>
2 = Insufficient Bandwidth
3 = Insufficient Permission
4 = Unsupported SubscriptionRequestType<263>
5 = Unsupported MarketDepth<264>
6 = Unsupported MDUpdateType<265>
7 = Unsupported AggregatedBook<266>
8 = Unsupported MDEntryType<269>

MARKET DATA SNAPSHOT/FULL REFRESH (W) Market Data Refresh

Description

Market Data Snapshot/Full Refresh (W) is used as the response to a Market Data Request (V) message. It can be used to transmit a 2-sided book of orders, a list of trades or ticker information.

Request Parameters

Tag Name Required Comments

42

OrigTime

Yes

Time of server as of message

55

Symbol

Yes

symbol of currency

262

MDReqID

No

Conditionally required if this message is in response to a Market Data Request .

268

< NoMDEntries >

Yes

Repeating group . Specifies the number of entries in the group.

=>269

MDEntryType

Yes

One or more of the following:
0 = Bid (Bid side of the order book)
1 = Offer (Ask side of the order book)
2 = Trade (Live trades)
4 = Opening Price <44>
5 = Closing Price <44>
7 = Trading Session High Price <44>
8 = Trading Session Low Price <44>
9 = Trading Session VWAP Price <44>
B = Trade Volume

=>270

MDEntryPx

No

Price of an entry. Required for all entry types except B (Trade Volume)

=>271

MDEntrySize

No

Size of an entry.

=>54

Side

No

Side of the trade(1:buy/2:sell)

Spot Trade API

Easily place Spot orders on OKcoin
Resource Description
NEW ORDER SINGLE(D) Place New Order

Description

The NEW ORDER SINGLE(D) is used by the client to submit new orders to the exchange.

Request Parameters

Tag Name Required Comments

1

Account

Yes

1=this.apiKey,this.secretKey

11

ClOrdID

Yes

Unique identifier for the order as assigned by the client.

38

OrderQty

Yes

Order quantity

40

OrdType

Yes

OKCoin supported order type: 1 = market order 2 = limit order

44

Price

Yes

Price OrdType<40> = 2(limit order) specifies single order price. If OrdType<40> = 1 and Side<54> = 1, it means buy certain amount(usd) coins. If OrdType<40> = 1 and Side<54> = 2, it means sell certain amount(usd) coins

54

Side

Yes

Value supported by OKCoin: 1 = Buy 2 = Sell

55

Symbol

Yes

Exchange symbol BTC/USD or LTC/USD

59

TimeInForce

No

60

TransactTime

Yes

Time this order request was initiated by the client.

99

StopPx

No

126

ExpireTime

No

EXECUTION REPORT(8) New Order Request/Reject

Description

Upon receiving a new order, the exchange should respond with the Execution Report (8) message communicating whether the order was accepted or rejected. Due to the way FIX protocol works, many values in this message mirror values from the original order.

Request Parameters

Tag Name Required Comments

6

AvgPx

Yes

Average execution price. Always 0 if ExecType<150> = 0 or 8.

11

ClOrdID

Yes

The exchange should populate this field with the original value assigned by the client in the New Order Single (D) message. Originally not required by FIX but required by OKCoin.

14

CumQty

Yes

Total executed quantity. Always 0 if ExecType<150> = 0 or 8

17

ExecID

Yes

Unique identifier of the execution message as assigned by exchange.

37

OrderID

Yes

Exchange-assigned order reference number.

38

OrderQty

Yes

Order quantity

39

OrdStatus

Yes

0 = New 8 = Rejected

54

Side

Yes

1 = Buy 2 = Sell

55

Symbol

Yes

Exchange symbol BTC/USD or LTC/USD

58

Text

No

Free format text string, usually exceptions

60

TransactTime

Yes

Time the transaction represented by this Execution Report occurred.

103

OrdRejReason

Yes

150

ExecType

No

Describes this report. 0 = New 8 = Rejected

 151

LeavesQty

  No  

Number of orders for further execution. 0 if OrdStatus<39> = 8(Rejected)

ORDER CANCEL REQUEST(F) Cancel Order

Description

ORDER CANCEL REQUEST(F) message requests the cancellation of a particular order. If an order has been partially filled, only the remaining quantity can be cancelled. The request should be accepted only if an order can successfully be cancelled without executing further. 

Request Parameters

Tag Name Required Comments

11

ClOrdID

Yes

Unique identifier of this request

41

OrigClOrdID

Yes

Original client identifier of the order being cancelled

54

Side

Yes

Side of the original order

55

Symbol

Yes

Symbol of the original order. BTC/USD or LTC/USD

60

TransactTime

Yes

Time this request was released by the client.

ORDER CANCEL REJECT(9) Order Cancel Reject

Description

ORDER CANCEL REJECT(9) is issued by the exchange upon receipt of Order Cancel Request (F) message which cannot be honored.

Request Parameters

Tag Name Required Comments

11

ClOrdID

Yes

Identifier of the cancel request

37

OrderID

Yes

Original exchange-assigned identifier of the order that could not be canceled.

39

OrdStatus

Yes

OrdStatus <39> value after this cancel reject is applied.

41

OrigClOrdID

Yes

Original client identifier of the order that could not be canceled.

54

Side

Yes

Side of the original order

58

Text

No

Free format text string, usually exceptions

60

TransactTime

No

Time when the rejection occurred.

434

CxlRejResponseTo

Yes

Identifies the type of request the message is in response to. Valid values: 1 = Order Cancel Request

EXECUTION REPORT(8) Order Cancel Acknowledgement

Description

The following Execution Report (8) is sent by the exchange upon successfully processing a cancel request.

Request Parameters

Tag Name Required Comments

6

AvgPx

Yes

Average execution price until order cancellation.

11

ClOrdID

Yes

Exchange should populate this field with the original value assigned by client in the New Order Single message.

14

CumQty

Yes

Total executed quantity until order cancellation.

17

ExecID

Yes

Unique identifier of the execution message as assigned by exchange

37

OrderID

Yes

Order ID

38

OrderQty

Yes

Quantity of original order

39

OrdStatus

Yes

Current order status 4 = cancelled

54

Side

Yes

1 = Buy 2 = Sell

55

Symbol

Yes

Symbol

58

Text

No

Free format text string

60

TransactTime

No

Time the transaction represented by this Execution Report occurred.

150

ExccType

Yes

Describes this report. 4 = Cancelled

151

LeavesQty

Yes

Amount of orders open for further execution. Should equal 0 in this case.

EXECUTION REPORT(8) Trade Report

Description

Trade reports are sent via the Execution Report (8) message. The trade report provides fill information as orders trade, including: average price of shares traded, total shares traded against the original order quantity, transaction time, trade date etc.

Request Parameters

Tag Name Required Comments

6

AvgPx

Yes

Average execution price

11

ClOrdID

Yes

Exchange should populate this field with the original value assigned by the client in the New Order Single message.

14

CumQty

Yes

Total executed quantity.

17

ExecID

Yes

Unique identifier of execution message as assigned by the exchange.

31

LastPx

Yes

Price of this fill

32

LastQty

Yes

Number of shares bought/sold on this fill.

37

OrderID

Yes

Orde ID

38

OrderQty

Yes

Quantity of original order

39

OrdStatus

Yes

Order status 1 = Partially filled 2 = Fully filled

40

OrdType

Yes

OKCoin supported order type: 1 = market order 2 = limit order

44

Price

Yes

Price OrdType<40> = 2(limit order) specifies single order price. If OrdType<40> = 1 and Side<54> = 1, it means buy certain amount(usd) coins. If OrdType<40> = 1 and Side<54> = 2, it means sell certain amount(usd) coins

54

Side

Yes

1 = Buy 2 = Sell

55

Symbol

Yes

Symbol

58

Text

No

Free format text string

60

TransactTime

No

Time the transaction represented by this Execution Report occurred.

150

ExccType

Yes

Describes this report. F = Trade(partial fill or fill)

151

LeavesQty

Yes

Amount of orders open for further execution.

ORDER MASS STATUS REQUEST(AF) Request Order Status

Description

Order Mass Status Request (AF) message requests the status of currently open orders. The exchange should respond with a series of Execution Report (8) messages detailing orders.

Request Parameters

Tag Name Required Comments

1

Account

No

Account identifier. If omitted, orders for all accounts should be returned. If specified, only orders for the specified account should be returned.

584

MassStatusReqID

Yes

Client-assigned unique ID of this request.(or ORDERID)

585

MassStatusReqType

Yes

Specifies the scope of the mass status request. 1 = status of a specified order(Tag584 is ORDERID) 7 = Status for all orders

EXECUTION REPORT(8) Reporting Order Status

Description

When the client requests the status of currently orders, the exchange should reply with a series of special Execution Reports (8), one for every active order.

Request Parameters

Tag Name Required Comments

1

Account

Yes

Account identifier. Required when the Execution Report (8) is in response to the Order Mass Status Request (AF) message.

6

AvgPx

Yes

Average execution price.

11

ClOrdID

Yes

Exchange should populate this field with the original value assigned by the client in the New Order Single message.

14

CumQty

Yes

Total executed quantity.

17

ExecID

Yes

Unique identifier of execution message as assigned by the exchange.

37

OrderID

Yes

Order ID

38

OrderQty

Yes

Quantity of original order

39

OrdStatus

Yes

Order status A = Pending 1 = Partially filled 2 = Fully filled 4 = Cancelled 6 = cancel request in process

40

OrdType

Yes

Mirrors the value from the original order.

44

Price

No

Required if specified in the original order.

54

Side

Yes

1 = Buy 2 = Sell

55

Symbol

Yes

Symbol

58

Text

No

Free format text string

60

TransactTime

No

Time the transaction represented by this Execution Report occurred.

99

StopPx

No

Required if specified in the original order.

150

ExecType

Yes

Describes this report: A = Pending 1 = Partially filled 2 = Fully filled 4 = Cancelled 6 = cancel request in process

151

LeavesQty

Yes

Amount of orders open for further execution.

911

TotNumReports

Yes

Identifies the total number of execution reports (open orders) that are returned in this batch of reports. Required only in response to Order Mass Status Request (AF).

TRADE CAPTURE REPORT REQUEST(AD) Requesting Trade History

Description

The Trade Capture Report Request (AD) message can be used by the buy-side to request historical trades for an account.

Request Parameters

Tag Name Required Comments

1

Account

No

Account Info. Only the logon account trades data will be returned

55

Symbol

Yes

BTC/usd or LTC/usd

568

TradeRequestID

Yes

Client-assigned unique ID of this request

569

TradeRequestType

Yes

OKCoin will always send:
1 = the most recent 7 days trades data

TRADE CAPTURE REPORT(AE) Trade History Result

Description

Each trade that matches the criteria specified in the original Trade Capture Report Request (AD) message should be sent to the client in a series of Trade Capture Report (AE) messages. OKCoin expects one message per trade.

Request Parameters

Tag Name Required Comments

31

LastPx

Yes

Price associated with this fill.

32

LastQty

Yes

Quantity traded in this fill.

38

OrderQty

Yes

Original ordered quantity associated with this fill.

55

Symbol

Yes

Symbol BTC/USD or LTC/USD(Required by OKCoin not FIX)

60

TransactTime

Yes

Time of transaction

75

TradeDate

Yes

Date of transaction

552

< NoSides >

Yes

Repeating group NoSides. This should always equal 1 because OKCoin expects one trade per message.

==>54

Side

Yes

1 = Buy 2 = Sell

==>37

OrderID

Yes

OKCoin assigned order ID for the order associated with this trade.

==>11

ClOrdID

Yes

Client-assigned order reference for the order associated with this trade.

==>1

Account

Yes

ID of the account associated with the trade.

570

reviouslyReported

Yes

Ignored by OKCoin

571

TradeReportID

Yes

Unique ID of this report

ACCOUNT INFO REQUEST(Z1000) Account Info Request

Description

Account Info Account Info Request (Z1000) is a non-standard FIX message used by OKCoin to request information related to user accounts. Tag 35 = Z1000.

Request Parameters

Tag Name Required Comments

1

Account

No

ID of the account for which information is being requested. If omitted, multiple Account Info Response (Z1001) messages should be sent, one for each existing account.

8000

AccReqID

Yes

Client-assigned unique ID of this request.

ACCOUNT INFO RESPONSE(Z1001) Account Info Response

Description

Account Info Response (Z1001) is a non-standard FIX message used by Zeroblock to process information related to user accounts. Tag 35 = Z1001.

Request Parameters

Tag Name Required Comments

1

Account

Yes

Account 'apiKey'

15

Currency

Yes

Base currency for the account. USD/BTC/LTC

8000

AccReqID

No

Client-assigned ID of the original request. Not required if unsolicited.

8001

Balance

Yes

Account balance in base currency.(available fund, excluding frozen fund)

8101

FreeBtc

No

available Btc

8102

FreeLtc

No

available Ltc

8103

FreeUsd

No

available Usd

8104

FreezedBtc

No

frozen Btc

8105

FreezedLtc

No

frozen Ltc

8106

FreezedUsd

No

frozen Usd

ORDERSINFO AFTER SOMEID REQUEST(Z2000) History Orders

Description

ORDERSINFO AFTER SOMEID REQUEST(Z2000) is a non-standard FIX message to get history order information. Tag 35 = Z2000.

Request Parameters

Tag Name Required Comments

37

OrderID

Yes

Order ID. Return 10 records after this id.

39

OrdStatus

YES

Order status. 0 = Not filled 1 = Fully filled

55

Symbol

YES

Symbol. BTC/USD or LTC/USD

568

TradeRequestID

YES

Client-assigned unique ID of this request.

提示

请先登录

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