com.binance.connector.client.impl.spot.AutoInvest 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;
/**
* Auto-Invest Endpoints
* All endpoints under the
* Auto-Invest Endpoints
* section of the API documentation will be implemented in this class.
*
* Response will be returned in String format.
*/
public class AutoInvest {
private final String baseUrl;
private final RequestHandler requestHandler;
private final boolean showLimitUsage;
public AutoInvest(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 AutoInvest(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 TARGET_ASSET_LIST = "/sapi/v1/lending/auto-invest/target-asset/list";
/**
* GET /sapi/v1/lending/auto-invest/target-asset/list
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* targetAsset -- optional/string
* size -- optional/long -- Default:8 Max:100
* current -- optional/long -- Current querying page. Start from 1. Default:1
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://developers.binance.com/docs/auto_invest/market-data/Get-target-asset-list
*/
public String targetAssetList(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, TARGET_ASSET_LIST, parameters, HttpMethod.GET, showLimitUsage);
}
private final String TARGET_ASSET_ROI_LIST = "/sapi/v1/lending/auto-invest/target-asset/roi/list";
/**
* ROI return list for target asset
*
*
* GET /sapi/v1/lending/auto-invest/target-asset/roi/list
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* targetAsset -- mandatory/string
* hisRoiType -- mandatory/enum -- FIVE_YEAR,THREE_YEAR,ONE_YEAR,SIX_MONTH,THREE_MONTH,SEVEN_DAY
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://developers.binance.com/docs/auto_invest/market-data/Get-target-asset-ROI-data
*/
public String targetAssetRoiList(Map parameters) {
ParameterChecker.checkParameter(parameters, "targetAsset", String.class);
ParameterChecker.checkParameter(parameters, "hisRoiType", String.class);
return requestHandler.sendSignedRequest(baseUrl, TARGET_ASSET_ROI_LIST, parameters, HttpMethod.GET, showLimitUsage);
}
private final String ALL_SOURCE_AND_TARGET_ASSETS = "/sapi/v1/lending/auto-invest/all/asset";
/**
* Query all source assets and target assets
*
*
* GET /sapi/v1/lending/auto-invest/all/asset
*
* @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://developers.binance.com/docs/auto_invest/market-data/Query-all-source-asset-and-target-asset
*/
public String allSourceAndTargetAssets(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, ALL_SOURCE_AND_TARGET_ASSETS, parameters, HttpMethod.GET, showLimitUsage);
}
private final String SOURCE_ASSET_LIST = "/sapi/v1/lending/auto-invest/source-asset/list";
/**
* Query Source Asset to be used for investment
*
*
* GET /sapi/v1/lending/auto-invest/source-asset/list
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* targetAsset -- optional/string -- Example: BTC,ETH,BNB
* indexId -- optional/long
* usageType -- mandatory/string -- "RECURRING", "ONE_TIME"
* flexibleAllowedToUse -- optional/boolean
* sourceType -- optional/enum -- MAIN_SITE for Binance user,TR for Binance Turkey user
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://developers.binance.com/docs/auto_invest/market-data/Query-source-asset-list
*/
public String sourceAssetList(Map parameters) {
ParameterChecker.checkParameter(parameters, "usageType", String.class);
return requestHandler.sendSignedRequest(baseUrl, SOURCE_ASSET_LIST, parameters, HttpMethod.GET, showLimitUsage);
}
private final String CHANGE_PLAN_STATUS = "/sapi/v1/lending/auto-invest/plan/edit-status";
/**
* Change Plan Status
*
* POST /sapi/v1/lending/auto-invest/plan/edit-status
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* planId -- mandatory/long
* status -- mandatory/enum -- "ONGOING","PAUSED","REMOVED"
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://developers.binance.com/docs/auto_invest/trade/Change-Plan-Status
*/
public String changePlanStatus(Map parameters) {
ParameterChecker.checkParameter(parameters, "planId", Long.class);
ParameterChecker.checkParameter(parameters, "status", String.class);
return requestHandler.sendPublicRequest(baseUrl, CHANGE_PLAN_STATUS, parameters, HttpMethod.POST, showLimitUsage);
}
private final String PLANS = "/sapi/v1/lending/auto-invest/plan/list";
/**
* Query plan lists
*
* GET /sapi/v1/lending/auto-invest/plan/list
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* planType -- mandatory/string
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://developers.binance.com/docs/auto_invest/market-data/Get-list-of-plans
*/
public String plansList(Map parameters) {
ParameterChecker.checkParameter(parameters, "planType", String.class);
return requestHandler.sendPublicRequest(baseUrl, PLANS, parameters, HttpMethod.GET, showLimitUsage);
}
private final String HOLDING_PLAN = "/sapi/v1/lending/auto-invest/plan/id";
/**
* Query holding details of the plan
*
*
* GET /sapi/v1/lending/auto-invest/plan/id
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* planId -- optional/long
* requestId -- optional/string
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://developers.binance.com/docs/auto_invest/trade/Query-holding-details-of-the-plan
*/
public String holdingPlan(Map parameters) {
return requestHandler.sendPublicRequest(baseUrl, HOLDING_PLAN, parameters, HttpMethod.GET, showLimitUsage);
}
private final String PLAN_SUBSCRIPTIONS_HISTORY = "/sapi/v1/lending/auto-invest/history/list";
/**
* Query the transaction history of plan subscriptions
*
*
* GET /sapi/v1/lending/auto-invest/history/list
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* planId -- optional/long
* startTime -- optional/long -- UTC timestamp in ms
* endTime -- optional/long -- UTC timestamp in ms
* targetAsset -- optional/string
* planType -- optional/enum
* size -- optional/long -- Default:10 Max:100
* current -- optional/long -- Current querying page. Start from 1. Default:1
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://developers.binance.com/docs/auto_invest/trade/Query-subscription-transaction-history
*/
public String planSubsHistory(Map parameters) {
return requestHandler.sendPublicRequest(baseUrl, PLAN_SUBSCRIPTIONS_HISTORY, parameters, HttpMethod.GET, showLimitUsage);
}
private final String INDEX_INFO = "/sapi/v1/lending/auto-invest/index/info";
/**
* Query index details
*
*
* GET /sapi/v1/lending/auto-invest/index/info
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* indexId -- mandatory/long
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://developers.binance.com/docs/auto_invest/market-data/Query-Index-Details
*/
public String indexInfo(Map parameters) {
ParameterChecker.checkParameter(parameters, "indexId", Long.class);
return requestHandler.sendSignedRequest(baseUrl, INDEX_INFO, parameters, HttpMethod.GET, showLimitUsage);
}
private final String INDEX_USER_SUMMARY = "/sapi/v1/lending/auto-invest/index/user-summary";
/**
* Details on users Index-Linked plan position details
*
*
* GET /sapi/v1/lending/auto-invest/index/user-summary
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* indexId -- mandatory/long
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://developers.binance.com/docs/auto_invest/trade/Query-Index-Linked-Plan-Position-Details
*/
public String userIndexPlans(Map parameters) {
ParameterChecker.checkParameter(parameters, "indexId", Long.class);
return requestHandler.sendSignedRequest(baseUrl, INDEX_USER_SUMMARY, parameters, HttpMethod.GET, showLimitUsage);
}
private final String ONE_TIME_TRANSACTION = "/sapi/v1/lending/auto-invest/one-off";
/**
* One time transaction
*
*
* POST /sapi/v1/lending/auto-invest/one-off
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* sourceType -- mandatory/string -- "MAIN_SITE" for Binance,"TR" for Binance Turkey
* requestId -- optional/string -- If not null, must follow sourceType + unique string, e.g: TR12354859
* subscriptionAmount -- mandatory/decimal
* sourceAsset -- mandatory/string
* flexibleAllowedToUse -- optional/boolean -- true/false;true: using flexible wallet
* planId -- optional/long -- portfolio plan's Id
* indexId -- optional/long
* details -- optional/arraylist -- The "PortfolioDetail" class contains 2 fields: "targetAsset" and "percentage".
* The sum of all the "PortfolioDetail" percentages in the Array should be 100.
* "details" example:
* details[0].targetAsset=BTC, details[0].percentage=60
* details[1].targetAsset=ETH, details[1].percentage=40
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://developers.binance.com/docs/auto_invest/trade/One-Time-Transaction
*/
public String submitOneTimeTransaction(Map parameters) {
ParameterChecker.checkParameter(parameters, "sourceType", String.class);
ParameterChecker.checkRequiredParameter(parameters, "subscriptionAmount");
ParameterChecker.checkParameter(parameters, "sourceAsset", String.class);
return requestHandler.sendSignedRequest(baseUrl, ONE_TIME_TRANSACTION, parameters, HttpMethod.POST, showLimitUsage);
}
private final String ONE_TIME_TRANSACTION_STATUS = "/sapi/v1/lending/auto-invest/one-off/status";
/**
* Transaction status for one-time transaction
*
*
* GET /sapi/v1/lending/auto-invest/one-off/status
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* transactionId -- mandatory/long -- portfolio plan's Id
* requestId -- optional/string -- transactionId and requestId cannot be empty at the same time
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://developers.binance.com/docs/auto_invest/trade/Query-One-Time-Transaction-Status
*/
public String oneTimeTransactionStatus(Map parameters) {
ParameterChecker.checkParameter(parameters, "transactionId", Long.class);
return requestHandler.sendSignedRequest(baseUrl, ONE_TIME_TRANSACTION_STATUS, parameters, HttpMethod.GET, showLimitUsage);
}
private final String REDEEM_INDEX_PLAN = "/sapi/v1/lending/auto-invest/redeem";
/**
* To redeem index-Linked plan holdings
*
*
* POST /sapi/v1/lending/auto-invest/redeem
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* indexId -- mandatory/long -- portfolio plan's Id
* requestId -- optional/string -- transactionId and requestId cannot be empty at the same time
* redemptionPercentage -- mandatory/long -- user redeem percentage,10/20/100.
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://developers.binance.com/docs/auto_invest/trade/Index-Linked-Plan-Redemption
*/
public String redeemIndexPlan(Map parameters) {
ParameterChecker.checkParameter(parameters, "indexId", Long.class);
ParameterChecker.checkParameter(parameters, "redemptionPercentage", Integer.class);
return requestHandler.sendSignedRequest(baseUrl, REDEEM_INDEX_PLAN, parameters, HttpMethod.POST, showLimitUsage);
}
private final String INDEX_LINKED_PLAN_REDEMPTION_HISTORY = "/sapi/v1/lending/auto-invest/redeem/history";
/**
* Get the history of Index Linked Plan Redemption transactions
*
* Max 30 day difference between startTime and endTime
* If no startTime and endTime, default to show past 30 day records
*
*
* GET /sapi/v1/lending/auto-invest/redeem/history
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* requestId -- mandatory/long
* 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
* asset -- optional/string
* size -- optional/long -- Default:10 Max:100
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://developers.binance.com/docs/auto_invest/trade/Query-Index-Linked-Plan-Redemption
*/
public String indexPlanRedeemHistory(Map parameters) {
ParameterChecker.checkParameter(parameters, "requestId", Long.class);
return requestHandler.sendSignedRequest(baseUrl, INDEX_LINKED_PLAN_REDEMPTION_HISTORY, parameters, HttpMethod.GET, showLimitUsage);
}
private final String INDEX_LINKED_PLAN_REBALANCE_DETAILS = "/sapi/v1/lending/auto-invest/rebalance/history";
/**
* GET /sapi/v1/lending/auto-invest/rebalance/history
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* 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
* size -- optional/long -- Default:10 Max:100
* recvWindow -- optional/long -- The value cannot be greater than 60000
* @return String
* @see
* https://developers.binance.com/docs/auto_invest/trade/Index-Linked-Plan-Rebalance-Details
*/
public String indexPlanRebalanceInfo(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, INDEX_LINKED_PLAN_REBALANCE_DETAILS, parameters, HttpMethod.GET, showLimitUsage);
}
}