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

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

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

import java.util.LinkedHashMap;

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;

/**
 * 

Crypto Loans Endpoints

* All endpoints under the * Crypto Loans Endpoint * section of the API documentation will be implemented in this class. *
* Response will be returned in String format. */ public class CryptoLoans { private final String baseUrl; private final RequestHandler requestHandler; private final boolean showLimitUsage; public CryptoLoans(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 CryptoLoans(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 LOAN_INCOME = "/sapi/v1/loan/income"; /** * GET /sapi/v1/loan/income *
* @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
* type -- optional/string -- All types will be returned by default. Enum: borrowIn, collateralSpent, repayAmount, collateralReturn(Collateral return after repayment), addCollateral, removeCollateral, collateralReturnAfterLiquidation
* startTime -- optional/long
* endTime -- optional/long
* limit -- optional/int -- default 20, max 100
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#get-crypto-loans-income-history-user_data */ public String loanIncome(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "asset", String.class); return requestHandler.sendSignedRequest(baseUrl, LOAN_INCOME, parameters, HttpMethod.GET, showLimitUsage); } private final String LOAN_BORROW = "/sapi/v1/loan/borrow"; /** * POST /sapi/v1/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 *

* loanCoin -- mandatory/string
* collateralCoin -- mandatory/string
* loanTerm -- mandatory/int -- 7/14/30/90/180 days
* loanAmount -- optional/decimal -- Mandatory when collateralAmount is empty
* collateralAmount -- optional/decimal -- Mandatory when loanAmount is empty
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#borrow-crypto-loan-borrow-trade */ public String loanBorrow(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "loanCoin", String.class); ParameterChecker.checkParameter(parameters, "collateralCoin", String.class); ParameterChecker.checkParameter(parameters, "loanTerm", Integer.class); return requestHandler.sendSignedRequest(baseUrl, LOAN_BORROW, parameters, HttpMethod.POST, showLimitUsage); } private final String LOAN_BORROW_HISTORY = "/sapi/v1/loan/borrow/history"; /** * GET /sapi/v1/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 *

* orderId -- optional/long -- orderId in POST /sapi/v1/loan/borrow
* loanCoin -- optional/string
* collateralCoin -- optional/string
* startTime -- optional/long
* endTime -- optional/long
* current -- optional/long -- Current querying page. Start from 1; default: 1; max: 1000
* limit -- optional/long -- Default: 10; max: 100
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#borrow-get-loan-borrow-history-user_data */ public String loanBorrowHistory(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, LOAN_BORROW_HISTORY, parameters, HttpMethod.GET, showLimitUsage); } private final String LOAN_ONGOING_ORDERS = "/sapi/v1/loan/ongoing/orders"; /** * GET /sapi/v1/loan/ongoing/orders *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* orderId -- optional/long -- orderId in POST /sapi/v1/loan/borrow
* loanCoin -- optional/string
* collateralCoin -- optional/string
* current -- optional/long -- Current querying page. Start from 1; default: 1; max: 1000
* limit -- optional/long -- Default: 10; max: 100
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#borrow-get-loan-ongoing-orders-user_data */ public String loanOngoingOrders(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, LOAN_ONGOING_ORDERS, parameters, HttpMethod.GET, showLimitUsage); } private final String LOAN_REPAY = "/sapi/v1/loan/repay"; /** * POST /sapi/v1/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 *

* orderId -- mandatory/long
* amount -- mandatory/decimal
* type -- optional/int -- Default: 1. 1 for "repay with borrowed coin"; 2 for "repay with collateral"
* collateralReturn -- optional/boolean -- Default: TRUE. TRUE: Return extra collateral to spot account; FALSE: Keep extra collateral in the order
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#repay-crypto-loan-repay-trade */ public String loanRepay(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "orderId", Long.class); ParameterChecker.checkRequiredParameter(parameters, "amount"); return requestHandler.sendSignedRequest(baseUrl, LOAN_REPAY, parameters, HttpMethod.POST, showLimitUsage); } private final String LOAN_REPAY_HISTORY = "/sapi/v1/loan/repay/history"; /** * GET /sapi/v1/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 *

* orderId -- optional/long
* loanCoin -- optional/string
* collateralCoin -- optional/string
* startTime -- optional/long
* endTime -- optional/long
* current -- optional/long -- Current querying page. Start from 1; default: 1; max: 1000
* limit -- optional/long -- Default: 10; max: 100
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#repay-get-loan-repayment-history-user_data */ public String loanRepayHistory(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, LOAN_REPAY_HISTORY, parameters, HttpMethod.GET, showLimitUsage); } private final String LOAN_ADJUST_LTV = "/sapi/v1/loan/adjust/ltv"; /** * POST /sapi/v1/loan/adjust/ltv *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* orderId -- mandatory/long
* amount -- mandatory/decimal
* direction -- optional/enum -- "ADDITIONAL", "REDUCED"
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#adjust-ltv-crypto-loan-adjust-ltv-trade */ public String loanAdjustLTV(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "orderId", Long.class); ParameterChecker.checkRequiredParameter(parameters, "amount"); return requestHandler.sendSignedRequest(baseUrl, LOAN_ADJUST_LTV, parameters, HttpMethod.POST, showLimitUsage); } private final String LOAN_ADJUST_LTV_HISTORY = "/sapi/v1/loan/ltv/adjustment/history"; /** * GET /sapi/v1/loan/ltv/adjustment/history *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* orderId -- optional/long
* loanCoin -- optional/string
* collateralCoin -- optional/string
* startTime -- optional/long
* endTime -- optional/long
* current -- optional/long -- Current querying page. Start from 1; default: 1; max: 1000
* limit -- optional/long -- Default: 10; max: 100
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#adjust-ltv-crypto-loan-adjust-ltv-trade */ public String loanAdjustLTVHistory(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, LOAN_ADJUST_LTV_HISTORY, parameters, HttpMethod.GET, showLimitUsage); } private final String LOANABLE_ASSETS_DATA = "/sapi/v1/loan/loanable/data"; /** * GET /sapi/v1/loan/loanable/data *
* @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
* vipLevel -- optional/int -- Default: user's VIP level. In case there's specific configuration, send "-1"
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#get-loanable-assets-data-user_data */ public String loanAssetsData(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, LOANABLE_ASSETS_DATA, parameters, HttpMethod.GET, showLimitUsage); } private final String COLLATERAL_ASSETS_DATA = "/sapi/v1/loan/collateral/data"; /** * GET /sapi/v1/loan/collateral/data *
* @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
* vipLevel -- optional/int -- Default: user's VIP level. In case there's specific configuration, send "-1"
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#get-collateral-assets-data-user_data */ public String collateralAssetsData(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, COLLATERAL_ASSETS_DATA, parameters, HttpMethod.GET, showLimitUsage); } private final String COLLATERAL_REPAY_RATE = "/sapi/v1/loan/repay/collateral/rate"; /** * GET /sapi/v1/loan/repay/collateral/rate *
* @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
* repayAmount -- mandatory/decimal -- repay amount of loanCoin
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#check-collateral-repay-rate-user_data */ public String collateralRepayRate(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "loanCoin", String.class); ParameterChecker.checkParameter(parameters, "collateralCoin", String.class); ParameterChecker.checkRequiredParameter(parameters, "repayAmount"); return requestHandler.sendSignedRequest(baseUrl, COLLATERAL_REPAY_RATE, parameters, HttpMethod.GET, showLimitUsage); } private final String CUSTOMIZE_MARGIN_CALL = "/sapi/v1/loan/customize/margin_call"; /** * GET /sapi/v1/loan/customize/margin_call *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* orderId -- optional/long -- Mandatory when collateralCoin is empty. Send either orderId or collateralCoin, if both parameters are sent, take orderId only.
* collateralCoin -- optional/string -- Mandatory when orderId is empty. Send either orderId or collateralCoin, if both parameters are sent, take orderId only.
* marginCall -- mandatory/decimal
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#crypto-loan-customize-margin-call-trade */ public String customizeMarginCall(LinkedHashMap parameters) { ParameterChecker.checkRequiredParameter(parameters, "marginCall"); return requestHandler.sendSignedRequest(baseUrl, CUSTOMIZE_MARGIN_CALL, parameters, HttpMethod.POST, showLimitUsage); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy