All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.binance.connector.client.impl.spot.SpotAlgo Maven / Gradle / Ivy

There is a newer version: 3.2.0
Show newest version
package com.binance.connector.client.impl.spot;

import java.util.Map;

import com.binance.connector.client.enums.HttpMethod;
import com.binance.connector.client.utils.ParameterChecker;
import com.binance.connector.client.utils.ProxyAuth;
import com.binance.connector.client.utils.RequestHandler;
import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator;
import com.binance.connector.client.utils.signaturegenerator.SignatureGenerator;

/**
 * 

Spot Algo Endpoints

* All endpoints under the * Spot Algo Endpoints * section of the API documentation will be implemented in this class. *
* Response will be returned in String format. */ public class SpotAlgo { private final String baseUrl; private final RequestHandler requestHandler; private final boolean showLimitUsage; public SpotAlgo(String baseUrl, String apiKey, String secretKey, boolean showLimitUsage, ProxyAuth proxy) { this.baseUrl = baseUrl; this.requestHandler = new RequestHandler(apiKey, new HmacSignatureGenerator(secretKey), proxy); this.showLimitUsage = showLimitUsage; } public SpotAlgo(String baseUrl, String apiKey, SignatureGenerator signatureGenerator, boolean showLimitUsage, ProxyAuth proxy) { this.baseUrl = baseUrl; this.requestHandler = new RequestHandler(apiKey, signatureGenerator, proxy); this.showLimitUsage = showLimitUsage; } private final String TWAP_ORDER = "/sapi/v1/algo/spot/newOrderTwap"; /** * Place a new spot TWAP order with Algo service. * *

* POST /sapi/v1/algo/spot/newOrderTwap *
* @param * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* symbol -- mandatory/string -- Trading symbol, e.g. BNBUSDT
* side -- mandatory/enum
* quantity -- mandatory/decimal -- Quantity of base asset; The notional (quantity * last price(base asset)) must be more than the equivalent of 1,000 USDT and less than the equivalent of 100,000 USDT.
* duration -- mandatory/long -- Duration for TWAP orders in seconds. [300, 86400]
* clientAlgoId -- optional/string -- A unique id among Algo orders (length should be 32 characters), If it is not sent, we will give default value.
* limitPrice -- optional/decimal -- Limit price of the order; If it is not sent, will place order by market price by default.
* stpMode -- optional/enum -- The allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER, EXPIRE_MAKER, EXPIRE_BOTH, NONE * recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#time-weighted-average-price-twap-new-order-trade-2 */ public String twapOrder(Map parameters) { ParameterChecker.checkParameter(parameters, "symbol", String.class); ParameterChecker.checkParameter(parameters, "side", String.class); ParameterChecker.checkRequiredParameter(parameters, "quantity"); ParameterChecker.checkParameter(parameters, "duration", Long.class); return requestHandler.sendSignedRequest(baseUrl, TWAP_ORDER, parameters, HttpMethod.POST, showLimitUsage); } private final String CANCEL_ORDER = "/sapi/v1/algo/spot/order"; /** * Cancel an open TWAP order * *

* DELETE /sapi/v1/algo/spot/order *
* @param * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* algoId -- mandatory/long
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#cancel-algo-order-trade-2 */ public String cancelOrder(Map parameters) { ParameterChecker.checkParameter(parameters, "algoId", Long.class); return requestHandler.sendPublicRequest(baseUrl, CANCEL_ORDER, parameters, HttpMethod.DELETE, showLimitUsage); } private final String OPEN_ORDERS = "/sapi/v1/algo/spot/openOrders"; /** * Get all open SPOT TWAP orders * *

* GET /sapi/v1/algo/spot/openOrders *
* @param * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#query-current-algo-open-orders-user_data-2 */ public String getOpenOrders(Map parameters) { return requestHandler.sendPublicRequest(baseUrl, OPEN_ORDERS, parameters, HttpMethod.GET, showLimitUsage); } private final String HISTORICAL_ORDERS = "/sapi/v1/algo/spot/historicalOrders"; /** * Get all historical SPOT TWAP orders * *

* GET /sapi/v1/algo/spot/historicalOrders *
* @param * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* symbol -- optional/string -- Trading symbol, e.g. BNBUSDT
* side -- optional/enum
* startTime -- optional/long -- UTC timestamp in ms
* endTime -- optional/long -- UTC timestamp in ms
* page -- optional/int -- Default 1
* pageSize -- optional/int -- MIN 1, MAX 100; Default 100
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#query-historical-algo-orders-user_data-2 */ public String getHistoricalOrders(Map parameters) { return requestHandler.sendPublicRequest(baseUrl, HISTORICAL_ORDERS, parameters, HttpMethod.GET, showLimitUsage); } private final String SUB_ORDERS = "/sapi/v1/algo/spot/subOrders"; /** * Get respective sub orders for a specified algoId * *

* GET /sapi/v1/algo/spot/subOrders *
* @param * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* algoId -- mandatory/long
* page -- optional/int -- Default 1
* pageSize -- optional/int -- MIN 1, MAX 100; Default 100
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#query-sub-orders-user_data-2 */ public String getSubOrders(Map parameters) { ParameterChecker.checkParameter(parameters, "algoId", Long.class); return requestHandler.sendPublicRequest(baseUrl, SUB_ORDERS, parameters, HttpMethod.GET, showLimitUsage); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy