com.binance.connector.client.impl.websocketapi.WebSocketApiAccount Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of binance-connector-java Show documentation
Show all versions of binance-connector-java Show documentation
lightweight connector to API
package com.binance.connector.client.impl.websocketapi;
import org.json.JSONObject;
import com.binance.connector.client.utils.JSONParser;
import com.binance.connector.client.utils.ParameterChecker;
import com.binance.connector.client.utils.websocketapi.WebSocketApiRequestHandler;
/**
* Account Requests
* All requests under the
* Account requests
* section of the WebSocket API documentation will be implemented in this class.
*
* Response will be returned as callback.
*/
public class WebSocketApiAccount implements WebSocketApiModule {
private WebSocketApiRequestHandler handler;
public WebSocketApiAccount(WebSocketApiRequestHandler handler) {
this.handler = handler;
}
/**
* Query account information.
*
* @param parameters JSONObject composed by key-value pairs:
*
* recvWindow -- optional/int -- The value cannot be greater than 60000
* requestId -- optional/String or int
*
* @see
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api#account-information-user_data
*/
public void accountStatus(JSONObject parameters) {
this.handler.signedRequest("account.status", parameters);
}
/**
* Query your current order rate limit.
*
* @param parameters JSONObject composed by key-value pairs:
*
* recvWindow -- optional/int -- The value cannot be greater than 60000
* requestId -- optional/String or int
*
* @see
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api#account-order-rate-limits-user_data
*/
public void accountRateLimitsOrders(JSONObject parameters) {
this.handler.signedRequest("account.rateLimits.orders", parameters);
}
/**
* Query information about all your orders – active, canceled, filled – filtered by time range.
*
* If startTime and/or endTime are specified, orderId is ignored.
*
* @param symbol String
* @param parameters JSONObject composed by key-value pairs:
*
* orderId -- optional/int -- Order ID to begin at
* startTime -- optional/int -- Timestamp in ms
* endTime -- optional/int -- Timestamp in ms
* limit -- optional/int -- Default 500; max 1000.
* recvWindow -- optional/int -- The value cannot be greater than 60000
* requestId -- optional/String or int
*
* @see
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api#account-order-history-user_data
*/
public void accountAllOrders(String symbol, JSONObject parameters) {
ParameterChecker.checkParameterType(symbol, String.class, "symbol");
parameters = JSONParser.addKeyValue(parameters, "symbol", symbol);
this.handler.signedRequest("allOrders", parameters);
}
/**
* Query information about all your OCOs, filtered by time range.
*
* If startTime and/or endTime are specified, fromId is ignored.
*
* @param parameters JSONObject composed by key-value pairs:
*
* fromId -- optional/int -- Order list ID to begin at
* startTime -- optional/int -- Timestamp in ms
* endTime -- optional/int -- Timestamp in ms
* limit -- optional/int -- Default 500; max 1000.
* recvWindow -- optional/int -- The value cannot be greater than 60000
* requestId -- optional/String or int
*
* @see
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api
*/
public void accountAllOcoOrders(JSONObject parameters) {
this.handler.signedRequest("allOrderLists", parameters);
}
/**
* Query information about all your trades, filtered by time range.
*
* @param symbol String
* @param parameters JSONObject composed by key-value pairs:
*
* orderId -- optional/int -- Order list ID to begin at
* startTime -- optional/int -- Timestamp in ms
* endTime -- optional/int -- Timestamp in ms
* fromId -- optional/int -- Trade ID to begin at
* limit -- optional/int -- Default 500; max 1000.
* recvWindow -- optional/int -- The value cannot be greater than 60000
* requestId -- optional/String or int
*
* @see
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api#account-trade-history-user_data
*/
public void accountTradeHistory(String symbol, JSONObject parameters) {
ParameterChecker.checkParameterType(symbol, String.class, "symbol");
parameters = JSONParser.addKeyValue(parameters, "symbol", symbol);
this.handler.signedRequest("myTrades", parameters);
}
/**
* Displays the list of orders that were expired because of STP trigger.
*
* @param symbol String
* @param parameters JSONObject composed by key-value pairs:
*
* preventedMatchId -- optional/long
* orderId -- optional/long
* fromPreventedMatchId -- optional/long
* limit -- optional/int -- Default 500; max 1000.
* recvWindow -- optional/int -- The value cannot be greater than 60000
* requestId -- optional/String or int
*
* @see
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api#account-prevented-matches-user_data
*/
public void accountPreventedMatches(String symbol, JSONObject parameters) {
ParameterChecker.checkParameterType(symbol, String.class, "symbol");
ParameterChecker.checkOneOfParametersRequired(parameters, "preventedMatchId", "orderId");
ParameterChecker.checkOnlyOneOfParameters(parameters, "preventedMatchId", "orderId");
parameters = JSONParser.addKeyValue(parameters, "symbol", symbol);
this.handler.signedRequest("myPreventedMatches", parameters);
}
/**
* Retrieves allocations resulting from SOR order placement.
*
* @param symbol String
* @param parameters JSONObject composed by key-value pairs:
*
* startTime -- optional/long -- Timestamp in ms
* endTime -- optional/long -- Timestamp in ms
* fromAllocationId -- optional/int
* limit -- optional/int -- Default 500; max 1000.
* orderId -- optional/long
* recvWindow -- optional/int -- The value cannot be greater than 60000
* requestId -- optional/String or int
*
* @see
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api#account-allocations-user_data
*/
public void accountAllocations(String symbol, JSONObject parameters) {
ParameterChecker.checkParameterType(symbol, String.class, "symbol");
parameters = JSONParser.addKeyValue(parameters, "symbol", symbol);
this.handler.signedRequest("myAllocations", parameters);
}
/**
* Get current account commission rates.
*
* @param symbol String
* @param parameters JSONObject composed by key-value pairs:
*
* requestId -- optional/String or int
*
* @see
* https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api#account-commission-rates-user_data
*/
public void accountCommissionRates(String symbol, JSONObject parameters) {
ParameterChecker.checkParameterType(symbol, String.class, "symbol");
parameters = JSONParser.addKeyValue(parameters, "symbol", symbol);
this.handler.signedRequest("account.commission", parameters);
}
}