Engine Response API

注意: 所有响应 RC 类型为 Number

The WebSocket API in this trading engine will replace the original sisyphus project.

Table of Contents

Public Api

0. Heartbeat

{"MsgType":"Heartbeat"} 5 seconds interval to keep WebSocket session alive.

1. Get active contracts

GetActiveContractsResponse

FieldValue/Explanation
MsgTypeGetActiveContractsResponse
CRIDan unique ID from client to identify requests and responses
RC0 means success, non-zero indicates failure
Reasonresult information
Contractsobject contains information of currently trading symbols, see Appendix 2.2

2. Quote

QuoteResponse

FieldValue/Explanation
MsgTypeQuoteResponse
CRIDan unique ID from client to identify requests and responses
RC0 means success, non-zero indicates failure
Reasonresult information
Tickermarket OHCL ticker data object, see Appendix 2.2
OrderBookorderbook object for current order book, see Appendix 2.3
PremiumAdjustmentobject holding information about price PremiumAdjustment, see Appendix 2.5

3. Login: AccountInfo, ExecReport

LoginResponse

FieldValue/Explanation
MsgTypeLoginResponse
CRIDan unique ID from client to identify requests and responses
RC0 means success, non-zero indicates failure
Reasonresult information
Accountaccount ID

AccountInfo

FieldValue/Explanation
MsgTypeAccountInfo
Accountaccount ID
RPRiskProfile
GGroup
BLBalanceList, see Appendix 2.6
CDLContractDetailList, see Appendix 2.7

ExecReport

FieldValue/Explanation
MsgTypeExecReport
Accountaccount ID
Timestamp
CRIDClientRequestID
OIDOrderID
Symbol
Side
OrderType
LastQty
CumQtyQuantity that has been already executed
LeaveQtyQuantity that pending to be executed
Price
StopPrice
Status
Text
TimeInForce
ExprDateexpiration date if TimeInForce is 'good till date'
ExprTimeexpiration time if TimeInForce is 'good till date'
SettlementQtyQuantity has been executed at current execution
AveragePrice
ExecutionDetailssee Appendix 2.8
CreatedCreated timestamp
FeeExchange
FeeExchangeOvernight
TradeFeeLogssee Appendix 2.9
IsLiquidation
IsEarlyProfit
IsDelivery

4. Logout

LogoutResponse

FieldValue/Explanation
MsgTypeLoginResponse
CRIDan unique ID from client to identify requests and responses
RC0 means success, non-zero indicates failure
Reasonresult information
Accountaccount ID

5. Place order

PlaceOrderResponse

FieldValue/Explanation
MsgTypePlaceOrderResponse
CRIDan unique ID from client to identify requests and responses
RC0 means success, non-zero indicates failure
Reasonresult information
OIDorder ID
Texttext to explain OrdRejReason
OrdRejReasonorder reject reason

6. Cancel all orders

CancelAllOrdersResponse

FieldValue/Explanation
MsgTypeCancelAllOrdersResponse
CRIDan unique ID from client to identify requests and responses
RC0 means success, non-zero indicates failure
Reasonresult information
CancelledOrdersIdlist of cancelled order IDs

7. Cancel order

CancelOrderResponse

FieldValue/Explanation
MsgTypeCancelOrderResponse
CRIDan unique ID from client to identify requests and responses
RC0 means success, non-zero indicates failure
Reasonresult information
OIDorder Id
OrdStatusorder status
CxlRejReasoncancel reject reason

8. Cancel replace order

CancelReplaceOrderResponse

FieldValue/Explanation
MsgTypeCancelReplaceOrderResponse
CRIDan unique ID from client to identify requests and responses
RC0 means success, non-zero indicates failure
Reasonresult information
OIDprevious order Id
OrdStatusorder status
CxlRejReasoncancel reject reason

8. Get account info

GetAccountInfoResponse

FieldValue/Explanation
MsgTypeCancelReplaceOrderResponse
CRIDan unique ID from client to identify requests and responses
RC0 means success, non-zero indicates failure
Reasonresult information
AccountInfoobject contains account information

9. Get orders

GetOrdersResponse

FieldValue/Explanation
MsgTypeRetrieveOrderResponse
CRIDan unique ID from client to identify requests and responses
RC0 means success, non-zero indicates failure
Reasonresult information
Reportsinformation object related to the order that you specified in request
OrdRejReasonorder reject reason

10. Get trades

GetTradesResponse

FieldValue/Explanation
MsgTypeGetTradesResponse
CRIDan unique ID from client to identify requests and responses
RC0 means success, non-zero indicates failure
Reasonresult information
Tradesobject for records of trades

Appendix 0: Result Codes

0.1 Exchange-Engine Result Codes

注意: 所有响应 RC 类型为 Number

ConstantValueDescription
RC_DATA_EMPTY-1data is empty
RC_OPR_SUCCESSED0successful operation
RC_OPR_FAILED1operate failed
RC_USER_AUTHEN_FAILED2user authen failed
RC_USER_ALREADY_EXIST3user is already exist
RC_CONNECTION_SECURITY_FAILED4connection security is failed
RC_INVALID_WITHDARWAL_EFF_MARGIN11invalid withdarwal exceed eff margin
RC_TRANSACTION_ID_IS_NOT_UNIQUE12transaction id is not unique
RC_SYSTEM_FAILED99an exception of system
RC_UNKNOWN_SYMBOL2001unknown symbol
RC_EXCHANGE_CLOSED2002Market is closed
RC_ORDER_EXCEEDS_LIMIT2003order exceeds limit
RC_UNKNOWN_ORDER2005unknown order
RC_DUPLICATE_ORDER2006duplicate order
RC_INVALID_INVESTOR_ID2010invalid investor
RC_INCORRECT_QUANTITY2013incorrect quantity
RC_UNKNOWN_ACCOUNT2015unknown account
RC_PRICE_EXCEED_CURRENT_PRICE_BAND2016price excceeds current price band
RC_OTHER2099other status
RC_ORDER_CANCEL_EXECUTE_SELF_ORDER2100order is cancelled, because it will execute self order
RC_CLORDID_CANNOT_EMPTY2101order id can't be empty
RC_INCORRECT_ORDER_SIDE2102order side is incorrect
RC_INCORRECT_ORDER_TYPE2103order type is incorrect
RC_INCORRECT_POSITION_EFFECT2104position effect is incorrect
RC_INCORRECT_PRICE2105price is incorrect
RC_INCORRECT_SECURITY_TYPE2106security type is incorrect
RC_INCORRECT_PRICE_DIGITS2107price digits is incorrect
RC_ACCOUNT_IS_LIQUIDATING2108account is liquidating
RC_POSITION_EXCEEDS_LIMIT2109position exceeds limit
RC_MARGIN_INSUFFICIENT2110margin is insufficient
RC_CLORDID_DUPLICATED_WITH_TODAY2111orderID is duplicated With in today
RC_ORDER_COUNT_ISZERO2112order count is zero
RC_INCORRECT_TIME_INFORCE2113time in force is incorrect
RC_BEGIN_CANNOT_GREATER_THAN_END2114begin can not be greater than the end
RC_INCORRECT_OLDQUANTITY2115old quanity is incorrect
RC_TOO_LATE_TO_CANCEL3000too late to cancel
RC_ORDER_ALREADY_PENDING_STATUS3001order already in pending status
RC_ORDER_DOES_NOT_BELONG_TO_USER3100order does not belong to user
RC_FAILTO_CANCEL_ORDER_MANAGER3101fail to cancel in order manager
RC_MARKET_ORDER_CANNOT_CANCELLED3102market order can't be cancelled
RC_MARKET_ORDER_CANNOT_REPLACED3103market order can't be replaced
RC_LINKED_ORDER_ISNOT_SUPPORTED3104linked order is not supported
RC_INVALID_ACCOUNT3410invalid account
RC_INVALID_TYPE3411invalid type
RC_INVALID_FORK3412invalid fork
RC_INVALID_AMOUNT3413invalid amount
RC_NOT_ENOUGH_FUNDS3414not enough funds
RC_TOO_MANY_ACTIVE_QUOTES4001too many active quotes
RC_ACTIVE_QUOTE_STANDS4002active quote stands
RC_NO_ACTIVE_QUOTE4003no actvie quote

Appendix 1: Types

1.1 OrdStatus

ValueCodeSource
New'0'FIX
PartiallyFilled'1'FIX
Filled'2'FIX
DoneForDay'3'FIX
Canceled'4'FIX
PendingCancel'6'FIX
Stopped'7'FIX
Rejected'8'FIX
Suspended'9'FIX
PendingNew'A'FIX
Calculated'B'FIX
Expired'C'FIX
AcceptedForBidding'D'FIX
PendingReplace'E'FIX
DoneForOvernight'F'
CancelledBySystem'G'
DoneBySystem'S'

1.2 OrdRejReason

ValueCodeSource
UnknownSymbol1FIX
ExchangeClosed2FIX
OrderExcceedsLimit3FIX
UnknownOrder5FIX
InvalidInvestorID10FIX
IncorrectQuantity13FIX
UnknownAccount15FIX
Other99FIX
PriceExcceedsCurrentPriceBand16
OrderCancelledBecauseItWillExecuteSelfOrder100
ClOrdIDCannotBeEmpty101
IncorrectOrderSide102
IncorrectOrderType103
IncorrectPositionEffect104
IncorrectPrice105
IncorrectSecurityType106
IncorrectPriceDigits107
AccountIsLiquidating108
PositionExcceedsLimit109
MarginInsufficient110
ClOrdIDIsDuplicatedWithInToday111
EMPTY-1
NOT_REJECT0

1.3 CxlRejReason

ValueCodeSource
TooLateToCancel0FIX
UnknownOrder1FIX
OrderAlreadyInPendingStatus3FIX
DuplicateOrder6FIX
Other99FIX
PriceExceedsCurrentPriceBand8
OrderDoesNotBelongToUser100
FailToCancelInOrderManager101
MarketOrderCannotBeCancelled102
IncorrectOrderType103
IncorrectQuantity104
IncorrectPrice105
MarginInsufficient110
LinkedOrderIsNotSupported111
IncorrectOldQuantity120
Empty-1

1.4 Order Side

ValueCode
BUY'1'
SELL'2'

1.5 Order Type

ValueCode
MARKET'1'
LIMIT'2'
STOP'3'

Appendix 2: Components

2.1 ActiveContract

FieldValue/Explanation
Symbolcontract symbol, e.g. BTCUSD
Indexindex symbol, eg. BPIUSD, BPI = Bitcoin Price Index
Quantitythe minimum quantity, eg. 0.0001
Pricethe minimum price, eg. 0.01

2.2 Ticker

FieldValue/Explanation
Symbol
BidPrice
AskPrice
Open
High
Low
Last
LastQuantity
PrevClsprevious close price
Volume
Volume24H
Timestamp
ExecutionLimitDown
ExecutionLimitUp

2.3 OrderBook

FieldValue/Explanation
Timestamp
Symbol
Version
Type
Listsee Appendix 2.4

2.4 OrderBook Entry

FieldValue/Explanation
Side
Size
Price

2.5 PremiumAdjustment

FieldValue/Explanation
PBMPriceBandMidpoint
APPAveragePricePremium
LCCRLongCarryingChargeRete
SCCRShortCarryingChargeRate
CCFCarryingChargeFrequency
ELCCRExpectedLongCarryingChargeRate
ESCCRExpectedShortCarryingChargeRate
ECCFExpectedCarryingChargeFrequency

2.6 AccountBalance

FieldValue/Explanation
CRCurrency
SODTransferTotal
CCash

2.7 ContractDetail

FieldValue/Explanation
SSymbol
TSSTotalSellSize
TBSTotalBuySize
OSOpenSize
APAveragePrice
PProfit
MVMarketValue
IMFInitialMarginFactor
LPLiquidationPrice
BIMRBaseInitialMarginRequired
QIMRQuoteInitialMarginRequired

2.8 ExecutionDetail

FieldValue/Explanation
Index
Timestamp
Price
TotalQuantity
OpenedQuantity
ClosedQuantity

2.9 ExecTradeFeeLog

FieldValue/Explanation
AAccount
CCreated timestamp
FTPFeeType
FSTFeeSubType
QQuantity
FTFeeTotal