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://developers.binance.com/docs/crypto_loan/stable-rate/market-data/Get-Crypto-Loans-Income-History
*/
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://developers.binance.com/docs/crypto_loan/stable-rate/trade/Crypto-Loan-Borrow
*/
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://developers.binance.com/docs/crypto_loan/stable-rate/user-information/Get-Loan-Borrow-History
*/
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://developers.binance.com/docs/crypto_loan/stable-rate/user-information/Get-Loan-Ongoing-Orders
*/
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://developers.binance.com/docs/crypto_loan/stable-rate/trade/Crypto-Loan-Repay
*/
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://developers.binance.com/docs/crypto_loan/stable-rate/user-information/Get-Loan-Repayment-History
*/
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://developers.binance.com/docs/crypto_loan/stable-rate/trade/Crypto-Loan-Adjust-LTV
*/
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://developers.binance.com/docs/crypto_loan/stable-rate/user-information/Get-Loan-LTV-Adjustment-History
*/
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://developers.binance.com/docs/vip_loan/market-data/Get-Loanable-Assets-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://developers.binance.com/docs/crypto_loan/stable-rate/market-data/Get-Collateral-Assets-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://developers.binance.com/docs/crypto_loan/stable-rate/market-data/Check-Collateral-Repay-Rate
*/
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://developers.binance.com/docs/crypto_loan/stable-rate/trade/Crypto-Loan-Customize-Margin-Call
*/
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_V2 = "/sapi/v2/loan/flexible/borrow";
/**
* POST /sapi/v2/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://developers.binance.com/docs/crypto_loan/flexible-rate/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_V2, parameters, HttpMethod.POST, showLimitUsage);
}
private final String FLEXIBLE_LOAN_ONGOING_ORDERS_V2 = "/sapi/v2/loan/flexible/ongoing/orders";
/**
* GET /sapi/v2/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://developers.binance.com/docs/crypto_loan/flexible-rate/user-information/Get-Flexible-Loan-Ongoing-Orders
*/
public String flexibleLoanOngoingOrders(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_ONGOING_ORDERS_V2, parameters, HttpMethod.GET, showLimitUsage);
}
private final String FLEXIBLE_LOAN_BORROW_HISTORY_V2 = "/sapi/v2/loan/flexible/borrow/history";
/**
* GET /sapi/v2/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://developers.binance.com/docs/crypto_loan/flexible-rate/user-information/Get-Flexible-Loan-Borrow-History
*/
public String flexibleLoanBorrowHistory(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_BORROW_HISTORY_V2, parameters, HttpMethod.GET, showLimitUsage);
}
private final String FLEXIBLE_LOAN_REPAY_V2 = "/sapi/v2/loan/flexible/repay";
/**
* POST /sapi/v2/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://developers.binance.com/docs/crypto_loan/flexible-rate/trade/Flexible-Loan-Repay
*/
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_V2, parameters, HttpMethod.POST, showLimitUsage);
}
private final String FLEXIBLE_LOAN_REPAY_HISTORY_V2 = "/sapi/v2/loan/flexible/repay/history";
/**
* GET /sapi/v2/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://developers.binance.com/docs/crypto_loan/flexible-rate/user-information/Get-Flexible-Loan-Repayment-History
*/
public String flexibleLoanRepayHistory(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_REPAY_HISTORY_V2, parameters, HttpMethod.GET, showLimitUsage);
}
private final String FLEXIBLE_LOAN_ADJUST_LTV_V2 = "/sapi/v2/loan/flexible/adjust/ltv";
/**
* POST /sapi/v2/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://developers.binance.com/docs/crypto_loan/flexible-rate/trade/Flexible-Loan-Adjust-LTV
*/
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_V2, parameters, HttpMethod.POST, showLimitUsage);
}
private final String FLEXIBLE_LOAN_LTV_ADJUST_HISTORY_V2 = "/sapi/v2/loan/flexible/ltv/adjustment/history";
/**
* GET /sapi/v2/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://developers.binance.com/docs/crypto_loan/flexible-rate/user-information
*/
public String flexibleLoanLtvAdjustHistory(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_LTV_ADJUST_HISTORY_V2, parameters, HttpMethod.GET, showLimitUsage);
}
private final String FLEXIBLE_LOAN_ASSETS_V2 = "/sapi/v2/loan/flexible/loanable/data";
/**
* Get interest rate and borrow limit of flexible loanable assets. The borrow limit is shown in USD value.
*
*
* GET /sapi/v2/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://developers.binance.com/docs/crypto_loan/flexible-rate/market-data/Get-Flexible-Loan-Assets-Data
*/
public String flexibleLoanAssets(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_ASSETS_V2, parameters, HttpMethod.GET, showLimitUsage);
}
private final String FLEXIBLE_LOAN_COLLATERAL_ASSETS_V2 = "/sapi/v2/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/v2/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://developers.binance.com/docs/crypto_loan/flexible-rate/market-data
*/
public String flexibleLoanCollateralAssets(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, FLEXIBLE_LOAN_COLLATERAL_ASSETS_V2, parameters, HttpMethod.GET, showLimitUsage);
}
}