Spot api

General API.
Order Count Limits * To keep an orderly market, jex imposes limits on the number of open orders per account. These limits are: * Maximum 200 open orders per contract per account; * Maximum 10 stop profit or stop orders per contract per account; * When placing a new order that causes these caps to be exceeded, it will be rejected with the message “has reach max order number [200|10]”.
Other instructions The number of contract orders sells for API is uniformly negative.
Endpoint security type.
Each endpoint has a security type that determines the how you will interact with it API-keys are passed into the Rest API via the X-JEX-APIKEY header API-keys and secret-keys are case sensitive API-keys can be configured to only access certain types of secure endpoints. For example, one API-key could be used for TRADE only, while another API-key can access everything except for TRADE routes.
SIGNED (TRADE and USER_DATA) Endpoint security.
SIGNED endpoints require an additional parameter, signature , to be sent in the query string or request body . Endpoints use HMAC SHA256 signatures. The HMAC SHA256 signature is a keyed HMAC SHA256 operation. Use your secretKey as the key and totalParams as the value for the HMAC operation. The signature is not case sensitive . totalParams is defined as the query string concatenated with the request body . The parameters of signature must be transmitted in the order of interface documents.
Timing security * A SIGNED endpoint also requires a parameter, timestamp , to be sent which should be the millisecond timestamp of when the request was created and sent. * An additional parameter, recvWindow , may be sent to specify the number of milliseconds after timestamp the request is valid for. If recvWindow is not sent, it defaults to 5000 . * The logic is as follows: javascript if (timestamp Serious trading is about timing. Networks can be unstable and unreliable, which can lead to requests taking varying amounts of time to reach the servers. With recvWindow , you can specify that the request must be processed within a certain number of milliseconds or be rejected by the server.
POST /api/v1/spot/order Examples for POST Here is a step-by-step example of how to send a vaild signed payload from the Linux command line using echo , openssl , and curl .
Example 1: As a query string.
queryString: symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559 HMAC SHA256 signature: curl command:
Example 2: As a request body.
requestBody: symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559 HMAC SHA256 signature: curl command:
Example 3: Mixed query string and request body.
queryString: symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC requestBody: quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559 HMAC SHA256 signature: curl command:
Note that the signature is different in example 3. There is no & between “GTC” and “quantity=1”.
Terminology.
base asset refers to the asset that is the quantity of a symbol. quote asset refers to the asset that is the price of a symbol.
ENUM definitions.
Symbol status (status):
PRE_TRADING TRADING POST_TRADING END_OF_DAY HALT AUCTION_MATCH BREAK.
Symbol type:
spot and option Order status (status):
NEW PARTIALLY_FILLED FILLED CANCELED PENDING_CANCEL (currently unused)) FAIL CANCLEFILLED REJECTED (currently unused) EXPIRED (currently unused)
contract status (status):
ENTRUSTED ENTRUSTING FAIL PARTFILLED FILLED CANCEL.
Order types (orderTypes, type):
LIMIT MARKET STOPLIMIT STOPMARKET PROFITLIMIT PROFITMARKET.
Order side (side):
Time in force:
GTC – Good Till Cancel IOC – Immediate or Cancel FOK – Fill or Kill.
Kline/Candlestick chart intervals:
m -> minutes; h -> hours; d -> days; w -> weeks; M -> months.
Rate limiters (rateLimitType)
Rate limit intervals (interval)
Endpoints for futures account.
General endpoints.
Test connectivity PING.
Weight: 1.
Parameters: NONE.
Check server time.
Get the current server time.
Weight: 1.
Parameters: NONE.
Exchange information.
Get the current trading rules and symbol information.
Weight: 1.
Parameters: NONE.
Depth information for spot.
Weight:1.
Parameters:
Name Type Mandatory Description symbol STRING YES limit INT NO Default 60; Max 60. Available:[5, 10, 20, 50, 60]
Recent trades for spot.
Get recent trades.
Weight: 1.
Parameters:
Name Type Mandatory Description symbol STRING YES limit INT NO Default 60; max 60.
Old trade lookup (MARKET_DATA)
Weight: 5.
Parameters:
Name Type Mandatory Description symbol STRING YES limit INT NO Default 200; max 500. fromId LONG NO TradeId to fetch from. Default gets most recent trades.
Kline/Candlestick data.
Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.
Weight: 1.
Parameters:
If startTime and endTime are not sent, the most recent klines are returned.
Current average price.
Weight: 1 Parameters:
Name Type Mandatory Description symbol STRING YES.
24hr ticker price change statistics.
24 hour rolling window price change statistics. Careful when accessing this with no symbol.
Weight: 1 for a single symbol; 40 when the symbol parameter is omitted.
Parameters:
Name Type Mandatory Description symbol STRING NO.
Price ticker for spot.
Back to newest price.
Weight: 1 for a single symbol; 2 when the symbol parameter is omitted.
Parameters:
Symbol order book ticker for spot.
Best price/qty on the order book for a symbol or symbols.
Weight: 1 for a single symbol; 2 when the symbol parameter is omitted.
Parameters:
Account endpoints.
Place order in coins transaction(TRADE)
POST /api/v1/spot/order (HMAC SHA256)
Weight: 1.
Parameters:
Name Type Mandatory Description symbol STRING YES side ENUM YES type ENUM YES LIMIT quantity DECIMAL YES price DECIMAL YES newOrderRespType ENUM NO Specify response type ACK , RESULT ; Default is ACK . recvWindow LONG NO timestamp LONG YES.
Two choices for newOrderRespType.
Response ACK: Returning speed is fast, trading information not included, less information.
Response RESULT: Returning speed is slow, returning some information on taking order transaction.
Test placing order API of coins transaction(TRADE)
POST /api/v1/spot/order/test (HMAC SHA256)
Used for test placing order request, won’t be submitted to matchmaking trading engine.
Weight: 1.
Parameters:
Reference POST /api/v1/spot/order.
Check orders of coins transaction(USER_DATA)
GET /api/v1/spot/order (HMAC SHA256)
Check order status.
Weight: 1.
Parameters:
Name Type Mandatory Description symbol STRING YES orderId LONG YES recvWindow LONG NO timestamp LONG YES.
Cancel order for coins transaction(TRADE)
DELETE /api/v1/spot/order (HMAC SHA256)
Weight: 1.
Parameters:
Name Type Mandatory Description symbol STRING YES orderId LONG YES recvWindow LONG NO timestamp LONG YES.
Check entry orders of coins transaction of this account(USER_DATA)
GET /api/v1/spot/openOrders (HMAC SHA256)
Weight: 5.
Parameters:
Name Type Mandatory Description symbol STRING YES orderId LONG NO Only orders after this orderID will be returned. Only partial recent orders will be returned startTime LONG NO endTime LONG NO limit INT NO Default 500; max 500. recvWindow LONG NO timestamp LONG YES.
Account information(USER_DATA)
GET /api/v1/account (HMAC SHA256)
Weight: 1.
Parameters:
Name Type Mandatory Description recvWindow LONG NO timestamp LONG YES.
Historical coins entry order of the account (USER_DATA)
GET /api/v1/spot/historyOrders (HMAC SHA256)
Obtain trading history of specified trading pair.
Weight: 5.
Parameters:
Name Type Mandatory Description symbol STRING YES orderId LONG NO Only orders after this orderID will be returned. Only partial recent orders will be returned startTime LONG NO endTime LONG NO limit INT NO Default 500; max 500. recvWindow LONG NO timestamp LONG YES.
User data.
User’s assets (USER_DATA)
Weight: 1.
Parameters:
Name Type Mandatory Description recvWindow LONG NO timestamp LONG YES.
Depositing address of the user(USER_DATA)
Weight: 1.
Parameters:
Name Type Mandatory Description asset STRING YES recvWindow LONG NO timestamp LONG YES.
Historical depositing records of the user (USER_DATA)
Weight: 5.
Parameters:
Name Type Mandatory Description asset STRING NO status int NO 0:pending,1:success startTime LONG NO endTime LONG NO recvWindow LONG NO timestamp LONG YES.
Service fee of the trading (USER_DATA)
Weight: 1.
Parameters:
Name Type Mandatory Description symbol STRING NO recvWindow LONG NO timestamp LONG YES.
Historical withdrawal records of the user(USER_DATA)
Weight: 5.
Parameters:
Name Type Mandatory Description asset STRING NO status INT NO 0:Email Sent,1:Cancelled 2:Awaiting Approval 3:Rejected 4:Processing 5:Failure 6Completed startTime LONG NO endTime LONG NO recvWindow LONG NO timestamp LONG YES.
User Data Streams.
The base API endpoint is: https://www.jex.com A User Data Stream listenKey is valid for 60 minutes after creation. Doing a PUT on a listenKey will extend its validity for 60 minutes. Doing a DELETE on a listenKey will close the stream. The base websocket endpoint is: wss://ws.jex.com User Data Streams are accessed at /ws/ A single connection to stream.jex.com is only valid for 24 hours; expect to be disconnected at the 24 hour mark.
User data stream payloads are not guaranteed to be in order during heavy periods; make sure to order your updates using E.
Specifics on how user data streams work.
For detailed subscription method, please refer to another websocket document.
Start user data stream (USER_STREAM)
Start a new user data stream. The stream will close after 60 minutes unless a keepalive is sent.
Weight: 1.
Parameters: NONE.
Keepalive (USER_STREAM)
Keepalive a user data stream to prevent a time out. User data streams will close after 60 minutes. It’s recommended to send a ping about every 30 minutes.
Weight: 1.
Parameters:
Name Type Mandatory Description listenKey STRING YES.
Close user data stream (USER_STREAM)
Weight: 1.
Parameters:
Name Type Mandatory Description listenKey STRING YES.
Account updates.
Event type of account updates is fixed to accountSpotInfo AND accountOptionInfo AND accountContractInfo They respectively refers to the asset related event of spot, options and futures. When there is a change of asset, relevant event will be pushed.
Update of orders.
Account state is updated with the outboundAccountInfo event.
event type is execSpotReport AND execOptionReport AND execContractReport They respectively refers to the asset related event of spot、options、futures Event type.
Possible executive type of contract(X field)
Possible executive type of spot and options (X field):
Possible executive type of contract(X field):
ENTRUSTED ENTRUSTING FAIL PARTFILLED FILLED CANCEL.
if refused(R field)
insufficient Available too many pending requests position is being liquidated position is being closed closing empty position closing order is enough contract is disabled reach liquidation price reach risk limit.
Contract positions.
Where there is a change in contract position event type is contractPositions.
Web Socket Streams.
General WSS information.
The base endpoint is: wss://ws.jex.com Streams can be accessed either in a single raw stream or in a combined stream Raw streams are accessed at /ws/ Combined streams are accessed at /stream?streams=// Combined stream events are wrapped as follows: “,”data”:> All symbols for streams are lowercase A single connection to stream.jex.com is only valid for 24 hours; expect to be disconnected at the 24 hour mark The websocket server will send a ping frame every 3 minutes. If the websocket server does not receive a pong frame back from the connection within a 10 minute period, the connection will be disconnected. Unsolicited pong frames are allowed. WSS contract order sells are uniformly negative It is recommended to use the combined streams method for connection. Each combined stream can subscribe to a maximum of 10 streams.
Stream Detailed Stream information.
Websocket Trade Streams.
Every 100 ms push, every single transaction in the last second is defined as a transaction between only one order taker and one bill holder.
Stream Name: @
tradeType.
Support 3 types as below: spotTrade optionTrade contractTrade.
Websocket Kline/Candlestick Streams.
The Kline/Candlestick Stream push updates to the current klines/candlestick every second.
Booking Kline requires interval parameter, shortest one is minute line, longest one is week line. Support intervals as below:
Stream Name: @_.
klineType.
-Support types – spotKline – optionKline – contractKline.
Individual Symbol Mini Ticker Stream.
24hr rolling window mini-ticker statistics for a single symbol pushed every second.
Stream Name: @
miniTickerType.
Support types: spotMiniTicker optionMiniTicker contractMiniTicker.
All Market Mini Tickers Stream.
24hr rolling window mini-ticker statistics for all symbols that changed in an array pushed every second.
StreamName: [email protected]
miniTickerType.
Support types: spotMiniTicker optionMiniTicker contractMiniTicker.
Individual Symbol Ticker Streams.
24hr rollwing window ticker statistics for a single symbol pushed every second.
Stream Name: @
All Market Tickers Stream.
24hr rolling window ticker statistics for all symbols that changed in an array pushed every second.
StreamName: [email protected]
Payload:
tickerType spotTicker optionTicker contractTicker.
Partial Book Depth Streams.
Top bids and asks, pushed every second. Valid are 5, 10, or 20.
Stream Name: @
depthType spotDepth optionDepth contractDepth 5 10 20.
Diff. Depth Stream.
Order book price and quantity depth updates used to locally manage an order book pushed every second.
Stream Name: @
depthType Support types spotDepth optionDepth contractDepth spotDepthUpdate optionDepthUpdate contractDepthUpdate.
Error Codes.
JEX Rest接口(包括wapi)返回的错误包含两部分,错误码与错误信息. 错误码是大类,一个错误码可能对应多个不同的错误信息。 以下是一个完整错误码实例 javascript.

Related Posts

Leave a Reply

Your email address will not be published.