com.binance.connector.client.impl.spot.CryptoLoans 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.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;
/**
* 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 Map 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(Map 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 Map 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(Map 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 Map 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(Map 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 Map 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(Map 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 Map 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(Map 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 Map 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(Map 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 Map 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(Map 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 Map 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(Map 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 Map 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(Map 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 Map 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(Map 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 Map 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(Map 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 Map 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(Map parameters) {
ParameterChecker.checkRequiredParameter(parameters, "marginCall");
return requestHandler.sendSignedRequest(baseUrl, CUSTOMIZE_MARGIN_CALL, parameters, HttpMethod.POST, showLimitUsage);
}
private final String FLEXIBLE_LOAN_BORROW = "/sapi/v1/loan/flexible/borrow";
/**
* POST /sapi/v1/loan/flexible/borrow
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* loanCoin -- mandatory/string -- Coin loaned.
* loanAmount -- optional/decimal -- Loan amount. Mandatory when collateralAmount is empty.
* collateralCoin -- mandatory/string -- Coin used as collateral.
* collateralAmount -- optional/decimal -- Mandatory when loanAmount is empty.
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#borrow-flexible-loan-borrow-trade
*/
public String flexibleLoanBorrow(Map parameters) {
ParameterChecker.checkParameter(parameters, "loanCoin", String.class);
ParameterChecker.checkParameter(parameters, "collateralCoin", String.class);
return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_BORROW, parameters, HttpMethod.POST, showLimitUsage);
}
private final String FLEXIBLE_LOAN_ONGOING_ORDERS = "/sapi/v1/loan/flexible/ongoing/orders";
/**
* GET /sapi/v1/loan/flexible/ongoing/orders
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* loanCoin -- optional/string -- Coin loaned.
* collateralCoin -- optional/string -- Coin used as collateral
* current -- optional/long -- Current querying page. Start from 1; default: 1; max: 1000;
* limit -- optional/long -- Default: 10; max: 100
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#borrow-get-flexible-loan-ongoing-orders-user_data
*/
public String flexibleLoanOngoingOrders(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_ONGOING_ORDERS, parameters, HttpMethod.GET, showLimitUsage);
}
private final String FLEXIBLE_LOAN_BORROW_HISTORY = "/sapi/v1/loan/flexible/borrow/history";
/**
* GET /sapi/v1/loan/flexible/borrow/history
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* loanCoin -- optional/string -- Coin loaned
* collateralCoin -- optional/string -- Coin used as collateral
* startTime -- optional/long -- UTC timestamp in ms
* endTime -- optional/long -- UTC timestamp in ms
* current -- optional/long -- Current querying page. Start from 1; default: 1; max: 1000;
* limit -- optional/long -- Default: 10; max: 100;
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#borrow-get-flexible-loan-borrow-history-user_data
*/
public String flexibleLoanBorrowHistory(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_BORROW_HISTORY, parameters, HttpMethod.GET, showLimitUsage);
}
private final String FLEXIBLE_LOAN_REPAY = "/sapi/v1/loan/flexible/repay";
/**
* POST /sapi/v1/loan/flexible/repay
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* loanCoin -- mandatory/string -- Coin loaned
* collateralCoin -- mandatory/string -- Coin used as collateral
* repayAmount -- mandatory/decimal -- repay amount of loanCoin
* collateralReturn -- optional/boolean -- Default: TRUE. TRUE: Return extra collateral to earn account; FALSE: Keep extra collateral in the order, and lower LTV.
* fullRepayment -- optional/boolean -- Default: FALSE. TRUE: Full repayment; FALSE: Partial repayment, based on loanAmount.
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#repay-flexible-loan-repay-trade
*/
public String flexibleLoanRepay(Map parameters) {
ParameterChecker.checkParameter(parameters, "loanCoin", String.class);
ParameterChecker.checkParameter(parameters, "collateralCoin", String.class);
ParameterChecker.checkRequiredParameter(parameters, "repayAmount");
return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_REPAY, parameters, HttpMethod.POST, showLimitUsage);
}
private final String FLEXIBLE_LOAN_REPAY_HISTORY = "/sapi/v1/loan/flexible/repay/history";
/**
* GET /sapi/v1/loan/flexible/repay/history
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* loanCoin -- optional/string -- Coin loaned
* collateralCoin -- optional/string -- Coin used as collateral
* startTime -- optional/long -- UTC timestamp in ms
* endTime -- optional/long -- UTC timestamp in ms
* current -- optional/long -- Current querying page. Start from 1; default: 1; max: 1000;
* limit -- optional/long -- Default: 10; max: 100;
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#repay-get-flexible-loan-repayment-history-user_data
*/
public String flexibleLoanRepayHistory(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_REPAY_HISTORY, parameters, HttpMethod.GET, showLimitUsage);
}
private final String FLEXIBLE_LOAN_ADJUST_LTV = "/sapi/v1/loan/flexible/adjust/ltv";
/**
* POST /sapi/v1/loan/flexible/adjust/ltv
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* loanCoin -- mandatory/string -- Coin loaned
* collateralCoin -- mandatory/string -- Coin used as collateral
* adjustmentAmount -- mandatory/decimal
* direction -- mandatory/enum -- "ADDITIONAL", "REDUCED"
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#adjust-ltv-flexible-loan-adjust-ltv-trade
*/
public String flexibleLoanAdjustLtv(Map parameters) {
ParameterChecker.checkParameter(parameters, "loanCoin", String.class);
ParameterChecker.checkParameter(parameters, "collateralCoin", String.class);
ParameterChecker.checkRequiredParameter(parameters, "adjustmentAmount");
ParameterChecker.checkParameter(parameters, "direction", String.class);
return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_ADJUST_LTV, parameters, HttpMethod.POST, showLimitUsage);
}
private final String FLEXIBLE_LOAN_LTV_ADJUST_HISTORY = "/sapi/v1/loan/flexible/ltv/adjustment/history";
/**
* GET /sapi/v1/loan/flexible/ltv/adjustment/history
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* loanCoin -- optional/string -- Coin loaned
* collateralCoin -- optional/string -- Coin used as collateral
* startTime -- optional/long -- UTC timestamp in ms
* endTime -- optional/long -- UTC timestamp in ms
* current -- optional/long -- Current querying page. Start from 1. Default:1 Max:1000
* limit -- optional/long -- Default: 10; max: 100;
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#adjust-ltv-get-flexible-loan-ltv-adjustment-history-user_data
*/
public String flexibleLoanLtvAdjustHistory(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_LTV_ADJUST_HISTORY, parameters, HttpMethod.GET, showLimitUsage);
}
private final String FLEXIBLE_LOAN_ASSETS = "/sapi/v1/loan/flexible/loanable/data";
/**
* Get interest rate and borrow limit of flexible loanable assets. The borrow limit is shown in USD value.
*
*
* GET /sapi/v1/loan/flexible/loanable/data
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* loanCoin -- optional/string -- Coin loaned
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#get-flexible-loan-assets-data-user_data
*/
public String flexibleLoanAssets(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_ASSETS, parameters, HttpMethod.GET, showLimitUsage);
}
private final String FLEXIBLE_LOAN_COLLATERAL_ASSETS = "/sapi/v1/loan/flexible/collateral/data";
/**
* Get LTV information and collateral limit of flexible loan's collateral assets. The collateral limit is shown in USD value.
*
*
* GET /sapi/v1/loan/flexible/collateral/data
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* collateralCoin -- optional/string -- Coin used as collateral
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#get-flexible-loan-collateral-assets-data-user_data
*/
public String flexibleLoanCollateralAssets(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_COLLATERAL_ASSETS, parameters, HttpMethod.GET, showLimitUsage);
}
}