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

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

package com.binance.connector.client.impl.spot;

import com.binance.connector.client.enums.HttpMethod;
import com.binance.connector.client.utils.HmacSignatureGenerator;
import com.binance.connector.client.utils.ParameterChecker;
import com.binance.connector.client.utils.RequestHandler;
import com.binance.connector.client.utils.SignatureGenerator;
import java.util.LinkedHashMap;

/**
 * 

Futures Endpoints

* All endpoints under the * Futures Endpoint * section of the API documentation will be implemented in this class. *
* Response will be returned in String format. */ public class Futures { private final String baseUrl; private final RequestHandler requestHandler; private final boolean showLimitUsage; public Futures(String baseUrl, String apiKey, String secretKey, boolean showLimitUsage) { this.baseUrl = baseUrl; this.requestHandler = new RequestHandler(apiKey, new HmacSignatureGenerator(secretKey)); this.showLimitUsage = showLimitUsage; } public Futures(String baseUrl, String apiKey, SignatureGenerator signatureGenerator, boolean showLimitUsage) { this.baseUrl = baseUrl; this.requestHandler = new RequestHandler(apiKey, signatureGenerator); this.showLimitUsage = showLimitUsage; } private final String FUTURES_TRANSFER = "/sapi/v1/futures/transfer"; /** * Execute transfer between spot account and futures account. *

* POST /sapi/v1/futures/transfer *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* asset -- mandatory/string -- The asset being transferred, e.g. USDT
* amount -- mandatory/decimal -- The amount to be transferred
* type -- mandatory/int -- 1: transfer from spot account to USDT-M futures account. * 2: transfer from USDT-M futures account to spot account. * 3: transfer from spot account to COIN-M futures account. * 4: transfer from COIN-M futures account to spot account.
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#new-future-account-transfer-user_data */ public String futuresTransfer(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "asset", String.class); ParameterChecker.checkRequiredParameter(parameters, "amount"); ParameterChecker.checkParameter(parameters, "type", Integer.class); return requestHandler.sendSignedRequest(baseUrl, FUTURES_TRANSFER, parameters, HttpMethod.POST, showLimitUsage); } /** * GET /sapi/v1/futures/transfer *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* asset -- mandatory/string -- The asset being transferred, e.g. USDT
* startTime -- mandatory/long
* endTime -- optional/long
* current -- optional/long -- Currently querying page. Start from 1. Default:1
* size -- optional/long -- Default:10 Max:100
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#get-future-account-transaction-history-list-user_data */ public String futuresTransferHistory(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "asset", String.class); ParameterChecker.checkParameter(parameters, "startTime", Long.class); return requestHandler.sendSignedRequest(baseUrl, FUTURES_TRANSFER, parameters, HttpMethod.GET, showLimitUsage); } private final String BORROW = "/sapi/v1/futures/loan/borrow"; /** * POST /sapi/v1/futures/loan/borrow *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* coin -- mandatory/string
* amount -- mandatory/decimal -- when collateralAmount is empty
* collateralCoin -- mandatory/string
* collateralAmount -- mandatory/decimal -- when amount is empty
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#borrow-for-cross-collateral-trade */ public String borrow(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, BORROW, parameters, HttpMethod.POST, showLimitUsage); } private final String BORROW_HISTORY = "/sapi/v1/futures/loan/borrow/history"; /** * GET /sapi/v1/futures/loan/borrow/history *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* coin -- optional/string
* startTime -- optional/long
* endTime -- optional/long
* limit -- optional/long -- default 500, max 1000
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#cross-collateral-borrow-history-user_data */ public String borrowHistory(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, BORROW_HISTORY, parameters, HttpMethod.GET, showLimitUsage); } private final String REPAY = "/sapi/v1/futures/loan/repay"; /** * POST /sapi/v1/futures/loan/repay *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* coin -- mandatory/string
* collateralCoin -- mandatory/string
* amount -- mandatory/decimal
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#repay-for-cross-collateral-trade */ public String repay(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "coin", String.class); ParameterChecker.checkParameter(parameters, "collateralCoin", String.class); ParameterChecker.checkRequiredParameter(parameters, "amount"); return requestHandler.sendSignedRequest(baseUrl, REPAY, parameters, HttpMethod.POST, showLimitUsage); } private final String REPAY_HISTORY = "/sapi/v1/futures/loan/repay/history"; /** * GET /sapi/v1/futures/loan/repay/history *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* coin -- optional/string
* startTime -- optional/long
* endTime -- optional/long
* limit -- optional/long -- default 500, max 1000
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#cross-collateral-repayment-history-user_data */ public String repayHistory(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, REPAY_HISTORY, parameters, HttpMethod.GET, showLimitUsage); } private final String WALLET = "/sapi/v2/futures/loan/wallet"; /** * GET /sapi/v2/futures/loan/wallet *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#cross-collateral-wallet-user_data */ public String loanWallet(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, WALLET, parameters, HttpMethod.GET, showLimitUsage); } private final String LOAN_CONFIGS = "/sapi/v2/futures/loan/configs"; /** * GET /sapi/v2/futures/loan/configs *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* loanCoin -- optional/string
* collateralCoin -- optional/long
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#cross-collateral-information-v2-user_data */ public String loanConfigs(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, LOAN_CONFIGS, parameters, HttpMethod.GET, showLimitUsage); } private final String CALCU_ADJUST_LEVEL = "/sapi/v2/futures/loan/calcAdjustLevel"; /** * GET /sapi/v2/futures/loan/calcAdjustLevel *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* loanCoin -- mandatory/string
* collateralCoin -- mandatory/string
* amount -- mandatory/decimal
* direction -- mandatory/enum -- "ADDITIONAL", "REDUCED"
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#calculate-rate-after-adjust-cross-collateral-ltv-v2-user_data */ public String calcAdjustLevel(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "loanCoin", String.class); ParameterChecker.checkParameter(parameters, "collateralCoin", String.class); ParameterChecker.checkRequiredParameter(parameters, "amount"); ParameterChecker.checkParameter(parameters, "direction", String.class); return requestHandler.sendSignedRequest(baseUrl, CALCU_ADJUST_LEVEL, parameters, HttpMethod.GET, showLimitUsage); } private final String CALCU_MAX_ADJUST_AMOUNT = "/sapi/v2/futures/loan/calcMaxAdjustAmount"; /** * GET /sapi/v2/futures/loan/calcMaxAdjustAmount *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* loanCoin -- mandatory/string
* collateralCoin -- mandatory/string
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#get-max-amount-for-adjust-cross-collateral-ltv-v2-user_data */ public String calcMaxAdjustAmount(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "loanCoin", String.class); ParameterChecker.checkParameter(parameters, "collateralCoin", String.class); return requestHandler.sendSignedRequest(baseUrl, CALCU_MAX_ADJUST_AMOUNT, parameters, HttpMethod.GET, showLimitUsage); } private final String ADJUST_COLLATERAL = "/sapi/v2/futures/loan/adjustCollateral"; /** * POST /sapi/v2/futures/loan/adjustCollateral *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* loanCoin -- mandatory/string
* collateralCoin -- mandatory/string
* amount -- mandatory/decimal
* direction -- mandatory/enum -- "ADDITIONAL", "REDUCED"
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#calculate-rate-after-adjust-cross-collateral-ltv-v2-user_data */ public String adjustCollateral(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "loanCoin", String.class); ParameterChecker.checkParameter(parameters, "collateralCoin", String.class); ParameterChecker.checkRequiredParameter(parameters, "amount"); ParameterChecker.checkParameter(parameters, "direction", String.class); return requestHandler.sendSignedRequest(baseUrl, ADJUST_COLLATERAL, parameters, HttpMethod.POST, showLimitUsage); } private final String ADJUST_COLLATERAL_HISTORY = "/sapi/v1/futures/loan/adjustCollateral/history"; /** * GET /sapi/v1/futures/loan/adjustCollateral/history *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* loanCoin -- optional/string
* collateralCoin -- optional/string
* startTime -- optional/long
* endTime -- optional/long
* limit -- optional/long -- default 500, max 1000
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#adjust-cross-collateral-ltv-history-user_data */ public String adjustCollateralHistory(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, ADJUST_COLLATERAL_HISTORY, parameters, HttpMethod.GET, showLimitUsage); } private final String LIQUIDATION_HISTORY = "/sapi/v1/futures/loan/liquidationHistory"; /** * GET /sapi/v1/futures/loan/liquidationHistory *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* loanCoin -- optional/string
* collateralCoin -- optional/string
* startTime -- optional/long
* endTime -- optional/long
* limit -- optional/long -- default 500, max 1000
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#cross-collateral-liquidation-history-user_data */ public String liquidationHistory(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, LIQUIDATION_HISTORY, parameters, HttpMethod.GET, showLimitUsage); } private final String COLLATERAL_REPAY_LIMIT = "/sapi/v1/futures/loan/collateralRepayLimit"; /** * Check the maximum and minimum limit when repay with collateral. *

* GET /sapi/v1/futures/loan/collateralRepayLimit *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* coin -- mandatory/string
* collateralCoin -- mandatory/string
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#check-collateral-repay-limit-user_data */ public String collateralRepayLimit(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "coin", String.class); ParameterChecker.checkParameter(parameters, "collateralCoin", String.class); return requestHandler.sendSignedRequest(baseUrl, COLLATERAL_REPAY_LIMIT, parameters, HttpMethod.GET, showLimitUsage); } private final String COLLATERAL_REPAY = "/sapi/v1/futures/loan/collateralRepay"; /** * Get quote before repay with collateral is mandatory, the quote will be valid within 25 seconds. *

* GET /sapi/v1/futures/loan/collateralRepay *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* coin -- mandatory/string
* collateralCoin -- mandatory/string
* amount -- mandatory/decimal -- repay amount
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#get-collateral-repay-quote-user_data */ public String collateralRepayQuote(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "coin", String.class); ParameterChecker.checkParameter(parameters, "collateralCoin", String.class); ParameterChecker.checkRequiredParameter(parameters, "amount"); return requestHandler.sendSignedRequest(baseUrl, COLLATERAL_REPAY, parameters, HttpMethod.GET, showLimitUsage); } /** * Repay with collateral. Get quote before repay with collateral is mandatory, the quote will be valid within 25 seconds. *

* POST /sapi/v1/futures/loan/collateralRepay *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* quoteId -- mandatory/string
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#repay-with-collateral-user_data */ public String collateralRepay(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "quoteId", String.class); return requestHandler.sendSignedRequest(baseUrl, COLLATERAL_REPAY, parameters, HttpMethod.POST, showLimitUsage); } private final String COLLATERAL_REPAY_RESULT = "/sapi/v1/futures/loan/collateralRepayResult"; /** * Check collateral repayment result. *

* GET /sapi/v1/futures/loan/collateralRepayResult *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* quoteId -- mandatory/string
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#collateral-repayment-result-user_data */ public String collateralRepayResult(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "quoteId", String.class); return requestHandler.sendSignedRequest(baseUrl, COLLATERAL_REPAY_RESULT, parameters, HttpMethod.GET, showLimitUsage); } private final String INTEREST_HISTORY = "/sapi/v1/futures/loan/interestHistory"; /** * GET /sapi/v1/futures/loan/interestHistory *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* collateralCoin -- optional/string
* startTime -- optional/long
* endTime -- optional/long
* current -- optional/long -- Currently querying page. Start from 1. Default:1
* limit -- optional/long -- default 500, max 1000
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#cross-collateral-interest-history-user_data */ public String interestHistory(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, INTEREST_HISTORY, parameters, HttpMethod.GET, showLimitUsage); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy