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

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

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

import java.math.BigDecimal;
import java.util.ArrayList;
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;

/**
 * 

Wallet Endpoints

* All endpoints under the * Wallet Endpoint * section of the API documentation will be implemented in this class. *
* Response will be returned in String format. */ public class Wallet { private final String baseUrl; private final RequestHandler requestHandler; private final boolean showLimitUsage; public Wallet(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 Wallet(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 SYSTEM_STATUS = "/sapi/v1/system/status"; /** * Fetch system status. *

* GET /sapi/v1/system/status *
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#system-status-system */ public String systemStatus() { return requestHandler.sendPublicRequest(baseUrl, SYSTEM_STATUS, null, HttpMethod.GET, showLimitUsage); } private final String COIN_INFO = "/sapi/v1/capital/config/getall"; /** * Get information of coins (available for deposit and withdraw) for user. *

* GET /sapi/v1/capital/config/getall *
* @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/#all-coins-39-information-user_data */ public String coinInfo(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, COIN_INFO, parameters, HttpMethod.GET, showLimitUsage); } private final String ACC_SNAP = "/sapi/v1/accountSnapshot"; /** * GET /sapi/v1/accountSnapshot *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* type -- mandatory/string -- "SPOT", "MARGIN", "FUTURES"
* startTime -- optional/long
* endTime -- optional/long
* limit -- optional/int -- min 5, max 30, default 5
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#daily-account-snapshot-user_data */ public String accountSnapshot(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "type", String.class); return requestHandler.sendSignedRequest(baseUrl, ACC_SNAP, parameters, HttpMethod.GET, showLimitUsage); } private final String DISABLE_FAST = "/sapi/v1/account/disableFastWithdrawSwitch"; /** * POST /sapi/v1/account/disableFastWithdrawSwitch *
* @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/#disable-fast-withdraw-switch-user_data */ public String disableFastWithdraw(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, DISABLE_FAST, parameters, HttpMethod.POST, showLimitUsage); } private final String ENABLE_FAST = "/sapi/v1/account/enableFastWithdrawSwitch"; /** * POST /sapi/v1/account/enableFastWithdrawSwitch *
* @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/#enable-fast-withdraw-switch-user_data */ public String enableFastWithdraw(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, ENABLE_FAST, parameters, HttpMethod.POST, showLimitUsage); } private final String WITHDRAW = "/sapi/v1/capital/withdraw/apply"; /** * Submit a withdraw request. *

* POST /sapi/v1/capital/withdraw/apply *
* @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
* withdrawOrderId -- optional/string -- client id for withdraw
* network -- optional/string
* address -- mandatory/string
* addressTag -- optional/string -- Secondary address identifier for coins like XRP,XMR etc.
* amount -- mandatory/decimal
* transactionFeeFlag -- optional/boolean -- When making internal transfer, true for returning the fee to the destination account; * false for returning the fee back to the departure account. Default false.
* name -- optional/string -- Description of the address. Space in name should be encoded into %20.
* walletType -- optional/int -- The wallet type for withdraw, 0-spot wallet , 1-funding wallet.Default spot wallet
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#withdraw-user_data */ public String withdraw(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "coin", String.class); ParameterChecker.checkParameter(parameters, "address", String.class); ParameterChecker.checkRequiredParameter(parameters, "amount"); return requestHandler.sendSignedRequest(baseUrl, WITHDRAW, parameters, HttpMethod.POST, showLimitUsage); } private final String DEPOSIT_HIST = "/sapi/v1/capital/deposit/hisrec"; /** * Fetch deposit history. *

* GET /sapi/v1/capital/deposit/hisrec *
* @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
* status -- optional/int -- 0(0:pending,6: credited but cannot withdraw, 1:success)
* startTime -- optional/long -- Default: 90 days from current timestamp
* endTime -- optional/long -- Default: present timestamp
* offset -- optional/int -- Default:0
* limit -- optional/int -- Default:1000, Max:1000
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#deposit-history-supporting-network-user_data */ public String depositHistory(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, DEPOSIT_HIST, parameters, HttpMethod.GET, showLimitUsage); } private final String WITHDRAW_HIST = "/sapi/v1/capital/withdraw/history"; /** * Fetch withdraw history. *

* GET /sapi/v1/capital/withdraw/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
* status -- optional/int -- 0(0:Email Sent,1:Cancelled 2:Awaiting Approval 3:Rejected 4:Processing 5:Failure 6:Completed)
* startTime -- optional/long -- Default: 90 days from current timestamp
* endTime -- optional/long -- Default: present timestamp
* offset -- optional/int
* limit -- optional/int -- Default:1000, Max:1000
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#withdraw-history-supporting-network-user_data */ public String withdrawHistory(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, WITHDRAW_HIST, parameters, HttpMethod.GET, showLimitUsage); } private final String DEPOSIT_ADD = "/sapi/v1/capital/deposit/address"; /** * Fetch deposit address with network. *

* GET /sapi/v1/capital/withdraw/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 -- mandatory/string
* network -- optional/string
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#deposit-address-supporting-network-user_data */ public String depositAddress(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "coin", String.class); return requestHandler.sendSignedRequest(baseUrl, DEPOSIT_ADD, parameters, HttpMethod.GET, showLimitUsage); } private final String ACC_STATUS = "/sapi/v1/account/status"; /** * Fetch account status detail. *

* GET /sapi/v1/account/status *
* @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/#account-status-user_data */ public String accountStatus(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, ACC_STATUS, parameters, HttpMethod.GET, showLimitUsage); } private final String API_TRADE_STATUS = "/sapi/v1/account/apiTradingStatus"; /** * Fetch account api trading status detail. *

* GET /sapi/v1/account/apiTradingStatus *
* @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/#account-api-trading-status-user_data */ public String apiTradingStatus(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, API_TRADE_STATUS, parameters, HttpMethod.GET, showLimitUsage); } private final String DUST_LOG = "/sapi/v1/asset/dribblet"; /** * Fetch account api trading status detail. *

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

* startTime -- optional/long
* endTime -- optional/long
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#dustlog-user_data */ public String dustLog(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, DUST_LOG, parameters, HttpMethod.GET, showLimitUsage); } private final String BNB_CONVERTABLE_ASSETS = "/sapi/v1/asset/dust-btc"; /** * POST /sapi/v1/asset/dust-btc *
* @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/#get-assets-that-can-be-converted-into-bnb-user_data */ public String bnbConvertableAssets(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, BNB_CONVERTABLE_ASSETS, parameters, HttpMethod.POST, showLimitUsage); } private final String DUST_TRANSFER = "/sapi/v1/asset/dust"; /** * Convert dust assets to BNB. *

* POST /sapi/v1/asset/dust *
* @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/array -- The asset being converted. For example: asset=BTC&asset=USDT
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#dust-transfer-user_data */ public String dustTransfer(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "asset", ArrayList.class); return requestHandler.sendSignedRequest(baseUrl, DUST_TRANSFER, parameters, HttpMethod.POST, showLimitUsage); } private final String ASSET_DIVIDEND = "/sapi/v1/asset/assetDividend"; /** * Query asset dividend record. *

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

* asset -- optional/string
* startTime -- optional/long
* endTime -- optional/long
* limit -- optional/int -- Default 20, max 500
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#asset-dividend-record-user_data */ public String assetDividend(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, ASSET_DIVIDEND, parameters, HttpMethod.GET, showLimitUsage); } private final String ASSET_DETAIL = "/sapi/v1/asset/assetDetail"; /** * Fetch details of assets supported on Binance. *

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

* asset -- optional/string
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#asset-detail-user_data */ public String assetDetail(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, ASSET_DETAIL, parameters, HttpMethod.GET, showLimitUsage); } private final String TRADE_FEE = "/sapi/v1/asset/tradeFee"; /** * Fetch trade fee. *

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

* symbol -- optional/string
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#trade-fee-user_data */ public String tradeFee(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, TRADE_FEE, parameters, HttpMethod.GET, showLimitUsage); } private final String UNIVERSAL_TRANSFER = "/sapi/v1/asset/transfer"; /** * You need to enable Permits Universal Transfer option for the api key which requests this endpoint. *

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

* type -- mandatory/enum
* asset -- mandatory/string
* amount -- mandatory/string
* fromSymbol -- optional/string
* toSymbol -- optional/string
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#user-universal-transfer-user_data */ public String universalTransfer(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "type", String.class); ParameterChecker.checkParameter(parameters, "asset", String.class); ParameterChecker.checkRequiredParameter(parameters, "amount"); return requestHandler.sendSignedRequest(baseUrl, UNIVERSAL_TRANSFER, parameters, HttpMethod.POST, showLimitUsage); } /** * GET /sapi/v1/asset/transfer *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* type -- mandatory/enum
* startTime -- optional/long
* endTime -- optional/long
* current -- optional/int -- Default 1
* size -- optional/int -- Default 10, Max 100
* fromSymbol -- optional/string
* toSymbol -- optional/string
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#query-user-universal-transfer-history-user_data */ public String queryUniversalTransfer(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "type", String.class); return requestHandler.sendSignedRequest(baseUrl, UNIVERSAL_TRANSFER, parameters, HttpMethod.GET, showLimitUsage); } private final String FUNDING_WALLET = "/sapi/v1/asset/get-funding-asset"; /** * POST /sapi/v1/asset/get-funding-asset *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* asset -- optional/string
* needBtcValuation -- optional/string -- true or false
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#funding-wallet-user_data */ public String fundingWallet(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, FUNDING_WALLET, parameters, HttpMethod.POST, showLimitUsage); } private final String API_PERMISSION = "/sapi/v1/account/apiRestrictions"; /** * GET /sapi/v1/account/apiRestrictions *
* @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/#get-api-key-permission-user_data */ public String apiPermission(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, API_PERMISSION, parameters, HttpMethod.GET, showLimitUsage); } private final String USER_ASSET = "/sapi/v3/asset/getUserAsset"; /** * Get user assets, just for positive data. *

* POST /sapi/v3/asset/getUserAsset *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* asset -- optional/string -- If asset is blank, then query all positive assets user have.
* needBtcValuation -- optional/boolean -- Whether need btc valuation or not.
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#user-asset-user_data */ public String getUserAsset(LinkedHashMap parameters) { return requestHandler.sendSignedRequest(baseUrl, USER_ASSET, parameters, HttpMethod.POST, showLimitUsage); } private final String BUSD_CONVERT = "/sapi/v1/asset/convert-transfer"; /** * Convert transfer, convert between BUSD and stablecoins. *

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

* clientTranId -- mandatory/string -- The unique user-defined transaction id, min length 20
* asset -- mandatory/string -- The current asset
* amount -- mandatory/BigDecimal -- The amount must be positive number
* targetAsset -- mandatory/string -- Target asset you want to convert
* accountType -- optional/string -- Only MAIN and CARD, default MAIN
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#busd-convert-trade */ public String busdConvert(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "clientTranId", String.class); ParameterChecker.checkParameter(parameters, "asset", String.class); ParameterChecker.checkParameter(parameters, "amount", BigDecimal.class); ParameterChecker.checkParameter(parameters, "targetAsset", String.class); return requestHandler.sendSignedRequest(baseUrl, BUSD_CONVERT, parameters, HttpMethod.POST, showLimitUsage); } private final String BUSD_CONVERT_HISTORY = "/sapi/v1/asset/convert-transfer/queryByPage"; /** *

* GET /sapi/v1/asset/convert-transfer/queryByPage *
* @param * parameters LinkedHashedMap of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* * startTime -- mandatory/long -- inclusive, unit: ms
* endTime -- mandatory/long -- exclusive, unit: ms
* tranId -- optional/long -- The transaction id
* clientTranId -- optional/string -- The unique user-defined transaction id
* asset -- optional/string -- If not sent or null, deducted asset and target asset are returned.
* accountType -- optional/string -- MAIN: main account. CARD: funding account. If not sent or null, spot and card wallet will be queried.
* current -- optional/integer -- current page, default 1, the min value is 1
* size -- optional/integer -- page size, default 10, the max value is 100
* recvWindow -- optional/long
* @return String * @see * https://binance-docs.github.io/apidocs/spot/en/#busd-convert-history-user_data */ public String busdConvertHistory(LinkedHashMap parameters) { ParameterChecker.checkParameter(parameters, "startTime", Long.class); ParameterChecker.checkParameter(parameters, "endTime", Long.class); return requestHandler.sendSignedRequest(baseUrl, BUSD_CONVERT_HISTORY, parameters, HttpMethod.GET, showLimitUsage); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy