From 44d20c0c4c8192467f4b110ac050907292ebe32f Mon Sep 17 00:00:00 2001 From: Girts Strazdins Date: Thu, 29 Dec 2022 08:53:33 +0100 Subject: [PATCH 01/14] Clean the README, refer to the original lib. --- README.md | 523 +----------------------------------------------------- 1 file changed, 4 insertions(+), 519 deletions(-) diff --git a/README.md b/README.md index e90c3ed4c..23e4ba678 100755 --- a/README.md +++ b/README.md @@ -1,523 +1,8 @@ # Java Binance API -binance-java-api is a lightweight Java library for interacting with the [Binance API](https://developers.binance.com/docs/api/scopes), providing complete API coverage, and supporting synchronous and asynchronous requests, as well as event streaming using WebSockets. +This is a fork of the original [Java Binance API](https://github.com/binance-exchange/binance-java-api). -## Features -* Support for synchronous and asynchronous REST requests to all [General](https://www.binance.com/restapipub.html#user-content-general-endpoints), [Market Data](https://www.binance.com/restapipub.html#user-content-market-data-endpoints), [Account](https://www.binance.com/restapipub.html#user-content-account-endpoints) endpoints, and [User](https://www.binance.com/restapipub.html#user-content-user-data-stream-endpoints) stream endpoints. -* Support for User Data, Trade, Kline, and Depth event streaming using [Binance WebSocket API](https://www.binance.com/restapipub.html#wss-endpoint). +This fork was made primarily because the original library is not actively maintained and does not +support some endpoints necessary for Profit-Loss (PNL) reports. -## Installation -1. Install library into your Maven's local repository by running `mvn install` -2. Add the following Maven dependency to your project's `pom.xml`: -``` - - com.binance.api - binance-api-client - 1.0.0 - -``` - -Alternatively, you can clone this repository and run the [examples](https://github.com/joaopsilva/binance-java-api/tree/master/src/test/java/com/binance/api/examples). - -## Examples - -### Getting Started - -There are three main client classes that can be used to interact with the API: - -1. [`BinanceApiRestClient`](https://github.com/joaopsilva/binance-java-api/blob/master/src/main/java/com/binance/api/client/BinanceApiRestClient.java), a synchronous/blocking [Binance API](https://www.binance.com/restapipub.html) client; -2. [`BinanceApiAsyncRestClient`](https://github.com/joaopsilva/binance-java-api/blob/master/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java), an asynchronous/non-blocking [Binance API](https://www.binance.com/restapipub.html) client; -3. [`BinanceApiWebSocketClient`](https://github.com/joaopsilva/binance-java-api/blob/master/src/main/java/com/binance/api/client/BinanceApiWebSocketClient.java), a data streaming client using [Binance WebSocket API](https://www.binance.com/restapipub.html#wss-endpoint). - -These can be instantiated through the corresponding factory method of [`BinanceApiClientFactory`](https://github.com/joaopsilva/binance-java-api/blob/master/src/main/java/com/binance/api/client/BinanceApiClientFactory.java), by passing the [security parameters](https://www.binance.com/restapipub.html#user-content-endpoint-security-type) `API-KEY` and `SECRET`, which can be created at [https://www.binance.com/userCenter/createApi.html](https://www.binance.com/userCenter/createApi.html). - -```java -BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance("API-KEY", "SECRET"); -BinanceApiRestClient client = factory.newRestClient(); -``` - -If the client only needs to access endpoints which do not require additional security, then these parameters are optional. - -Once the client is instantiated, it is possible to start making requests to the API. - -### General endpoints - -#### Test connectivity -```java -client.ping(); -``` -#### Check server time -```java -long serverTime = client.getServerTime(); -System.out.println(serverTime); -``` -
- View Response - -```java -1508380346873 -``` -
- -### Market Data endpoints - -#### Order book of a symbol -```java -OrderBook orderBook = client.getOrderBook("NEOETH", 10); -List asks = orderBook.getAsks(); -OrderBookEntry firstAskEntry = asks.get(0); -System.out.println(firstAskEntry.getPrice() + " / " + firstAskEntry.getQty()); -``` -
- View Response - - ```java -0.09200000 / 5.52000000 -``` -
- -#### Compressed/Aggregate trades list of a symbol -```java -List aggTrades = client.getAggTrades("NEOETH"); -System.out.println(aggTrades); -``` -
- View Response - - ```java -[AggTrade[aggregatedTradeId=30593,price=0.09880800,quantity=40.89000000,firstBreakdownTradeId=33363,lastBreakdownTradeId=33363,tradeTime=1508331041246,isBuyerMaker=true], ...] -``` -
- -#### Weekly candlestick bars for a symbol -```java -List candlesticks = client.getCandlestickBars("NEOETH", CandlestickInterval.WEEKLY); -System.out.println(candlesticks); -``` -
- View Response - - ```java -[Candlestick[openTime=1506297600000,open=0.09700000,high=0.12000100,low=0.05500000,close=0.11986900,volume=25709.37000000,closeTime=1506902399999,quoteAssetVolume=2649.80091051,numberOfTrades=2435,takerBuyBaseAssetVolume=10520.59000000,takerBuyQuoteAssetVolume=1101.94985388], ...] -``` -
- -#### Latest price of a symbol -```java -TickerStatistics tickerStatistics = client.get24HrPriceStatistics("NEOETH"); -System.out.println(tickerStatistics.getLastPrice()); -``` -
- View Response - - ```java -0.09100100 -``` -
- -#### Getting all latests prices -```java -List allPrices = client.getAllPrices(); -System.out.println(allPrices); -``` -
- View Response - - ```java -[TickerPrice[symbol=ETHBTC,price=0.05590400], TickerPrice[symbol=LTCBTC,price=0.01073300], ...] -``` -
- -### Account Data endpoints - -#### Get account balances -```java -Account account = client.getAccount(); -System.out.println(account.getBalances()); -System.out.println(account.getAssetBalance("ETH").getFree()); -``` -
- View Response - - ```java -AssetBalance[asset=ETH,free=0.10000000,locked=0.00000000] -0.10000000 -``` -
- -#### Get list of trades for an account and a symbol -```java -List myTrades = client.getMyTrades("NEOETH"); -System.out.println(myTrades); -``` -
- View Response - - ```java -[Trade[id=123,price=0.00000100,qty=1000.00000000,commission=0.00172100,commissionAsset=ETH,time=1507927870561,buyer=false,maker=false,bestMatch=true,symbol=,orderId=11289], Trade[id=123,price=0.00001000,qty=3.00000000,commission=0.00000003,commissionAsset=ETH,time=1507927874215,buyer=false,maker=false,bestMatch=true,symbol=,orderId=123]] -``` -
- -#### Get account open orders for a symbol -```java -List openOrders = client.getOpenOrders(new OrderRequest("LINKETH")); -System.out.println(openOrders); -``` -
- View Response - - ```java -[Order[symbol=LINKETH,orderId=12345,clientOrderId=XYZ,price=0.00010000,origQty=1000.00000000,executedQty=0.00000000,status=NEW,timeInForce=GTC,type=LIMIT,side=BUY,stopPrice=0.00000000,icebergQty=0.00000000,time=1508382291552]] -``` -
- -#### Get order status -```java -Order order = client.getOrderStatus(new OrderStatusRequest("LINKETH", 12345L)); -System.out.println(order.getExecutedQty()); -``` -
- View Response - - ```java -0.00000000 -``` -
- -#### Placing a MARKET order -```java -NewOrderResponse newOrderResponse = client.newOrder(marketBuy("LINKETH", "1000").orderRespType(OrderResponseType.FULL)); -List fills = newOrderResponse.getFills(); -System.out.println(newOrderResponse.getClientOrderId()); -``` -
- View Response - - ```java -XXXXXfc2XXzTXXGs66ZcXX -``` -
- -#### Placing a LIMIT order -```java -NewOrderResponse newOrderResponse = client.newOrder(limitBuy("LINKETH", TimeInForce.GTC, "1000", "0.0001")); -System.out.println(newOrderResponse.getTransactTime()); -``` -
- View Response - - ```java -1508382322725 -``` -
- -#### Canceling an order -```java -client.cancelOrder(new CancelOrderRequest("LINKETH", 123015L)); -``` - -#### Withdraw - -In order to be able to withdraw programatically, please enable the `Enable Withdrawals` option in the API settings. - -```java -client.withdraw("ETH", "0x123", "0.1", null); -``` - -#### Fetch withdraw history - -```java -WithdrawHistory withdrawHistory = client.getWithdrawHistory("ETH"); -System.out.println(withdrawHistory); -``` -
- View Response - - ```java -WithdrawHistory[withdrawList=[Withdraw[amount=0.1,address=0x123,asset=ETH,applyTime=2017-10-13 20:59:38,successTime=2017-10-13 21:20:09,txId=0x456,id=789]],success=true] -``` -
- -#### Fetch deposit history -```java -DepositHistory depositHistory = client.getDepositHistory("ETH"); -System.out.println(depositHistory); -``` -
- View Response - - ```java -DepositHistory[depositList=[Deposit[amount=0.100000000000000000,asset=ETH,insertTime=2017-10-18 13:03:39], Deposit[amount=1.000000000000000000,asset=NEO,insertTime=2017-10-13 20:24:04]],success=true] -``` -
- -#### Get deposit address -```java -DepositAddress depositAddress = client.getDepositAddress("ETH"); -System.out.println(depositAddress); -``` -
- View Response - - ```java -DepositAddress[address=0x99...,success=true,addressTag=,asset=ETH] -``` -
- -### User stream endpoints - -#### Start user data stream, keepalive, and close data stream -```java -String listenKey = client.startUserDataStream(); -client.keepAliveUserDataStream(listenKey); -client.closeUserDataStream(listenKey); -``` - -### WebSocket API - -#### Initialize the WebSocket client -```java -BinanceApiWebSocketClient client = BinanceApiClientFactory.newInstance().newWebSocketClient(); -``` - -User needs to be aware that REST symbols which are `upper case` differ from WebSocket symbols which must be `lower case`. -In scenario of subscription with upper case styled symbol, server will return no error and subscribe to given channel - however, no events will be pushed. - -#### Handling web socket errors - -Each of the methods on `BinanceApiWebSocketClient`, which opens a new web socket, takes a `BinanceApiCallback`, which is -called for each event received from the Binance servers. - -The `BinanceApiCallback` interface also has a `onFailure(Throwable)` method, which, optionally, can be implemented to -receive notifications if the web-socket fails, e.g. disconnection. - -```java -client.onAggTradeEvent(symbol.toLowerCase(), new BinanceApiCallback() { - @Override - public void onResponse(final AggTradeEvent response) { - System.out.println(response); - } - - @Override - public void onFailure(final Throwable cause) { - System.err.println("Web socket failed"); - cause.printStackTrace(System.err); - } -}); -``` - -#### Closing web sockets - -Each of the methods on `BinanceApiWebSocketClient`, which opens a new web socket, also returns a `Closeable`. -This `Closeable` can be used to close the underlying web socket and free any associated resources, e.g. - -```java -Closable ws = client.onAggTradeEvent("ethbtc", someCallback); -// some time later... -ws.close(); -``` - -#### Listen for aggregated trade events for ETH/BTC -```java -client.onAggTradeEvent("ethbtc", (AggTradeEvent response) -> { - System.out.println(response.getPrice()); - System.out.println(response.getQuantity()); -}); -``` -
- View Response - - ```java -0.05583500 / 1.06400000 -1508383333069 -0.05557200 / 2.00000000 -1508383345070 -0.05583200 / 2.68500000 -1508383352961 -... -``` -
- -#### Listen for changes in the order book for ETH/BTC -```java -client.onDepthEvent("ethbtc", (DepthEvent response) -> { - System.out.println(response.getAsks()); -}); -``` -
- View Response - - ```java -[OrderBookEntry[price=0.05559500,qty=7.94200000], OrderBookEntry[price=0.05559800,qty=0.00000000]] -[OrderBookEntry[price=0.05558400,qty=30.61800000], OrderBookEntry[price=0.05559500,qty=0.00000000], OrderBookEntry[price=0.05560600,qty=8.32100000]] -[OrderBookEntry[price=0.05559100,qty=7.86600000], OrderBookEntry[price=0.05560600,qty=0.00000000], OrderBookEntry[price=0.05607700,qty=5.15500000], OrderBookEntry[price=0.05620700,qty=0.00000000], OrderBookEntry[price=0.05842200,qty=0.00000000]] -[OrderBookEntry[price=0.05558400,qty=29.61700000]] -... -``` -
- -#### Get 1m candlesticks in real-time for ETH/BTC -```java -client.onCandlestickEvent("ethbtc", CandlestickInterval.ONE_MINUTE, response -> System.out.println(response)); -``` -
- View Response - - ```java -CandlestickEvent[eventType=kline,eventTime=1508417055113,symbol=ETHBTC,openTime=1508417040000,open=0.05376300,high=0.05376300,low=0.05372900,close=0.05372900,volume=0.49400000,closeTime=1508417099999,intervalId=1m,firstTradeId=2199019,lastTradeId=2199020,quoteAssetVolume=0.02654552,numberOfTrades=2,takerBuyBaseAssetVolume=0.00000000,takerBuyQuoteAssetVolume=0.00000000,isBarFinal=false] -CandlestickEvent[eventType=kline,eventTime=1508417055145,symbol=ETHBTC,openTime=1508417040000,open=0.05376300,high=0.05376300,low=0.05371700,close=0.05371700,volume=0.62900000,closeTime=1508417099999,intervalId=1m,firstTradeId=2199019,lastTradeId=2199021,quoteAssetVolume=0.03379731,numberOfTrades=3,takerBuyBaseAssetVolume=0.00000000,takerBuyQuoteAssetVolume=0.00000000,isBarFinal=false] -CandlestickEvent[eventType=kline,eventTime=1508417096085,symbol=ETHBTC,openTime=1508417040000,open=0.05376300,high=0.05376300,low=0.05370900,close=0.05370900,volume=0.68000000,closeTime=1508417099999,intervalId=1m,firstTradeId=2199019,lastTradeId=2199022,quoteAssetVolume=0.03653646,numberOfTrades=4,takerBuyBaseAssetVolume=0.00000000,takerBuyQuoteAssetVolume=0.00000000,isBarFinal=false] -... -``` -
- -#### Keep a local depth cache for a symbol - -Please see [DepthCacheExample.java](https://github.com/joaopsilva/binance-java-api/blob/master/src/test/java/com/binance/api/examples/DepthCacheExample.java) for an implementation which uses the binance-java-api for maintaining a local depth cache for a symbol. In the same folder, you can also find how to do caching of account balances, aggregated trades, and klines/candlesticks. - -
- View Response - - ```java -ASKS: -0.05690700 / 6.15100000 -0.05447800 / 0.09500000 -0.05447700 / 28.22000000 -0.05439000 / 0.54500000 -0.05438400 / 1.10300000 -0.05436600 / 0.06100000 -0.05434000 / 0.05500000 -0.05432800 / 3.45100000 -0.05422700 / 1.11100000 -0.05410600 / 5.85900000 -0.05409300 / 4.50000000 -BIDS: -0.05390000 / 2.26000000 -0.05389000 / 15.00000000 -0.05385600 / 1.95000000 -0.05367900 / 0.10000000 -0.05366700 / 2.27600000 -0.05360000 / 10.96100000 -0.05348500 / 14.04000000 -0.05345000 / 0.56100000 -0.05336200 / 21.10000000 -0.05336100 / 21.15000000 -0.05306600 / 0.21100000 -0.05116300 / 10.95000000 -BEST ASK: 0.05409300 / 4.50000000 -BEST BID: 0.05390000 / 2.26000000 -... -``` -
- -#### Listen for changes in the account - -```java -client.onUserDataUpdateEvent(listenKey, response -> { - if (response.getEventType() == UserDataUpdateEventType.ACCOUNT_UPDATE) { - AccountUpdateEvent accountUpdateEvent = response.getAccountUpdateEvent(); - - // Print new balances of every available asset - System.out.println(accountUpdateEvent.getBalances()); - } else { - OrderTradeUpdateEvent orderTradeUpdateEvent = response.getOrderTradeUpdateEvent(); - - // Print details about an order/trade - System.out.println(orderTradeUpdateEvent); - - // Print original quantity - System.out.println(orderTradeUpdateEvent.getOriginalQuantity()); - - // Or price - System.out.println(orderTradeUpdateEvent.getPrice()); - } -}); -``` - -#### Multi-channel subscription -Client provides a way for user to subscribe to multiple channels using same websocket - to achieve that user needs to coma-separate symbols as it is in following examples. - -````java -client.onAggTradeEvent("ethbtc,ethusdt", (AggTradeEvent response) -> { - if (Objects.equals(response.getSymbol(),"ethbtc")) { - // handle ethbtc event - } else if(Objects.equals(response.getSymbol()),"ethusdt")) { - // handle ethusdt event - } -}); -```` -````java -client.onDepthEvent("ethbtc,ethusdt", (DepthEvent response) -> { - if (Objects.equals(response.getSymbol(),"ethbtc")) { - // handle ethbtc event - } else if(Objects.equals(response.getSymbol()),"ethusdt")) { - // handle ethusdt event - } -}); -```` -````java -client.onCandlestickEvent("ethbtc,ethusdt", CandlestickInterval.ONE_MINUTE, (CandlestickEvent response) -> { - if (Objects.equals(response.getSymbol(),"ethbtc")) { - // handle ethbtc event - } else if(Objects.equals(response.getSymbol()),"ethusdt")) { - // handle ethusdt event - } -}); -```` - -### Asynchronous requests - -To make an asynchronous request it is necessary to use the `BinanceApiAsyncRestClient`, and call the method with the same name as in the synchronous version, but passing a callback [`BinanceApiCallback`](https://github.com/joaopsilva/binance-java-api/blob/master/src/main/java/com/binance/api/client/BinanceApiCallback.java) that handles the response whenever it arrives. - -#### Get latest price of a symbol asynchronously -```java -client.get24HrPriceStatistics("NEOETH", (TickerStatistics response) -> { - System.out.println(response.getLastPrice()); - System.out.println(response.getVolume()); -}); -``` -
- View Response - - ```java -0.09100100 -``` -
- -#### Placing a LIMIT order asynchronously -```java -client.newOrder(limitBuy("LINKETH", TimeInForce.GTC, "1000", "0.0001"), (NewOrderResponse response) -> { - System.out.println(response.getTransactTime()); -}); -``` -
- View Response - - ```java -1508382322725 -``` -
- -### Exception handling - -Every API method can potentially throw an unchecked `BinanceApiException` which wraps the error message returned from the Binance API, or an exception, in case the request never properly reached the server. - -```java -try { - client.getOrderBook("UNKNOWN", 10); -} catch (BinanceApiException e) { - System.out.println(e.getError().getCode()); // -1121 - System.out.println(e.getError().getMsg()); // Invalid symbol -} -``` -
- View Response - -```java --1121 -Invalid symbol -``` -
- -### More examples -An extensive set of examples, covering most aspects of the API, can be found at https://github.com/joaopsilva/binance-java-api/tree/master/src/test/java/com/binance/api/examples. +See the [docs for the original library](https://github.com/binance-exchange/binance-java-api). From f101abd18edc89c07391c0f71553459d51879b51 Mon Sep 17 00:00:00 2001 From: Girts Strazdins Date: Thu, 29 Dec 2022 08:54:35 +0100 Subject: [PATCH 02/14] Updates Retrofit version in the pom (not tested yet). Use Java 17. --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 67e7af532..c31624681 100755 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ - 2.4.0 + 2.9.0 @@ -53,8 +53,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.8 - 1.8 + 17 + 17 From 63ea7b971a18b8e553b6caea1fe18737bf1fbb60 Mon Sep 17 00:00:00 2001 From: Girts Strazdins Date: Thu, 29 Dec 2022 08:56:09 +0100 Subject: [PATCH 03/14] Auto-format all files (with 2-spaces, Google Style) --- .../BinanceApiAsyncMarginRestClient.java | 11 +- .../api/client/BinanceApiAsyncRestClient.java | 92 +-- .../api/client/BinanceApiCallback.java | 25 +- .../api/client/BinanceApiClientFactory.java | 30 +- .../client/BinanceApiMarginRestClient.java | 231 +++---- .../api/client/BinanceApiRestClient.java | 46 +- .../api/client/BinanceApiSwapRestClient.java | 148 ++--- .../api/client/BinanceApiWebSocketClient.java | 136 ++--- .../api/client/config/BinanceApiConfig.java | 128 ++-- .../client/constant/BinanceApiConstants.java | 2 +- .../com/binance/api/client/constant/Util.java | 30 +- .../api/client/domain/ContingencyType.java | 2 +- .../LiquidityOperationRecordStatus.java | 14 +- .../api/client/domain/OCOOrderStatus.java | 6 +- .../binance/api/client/domain/OCOStatus.java | 6 +- .../api/client/domain/SwapRemoveType.java | 2 +- .../api/client/domain/TimeInForce.java | 2 +- .../domain/account/CrossMarginAssets.java | 132 ++-- .../domain/account/DustTransferResponse.java | 58 +- .../api/client/domain/account/Liquidity.java | 160 ++--- .../account/LiquidityOperationRecord.java | 152 ++--- .../api/client/domain/account/Loan.java | 72 +-- .../client/domain/account/MarginAccount.java | 6 +- .../client/domain/account/MarginNewOrder.java | 546 ++++++++--------- .../account/MarginNewOrderResponse.java | 314 +++++----- .../account/MaxBorrowableQueryResult.java | 4 +- .../api/client/domain/account/NewOCO.java | 454 +++++++------- .../client/domain/account/NewOCOResponse.java | 148 ++--- .../api/client/domain/account/NewOrder.java | 30 +- .../domain/account/NewOrderResponseType.java | 7 +- .../api/client/domain/account/Order.java | 38 +- .../api/client/domain/account/OrderList.java | 144 ++--- .../client/domain/account/OrderReport.java | 230 +++---- .../api/client/domain/account/Pool.java | 72 +-- .../api/client/domain/account/Repay.java | 152 ++--- .../domain/account/RepayQueryResult.java | 6 +- .../client/domain/account/SideEffectType.java | 6 +- .../domain/account/SubAccountTransfer.java | 286 ++++----- .../client/domain/account/SwapHistory.java | 192 +++--- .../api/client/domain/account/SwapQuote.java | 152 ++--- .../api/client/domain/account/SwapRecord.java | 26 +- .../api/client/domain/account/SwapStatus.java | 14 +- .../domain/account/TradeHistoryItem.java | 182 +++--- .../client/domain/account/TransferResult.java | 113 ++-- .../client/domain/account/WithdrawResult.java | 94 +-- .../account/request/AllOrderListRequest.java | 96 +-- .../request/CancelOrderListRequest.java | 108 ++-- .../account/request/CancelOrderResponse.java | 10 +- .../request/OrderListStatusRequest.java | 66 +- .../domain/event/AccountUpdateEvent.java | 2 +- .../client/domain/event/BookTickerEvent.java | 194 +++--- .../event/CandlestickEventSerializer.java | 4 +- .../api/client/domain/event/TickerEvent.java | 472 +++++++-------- .../domain/event/UserDataUpdateEvent.java | 12 +- .../api/client/domain/general/Asset.java | 220 +++---- .../client/domain/general/ExchangeFilter.java | 4 +- .../client/domain/general/SymbolFilter.java | 10 +- .../market/OrderBookEntrySerializer.java | 2 +- .../domain/market/TickerStatistics.java | 6 +- .../client/exception/BinanceApiException.java | 6 +- .../BinanceApiAsyncMarginRestClientImpl.java | 160 ++--- .../impl/BinanceApiAsyncRestClientImpl.java | 2 +- .../impl/BinanceApiMarginRestClientImpl.java | 194 +++--- .../client/impl/BinanceApiRestClientImpl.java | 514 ++++++++-------- .../api/client/impl/BinanceApiService.java | 568 +++++++++--------- .../impl/BinanceApiServiceGenerator.java | 150 ++--- .../impl/BinanceApiSwapRestClientImpl.java | 188 +++--- .../impl/BinanceApiWebSocketClientImpl.java | 144 ++--- .../security/AuthenticationInterceptor.java | 122 ++-- .../api/client/security/HmacSHA256Signer.java | 3 +- 70 files changed, 3991 insertions(+), 3967 deletions(-) diff --git a/src/main/java/com/binance/api/client/BinanceApiAsyncMarginRestClient.java b/src/main/java/com/binance/api/client/BinanceApiAsyncMarginRestClient.java index 8d1d8486f..91d7a551b 100755 --- a/src/main/java/com/binance/api/client/BinanceApiAsyncMarginRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiAsyncMarginRestClient.java @@ -31,7 +31,7 @@ public interface BinanceApiAsyncMarginRestClient { * Get all open orders on margin account for a symbol (async). * * @param orderRequest order request parameters - * @param callback the callback that handles the response + * @param callback the callback that handles the response */ void getOpenOrders(OrderRequest orderRequest, BinanceApiCallback> callback); @@ -84,7 +84,8 @@ public interface BinanceApiAsyncMarginRestClient { /** * Execute transfer between spot account and margin account - * @param asset asset to repay + * + * @param asset asset to repay * @param amount amount to repay * @return transaction id */ @@ -92,7 +93,8 @@ public interface BinanceApiAsyncMarginRestClient { /** * Apply for a loan - * @param asset asset to repay + * + * @param asset asset to repay * @param amount amount to repay * @return transaction id */ @@ -100,7 +102,8 @@ public interface BinanceApiAsyncMarginRestClient { /** * Repay loan for margin account - * @param asset asset to repay + * + * @param asset asset to repay * @param amount amount to repay * @return transaction id */ diff --git a/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java b/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java index d0e3b1c01..44e337a7a 100755 --- a/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java @@ -61,8 +61,8 @@ public interface BinanceApiAsyncRestClient { /** * Get order book of a symbol (asynchronous) * - * @param symbol ticker symbol (e.g. ETHBTC) - * @param limit depth of the order book (max 100) + * @param symbol ticker symbol (e.g. ETHBTC) + * @param limit depth of the order book (max 100) * @param callback the callback that handles the response */ void getOrderBook(String symbol, Integer limit, BinanceApiCallback callback); @@ -70,8 +70,8 @@ public interface BinanceApiAsyncRestClient { /** * Get recent trades (up to last 500). Weight: 1 * - * @param symbol ticker symbol (e.g. ETHBTC) - * @param limit of last trades (Default 500; max 1000.) + * @param symbol ticker symbol (e.g. ETHBTC) + * @param limit of last trades (Default 500; max 1000.) * @param callback the callback that handles the response */ void getTrades(String symbol, Integer limit, BinanceApiCallback> callback); @@ -79,9 +79,9 @@ public interface BinanceApiAsyncRestClient { /** * Get older trades. Weight: 5 * - * @param symbol ticker symbol (e.g. ETHBTC) - * @param limit of last trades (Default 500; max 1000.) - * @param fromId TradeId to fetch from. Default gets most recent trades. + * @param symbol ticker symbol (e.g. ETHBTC) + * @param limit of last trades (Default 500; max 1000.) + * @param fromId TradeId to fetch from. Default gets most recent trades. * @param callback the callback that handles the response */ void getHistoricalTrades(String symbol, Integer limit, Long fromId, BinanceApiCallback> callback); @@ -89,16 +89,16 @@ public interface BinanceApiAsyncRestClient { /** * Get compressed, aggregate trades. Trades that fill at the time, from the same order, with * the same price will have the quantity aggregated. - * + *

* If both startTime and endTime are sent, limitshould not * be sent AND the distance between startTime and endTime must be less than 24 hours. * - * @param symbol symbol to aggregate (mandatory) - * @param fromId ID to get aggregate trades from INCLUSIVE (optional) - * @param limit Default 500; max 1000 (optional) + * @param symbol symbol to aggregate (mandatory) + * @param fromId ID to get aggregate trades from INCLUSIVE (optional) + * @param limit Default 500; max 1000 (optional) * @param startTime Timestamp in ms to get aggregate trades from INCLUSIVE (optional). - * @param endTime Timestamp in ms to get aggregate trades until INCLUSIVE (optional). - * @param callback the callback that handles the response + * @param endTime Timestamp in ms to get aggregate trades until INCLUSIVE (optional). + * @param callback the callback that handles the response * @return a list of aggregate trades for the given symbol */ void getAggTrades(String symbol, String fromId, Integer limit, Long startTime, Long endTime, BinanceApiCallback> callback); @@ -113,12 +113,12 @@ public interface BinanceApiAsyncRestClient { /** * Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time. * - * @param symbol symbol to aggregate (mandatory) - * @param interval candlestick interval (mandatory) - * @param limit Default 500; max 1000 (optional) + * @param symbol symbol to aggregate (mandatory) + * @param interval candlestick interval (mandatory) + * @param limit Default 500; max 1000 (optional) * @param startTime Timestamp in ms to get candlestick bars from INCLUSIVE (optional). - * @param endTime Timestamp in ms to get candlestick bars until INCLUSIVE (optional). - * @param callback the callback that handles the response containing a candlestick bar for the given symbol and interval + * @param endTime Timestamp in ms to get candlestick bars until INCLUSIVE (optional). + * @param callback the callback that handles the response containing a candlestick bar for the given symbol and interval */ void getCandlestickBars(String symbol, CandlestickInterval interval, Integer limit, Long startTime, Long endTime, BinanceApiCallback> callback); @@ -132,17 +132,17 @@ public interface BinanceApiAsyncRestClient { /** * Get 24 hour price change statistics (asynchronous). * - * @param symbol ticker symbol (e.g. ETHBTC) + * @param symbol ticker symbol (e.g. ETHBTC) * @param callback the callback that handles the response */ void get24HrPriceStatistics(String symbol, BinanceApiCallback callback); - + /** * Get 24 hour price change statistics for all symbols (asynchronous). - * + * * @param callback the callback that handles the response */ - void getAll24HrPriceStatistics(BinanceApiCallback> callback); + void getAll24HrPriceStatistics(BinanceApiCallback> callback); /** * Get Latest price for all symbols (asynchronous). @@ -150,14 +150,14 @@ public interface BinanceApiAsyncRestClient { * @param callback the callback that handles the response */ void getAllPrices(BinanceApiCallback> callback); - + /** * Get latest price for symbol (asynchronous). - * - * @param symbol ticker symbol (e.g. ETHBTC) + * + * @param symbol ticker symbol (e.g. ETHBTC) * @param callback the callback that handles the response */ - void getPrice(String symbol , BinanceApiCallback callback); + void getPrice(String symbol, BinanceApiCallback callback); /** * Get best price/qty on the order book for all symbols (asynchronous). @@ -171,7 +171,7 @@ public interface BinanceApiAsyncRestClient { /** * Send in a new order (asynchronous) * - * @param order the new order to submit. + * @param order the new order to submit. * @param callback the callback that handles the response */ void newOrder(NewOrder order, BinanceApiCallback callback); @@ -179,7 +179,7 @@ public interface BinanceApiAsyncRestClient { /** * Test new order creation and signature/recvWindow long. Creates and validates a new order but does not send it into the matching engine. * - * @param order the new TEST order to submit. + * @param order the new TEST order to submit. * @param callback the callback that handles the response */ void newOrderTest(NewOrder order, BinanceApiCallback callback); @@ -188,7 +188,7 @@ public interface BinanceApiAsyncRestClient { * Check an order's status (asynchronous). * * @param orderStatusRequest order status request parameters - * @param callback the callback that handles the response + * @param callback the callback that handles the response */ void getOrderStatus(OrderStatusRequest orderStatusRequest, BinanceApiCallback callback); @@ -196,7 +196,7 @@ public interface BinanceApiAsyncRestClient { * Cancel an active order (asynchronous). * * @param cancelOrderRequest order status request parameters - * @param callback the callback that handles the response + * @param callback the callback that handles the response */ void cancelOrder(CancelOrderRequest cancelOrderRequest, BinanceApiCallback callback); @@ -204,7 +204,7 @@ public interface BinanceApiAsyncRestClient { * Get all open orders on a symbol (asynchronous). * * @param orderRequest order request parameters - * @param callback the callback that handles the response + * @param callback the callback that handles the response */ void getOpenOrders(OrderRequest orderRequest, BinanceApiCallback> callback); @@ -212,7 +212,7 @@ public interface BinanceApiAsyncRestClient { * Get all account orders; active, canceled, or filled. * * @param orderRequest order request parameters - * @param callback the callback that handles the response + * @param callback the callback that handles the response */ void getAllOrders(AllOrdersRequest orderRequest, BinanceApiCallback> callback); @@ -229,9 +229,9 @@ public interface BinanceApiAsyncRestClient { /** * Get trades for a specific account and symbol. * - * @param symbol symbol to get trades from - * @param limit default 500; max 1000 - * @param fromId TradeId to fetch from. Default gets most recent trades. + * @param symbol symbol to get trades from + * @param limit default 500; max 1000 + * @param fromId TradeId to fetch from. Default gets most recent trades. * @param callback the callback that handles the response with a list of trades */ void getMyTrades(String symbol, Integer limit, Long fromId, Long recvWindow, Long timestamp, BinanceApiCallback> callback); @@ -239,8 +239,8 @@ public interface BinanceApiAsyncRestClient { /** * Get trades for a specific account and symbol. * - * @param symbol symbol to get trades from - * @param limit default 500; max 1000 + * @param symbol symbol to get trades from + * @param limit default 500; max 1000 * @param callback the callback that handles the response with a list of trades */ void getMyTrades(String symbol, Integer limit, BinanceApiCallback> callback); @@ -248,20 +248,20 @@ public interface BinanceApiAsyncRestClient { /** * Get trades for a specific account and symbol. * - * @param symbol symbol to get trades from + * @param symbol symbol to get trades from * @param callback the callback that handles the response with a list of trades */ void getMyTrades(String symbol, BinanceApiCallback> callback); /** * Submit a withdraw request. - * + *

* Enable Withdrawals option has to be active in the API settings. * - * @param asset asset symbol to withdraw - * @param address address to withdraw to - * @param amount amount to withdraw - * @param name description/alias of the address + * @param asset asset symbol to withdraw + * @param address address to withdraw to + * @param amount amount to withdraw + * @param name description/alias of the address * @param addressTag Secondary address identifier for coins like XRP,XMR etc. */ void withdraw(String asset, String address, String amount, String name, String addressTag, BinanceApiCallback callback); @@ -285,7 +285,7 @@ public interface BinanceApiAsyncRestClient { * * @param callback the callback that handles the response and returns the deposit address */ - void getDepositAddress(String asset, BinanceApiCallback callback); + void getDepositAddress(String asset, BinanceApiCallback callback); // User stream endpoints @@ -300,7 +300,7 @@ public interface BinanceApiAsyncRestClient { * PING a user data stream to prevent a time out. * * @param listenKey listen key that identifies a data stream - * @param callback the callback that handles the response which contains a listenKey + * @param callback the callback that handles the response which contains a listenKey */ void keepAliveUserDataStream(String listenKey, BinanceApiCallback callback); @@ -308,7 +308,7 @@ public interface BinanceApiAsyncRestClient { * Close out a new user data stream. * * @param listenKey listen key that identifies a data stream - * @param callback the callback that handles the response which contains a listenKey + * @param callback the callback that handles the response which contains a listenKey */ void closeUserDataStream(String listenKey, BinanceApiCallback callback); } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/BinanceApiCallback.java b/src/main/java/com/binance/api/client/BinanceApiCallback.java index 3112bd793..d15528ad1 100755 --- a/src/main/java/com/binance/api/client/BinanceApiCallback.java +++ b/src/main/java/com/binance/api/client/BinanceApiCallback.java @@ -8,17 +8,18 @@ @FunctionalInterface public interface BinanceApiCallback { - /** - * Called whenever a response comes back from the Binance API. - * - * @param response the expected response object - */ - void onResponse(T response); + /** + * Called whenever a response comes back from the Binance API. + * + * @param response the expected response object + */ + void onResponse(T response); - /** - * Called whenever an error occurs. - * - * @param cause the cause of the failure - */ - default void onFailure(Throwable cause) {} + /** + * Called whenever an error occurs. + * + * @param cause the cause of the failure + */ + default void onFailure(Throwable cause) { + } } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/BinanceApiClientFactory.java b/src/main/java/com/binance/api/client/BinanceApiClientFactory.java index 7ba5551bb..66de5fa7c 100755 --- a/src/main/java/com/binance/api/client/BinanceApiClientFactory.java +++ b/src/main/java/com/binance/api/client/BinanceApiClientFactory.java @@ -35,16 +35,17 @@ private BinanceApiClientFactory(String apiKey, String secret) { /** * Instantiates a new binance api client factory. * - * @param apiKey the API key - * @param secret the Secret - * @param useTestnet true if endpoint is spot test network URL; false if endpoint is production spot API URL. + * @param apiKey the API key + * @param secret the Secret + * @param useTestnet true if endpoint is spot test network URL; false if endpoint is production spot API URL. * @param useTestnetStreaming true for spot test network websocket streaming; false for no streaming. */ private BinanceApiClientFactory(String apiKey, String secret, boolean useTestnet, boolean useTestnetStreaming) { - this(apiKey, secret); - if (useTestnet) { - BinanceApiConfig.useTestnet = true; - BinanceApiConfig.useTestnetStreaming = useTestnetStreaming; } + this(apiKey, secret); + if (useTestnet) { + BinanceApiConfig.useTestnet = true; + BinanceApiConfig.useTestnetStreaming = useTestnetStreaming; + } } /** @@ -52,7 +53,6 @@ private BinanceApiClientFactory(String apiKey, String secret, boolean useTestnet * * @param apiKey the API key * @param secret the Secret - * * @return the binance api client factory */ public static BinanceApiClientFactory newInstance(String apiKey, String secret) { @@ -62,15 +62,14 @@ public static BinanceApiClientFactory newInstance(String apiKey, String secret) /** * New instance with optional Spot Test Network endpoint. * - * @param apiKey the API key - * @param secret the Secret - * @param useTestnet true if endpoint is spot test network URL; false if endpoint is production spot API URL. + * @param apiKey the API key + * @param secret the Secret + * @param useTestnet true if endpoint is spot test network URL; false if endpoint is production spot API URL. * @param useTestnetStreaming true for spot test network websocket streaming; false for no streaming. - * * @return the binance api client factory. */ - public static BinanceApiClientFactory newInstance(String apiKey, String secret, boolean useTestnet, boolean useTestnetStreaming) { - return new BinanceApiClientFactory(apiKey, secret, useTestnet, useTestnetStreaming); + public static BinanceApiClientFactory newInstance(String apiKey, String secret, boolean useTestnet, boolean useTestnetStreaming) { + return new BinanceApiClientFactory(apiKey, secret, useTestnet, useTestnetStreaming); } /** @@ -85,9 +84,8 @@ public static BinanceApiClientFactory newInstance() { /** * New instance without authentication and with optional Spot Test Network endpoint. * - * @param useTestnet true if endpoint is spot test network URL; false if endpoint is production spot API URL. + * @param useTestnet true if endpoint is spot test network URL; false if endpoint is production spot API URL. * @param useTestnetStreaming true for spot test network websocket streaming; false for no streaming. - * * @return the binance api client factory. */ public static BinanceApiClientFactory newInstance(boolean useTestnet, boolean useTestnetStreaming) { diff --git a/src/main/java/com/binance/api/client/BinanceApiMarginRestClient.java b/src/main/java/com/binance/api/client/BinanceApiMarginRestClient.java index 6f100a365..f682b9039 100755 --- a/src/main/java/com/binance/api/client/BinanceApiMarginRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiMarginRestClient.java @@ -10,118 +10,125 @@ import java.util.List; public interface BinanceApiMarginRestClient { - /** - * Get current margin account information using default parameters. - */ - MarginAccount getAccount(); - - /** - * Get all open orders on margin account for a symbol. - * - * @param orderRequest order request parameters - */ - List getOpenOrders(OrderRequest orderRequest); - - /** - * Send in a new margin order. - * - * @param order the new order to submit. - * @return a response containing details about the newly placed order. - */ - MarginNewOrderResponse newOrder(MarginNewOrder order); - - /** - * Cancel an active margin order. - * - * @param cancelOrderRequest order status request parameters - */ - CancelOrderResponse cancelOrder(CancelOrderRequest cancelOrderRequest); - - /** - * Check margin order's status. - * @param orderStatusRequest order status request options/filters - * - * @return an order - */ - Order getOrderStatus(OrderStatusRequest orderStatusRequest); - - /** - * Get margin trades for a specific symbol. - * - * @param symbol symbol to get trades from - * @return a list of trades - */ - List getMyTrades(String symbol); - - // User stream endpoints - - /** - * Start a new user data stream. - * - * @return a listen key that can be used with data streams - */ - String startUserDataStream(); - - /** - * PING a user data stream to prevent a time out. - * - * @param listenKey listen key that identifies a data stream - */ - void keepAliveUserDataStream(String listenKey); - - /** - * Execute transfer between spot account and margin account - * @param asset asset to repay - * @param amount amount to repay - * @return transaction id - */ - MarginTransaction transfer(String asset, String amount, TransferType type); - - /** - * Apply for a loan - * @param asset asset to repay - * @param amount amount to repay - * @return transaction id - */ - MarginTransaction borrow(String asset, String amount); - - /** - * Query loan record - * @param asset asset to query - * @return repay records - */ - RepayQueryResult queryRepay(String asset, long startTime); - - /** - * Query max borrowable - * @param asset asset to query - * @return max borrowable - */ - MaxBorrowableQueryResult queryMaxBorrowable(String asset); - - /** - * Query loan record - * @param asset asset to query - * @param txId the tranId in POST /sapi/v1/margin/repay - * @return loan records - */ - RepayQueryResult queryRepay(String asset, String txId); - - /** - * Repay loan for margin account - * @param asset asset to repay - * @param amount amount to repay - * @return transaction id - */ - MarginTransaction repay(String asset, String amount); - - /** - * Query loan record - * @param asset asset to query - * @param txId the tranId in POST /sapi/v1/margin/loan - * @return loan records - */ - LoanQueryResult queryLoan(String asset, String txId); + /** + * Get current margin account information using default parameters. + */ + MarginAccount getAccount(); + + /** + * Get all open orders on margin account for a symbol. + * + * @param orderRequest order request parameters + */ + List getOpenOrders(OrderRequest orderRequest); + + /** + * Send in a new margin order. + * + * @param order the new order to submit. + * @return a response containing details about the newly placed order. + */ + MarginNewOrderResponse newOrder(MarginNewOrder order); + + /** + * Cancel an active margin order. + * + * @param cancelOrderRequest order status request parameters + */ + CancelOrderResponse cancelOrder(CancelOrderRequest cancelOrderRequest); + + /** + * Check margin order's status. + * + * @param orderStatusRequest order status request options/filters + * @return an order + */ + Order getOrderStatus(OrderStatusRequest orderStatusRequest); + + /** + * Get margin trades for a specific symbol. + * + * @param symbol symbol to get trades from + * @return a list of trades + */ + List getMyTrades(String symbol); + + // User stream endpoints + + /** + * Start a new user data stream. + * + * @return a listen key that can be used with data streams + */ + String startUserDataStream(); + + /** + * PING a user data stream to prevent a time out. + * + * @param listenKey listen key that identifies a data stream + */ + void keepAliveUserDataStream(String listenKey); + + /** + * Execute transfer between spot account and margin account + * + * @param asset asset to repay + * @param amount amount to repay + * @return transaction id + */ + MarginTransaction transfer(String asset, String amount, TransferType type); + + /** + * Apply for a loan + * + * @param asset asset to repay + * @param amount amount to repay + * @return transaction id + */ + MarginTransaction borrow(String asset, String amount); + + /** + * Query loan record + * + * @param asset asset to query + * @return repay records + */ + RepayQueryResult queryRepay(String asset, long startTime); + + /** + * Query max borrowable + * + * @param asset asset to query + * @return max borrowable + */ + MaxBorrowableQueryResult queryMaxBorrowable(String asset); + + /** + * Query loan record + * + * @param asset asset to query + * @param txId the tranId in POST /sapi/v1/margin/repay + * @return loan records + */ + RepayQueryResult queryRepay(String asset, String txId); + + /** + * Repay loan for margin account + * + * @param asset asset to repay + * @param amount amount to repay + * @return transaction id + */ + MarginTransaction repay(String asset, String amount); + + /** + * Query loan record + * + * @param asset asset to query + * @param txId the tranId in POST /sapi/v1/margin/loan + * @return loan records + */ + LoanQueryResult queryLoan(String asset, String txId); } diff --git a/src/main/java/com/binance/api/client/BinanceApiRestClient.java b/src/main/java/com/binance/api/client/BinanceApiRestClient.java index ebe0b9667..1aaea131b 100755 --- a/src/main/java/com/binance/api/client/BinanceApiRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiRestClient.java @@ -49,7 +49,7 @@ public interface BinanceApiRestClient { * Get order book of a symbol. * * @param symbol ticker symbol (e.g. ETHBTC) - * @param limit depth of the order book (max 100) + * @param limit depth of the order book (max 100) */ OrderBook getOrderBook(String symbol, Integer limit); @@ -57,7 +57,7 @@ public interface BinanceApiRestClient { * Get recent trades (up to last 500). Weight: 1 * * @param symbol ticker symbol (e.g. ETHBTC) - * @param limit of last trades (Default 500; max 1000.) + * @param limit of last trades (Default 500; max 1000.) */ List getTrades(String symbol, Integer limit); @@ -65,7 +65,7 @@ public interface BinanceApiRestClient { * Get older trades. Weight: 5 * * @param symbol ticker symbol (e.g. ETHBTC) - * @param limit of last trades (Default 500; max 1000.) + * @param limit of last trades (Default 500; max 1000.) * @param fromId TradeId to fetch from. Default gets most recent trades. */ List getHistoricalTrades(String symbol, Integer limit, Long fromId); @@ -73,15 +73,15 @@ public interface BinanceApiRestClient { /** * Get compressed, aggregate trades. Trades that fill at the time, from the same order, with * the same price will have the quantity aggregated. - * + *

* If both startTime and endTime are sent, limitshould not * be sent AND the distance between startTime and endTime must be less than 24 hours. * - * @param symbol symbol to aggregate (mandatory) - * @param fromId ID to get aggregate trades from INCLUSIVE (optional) - * @param limit Default 500; max 1000 (optional) + * @param symbol symbol to aggregate (mandatory) + * @param fromId ID to get aggregate trades from INCLUSIVE (optional) + * @param limit Default 500; max 1000 (optional) * @param startTime Timestamp in ms to get aggregate trades from INCLUSIVE (optional). - * @param endTime Timestamp in ms to get aggregate trades until INCLUSIVE (optional). + * @param endTime Timestamp in ms to get aggregate trades until INCLUSIVE (optional). * @return a list of aggregate trades for the given symbol */ List getAggTrades(String symbol, String fromId, Integer limit, Long startTime, Long endTime); @@ -96,11 +96,11 @@ public interface BinanceApiRestClient { /** * Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time. * - * @param symbol symbol to aggregate (mandatory) - * @param interval candlestick interval (mandatory) - * @param limit Default 500; max 1000 (optional) + * @param symbol symbol to aggregate (mandatory) + * @param interval candlestick interval (mandatory) + * @param limit Default 500; max 1000 (optional) * @param startTime Timestamp in ms to get candlestick bars from INCLUSIVE (optional). - * @param endTime Timestamp in ms to get candlestick bars until INCLUSIVE (optional). + * @param endTime Timestamp in ms to get candlestick bars until INCLUSIVE (optional). * @return a candlestick bar for the given symbol and interval */ List getCandlestickBars(String symbol, CandlestickInterval interval, Integer limit, Long startTime, Long endTime); @@ -160,8 +160,8 @@ public interface BinanceApiRestClient { /** * Check an order's status. - * @param orderStatusRequest order status request options/filters * + * @param orderStatusRequest order status request options/filters * @return an order */ Order getOrderStatus(OrderStatusRequest orderStatusRequest); @@ -192,8 +192,7 @@ public interface BinanceApiRestClient { /** * Send in a new OCO; * - * @param oco - * the OCO to submit + * @param oco the OCO to submit * @return a response containing details about the newly placed OCO. */ NewOCOResponse newOCO(NewOCO oco); @@ -235,7 +234,7 @@ public interface BinanceApiRestClient { * Get trades for a specific account and symbol. * * @param symbol symbol to get trades from - * @param limit default 500; max 1000 + * @param limit default 500; max 1000 * @param fromId TradeId to fetch from. Default gets most recent trades. * @return a list of trades */ @@ -245,7 +244,7 @@ public interface BinanceApiRestClient { * Get trades for a specific account and symbol. * * @param symbol symbol to get trades from - * @param limit default 500; max 1000 + * @param limit default 500; max 1000 * @return a list of trades */ List getMyTrades(String symbol, Integer limit); @@ -257,24 +256,25 @@ public interface BinanceApiRestClient { * @return a list of trades */ List getMyTrades(String symbol); - + List getMyTrades(String symbol, Long fromId); /** * Submit a withdraw request. - * + *

* Enable Withdrawals option has to be active in the API settings. * - * @param asset asset symbol to withdraw - * @param address address to withdraw to - * @param amount amount to withdraw - * @param name description/alias of the address + * @param asset asset symbol to withdraw + * @param address address to withdraw to + * @param amount amount to withdraw + * @param name description/alias of the address * @param addressTag Secondary address identifier for coins like XRP,XMR etc. */ WithdrawResult withdraw(String asset, String address, String amount, String name, String addressTag); /** * Conver a list of assets to BNB + * * @param asset the list of assets to convert */ DustTransferResponse dustTranfer(List asset); diff --git a/src/main/java/com/binance/api/client/BinanceApiSwapRestClient.java b/src/main/java/com/binance/api/client/BinanceApiSwapRestClient.java index f7baf2c2e..790efda5e 100755 --- a/src/main/java/com/binance/api/client/BinanceApiSwapRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiSwapRestClient.java @@ -9,86 +9,86 @@ public interface BinanceApiSwapRestClient { - /** - * Get metadata about all swap pools. - * - * @return - */ - List listAllSwapPools(); + /** + * Get metadata about all swap pools. + * + * @return + */ + List listAllSwapPools(); - /** - * Get liquidity information and user share of a pool. - * - * @param poolId - * @return - */ - Liquidity getPoolLiquidityInfo(String poolId); + /** + * Get liquidity information and user share of a pool. + * + * @param poolId + * @return + */ + Liquidity getPoolLiquidityInfo(String poolId); - /** - * Add liquidity to a pool. - * - * @param poolId - * @param asset - * @param quantity - * @return - */ - LiquidityOperationRecord addLiquidity(String poolId, - String asset, - String quantity); + /** + * Add liquidity to a pool. + * + * @param poolId + * @param asset + * @param quantity + * @return + */ + LiquidityOperationRecord addLiquidity(String poolId, + String asset, + String quantity); - /** - * Remove liquidity from a pool, type include SINGLE and COMBINATION, asset is mandatory for single asset removal - * - * @param poolId - * @param type - * @param asset - * @param shareAmount - * @return - */ - LiquidityOperationRecord removeLiquidity(String poolId, SwapRemoveType type, List asset, String shareAmount); + /** + * Remove liquidity from a pool, type include SINGLE and COMBINATION, asset is mandatory for single asset removal + * + * @param poolId + * @param type + * @param asset + * @param shareAmount + * @return + */ + LiquidityOperationRecord removeLiquidity(String poolId, SwapRemoveType type, List asset, String shareAmount); - /** - * Get liquidity operation (add/remove) records of a pool - * - * @param poolId - * @param limit - * @return - */ - List getPoolLiquidityOperationRecords( - String poolId, - Integer limit); + /** + * Get liquidity operation (add/remove) records of a pool + * + * @param poolId + * @param limit + * @return + */ + List getPoolLiquidityOperationRecords( + String poolId, + Integer limit); - /** - * Get liquidity operation (add/remove) record. - * - * @param operationId - * @return - */ - LiquidityOperationRecord getLiquidityOperationRecord(String operationId); + /** + * Get liquidity operation (add/remove) record. + * + * @param operationId + * @return + */ + LiquidityOperationRecord getLiquidityOperationRecord(String operationId); - /** - * Request a quote for swap quote asset (selling asset) for base asset (buying asset), essentially price/exchange rates. - * - * @param quoteAsset - * @param baseAsset - * @param quoteQty - * @return - */ - SwapQuote requestQuote(String quoteAsset, - String baseAsset, - String quoteQty); + /** + * Request a quote for swap quote asset (selling asset) for base asset (buying asset), essentially price/exchange rates. + * + * @param quoteAsset + * @param baseAsset + * @param quoteQty + * @return + */ + SwapQuote requestQuote(String quoteAsset, + String baseAsset, + String quoteQty); - /** - * Swap quoteAsset for baseAsset - * - * @param quoteAsset - * @param baseAsset - * @param quoteQty - * @return - */ - SwapRecord swap(String quoteAsset, - String baseAsset, - String quoteQty); + /** + * Swap quoteAsset for baseAsset + * + * @param quoteAsset + * @param baseAsset + * @param quoteQty + * @return + */ + SwapRecord swap(String quoteAsset, + String baseAsset, + String quoteQty); - SwapHistory getSwapHistory(String swapId); + SwapHistory getSwapHistory(String swapId); } diff --git a/src/main/java/com/binance/api/client/BinanceApiWebSocketClient.java b/src/main/java/com/binance/api/client/BinanceApiWebSocketClient.java index bc048d464..d8b2bdbd0 100755 --- a/src/main/java/com/binance/api/client/BinanceApiWebSocketClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiWebSocketClient.java @@ -11,80 +11,80 @@ */ public interface BinanceApiWebSocketClient extends Closeable { - /** - * Open a new web socket to receive {@link DepthEvent depthEvents} on a callback. - * - * @param symbols market (one or coma-separated) symbol(s) to subscribe to - * @param callback the callback to call on new events - * @return a {@link Closeable} that allows the underlying web socket to be closed. - */ - Closeable onDepthEvent(String symbols, BinanceApiCallback callback); + /** + * Open a new web socket to receive {@link DepthEvent depthEvents} on a callback. + * + * @param symbols market (one or coma-separated) symbol(s) to subscribe to + * @param callback the callback to call on new events + * @return a {@link Closeable} that allows the underlying web socket to be closed. + */ + Closeable onDepthEvent(String symbols, BinanceApiCallback callback); - /** - * Open a new web socket to receive {@link CandlestickEvent candlestickEvents} on a callback. - * - * @param symbols market (one or coma-separated) symbol(s) to subscribe to - * @param interval the interval of the candles tick events required - * @param callback the callback to call on new events - * @return a {@link Closeable} that allows the underlying web socket to be closed. - */ - Closeable onCandlestickEvent(String symbols, CandlestickInterval interval, BinanceApiCallback callback); + /** + * Open a new web socket to receive {@link CandlestickEvent candlestickEvents} on a callback. + * + * @param symbols market (one or coma-separated) symbol(s) to subscribe to + * @param interval the interval of the candles tick events required + * @param callback the callback to call on new events + * @return a {@link Closeable} that allows the underlying web socket to be closed. + */ + Closeable onCandlestickEvent(String symbols, CandlestickInterval interval, BinanceApiCallback callback); - /** - * Open a new web socket to receive {@link AggTradeEvent aggTradeEvents} on a callback. - * - * @param symbols market (one or coma-separated) symbol(s) to subscribe to - * @param callback the callback to call on new events - * @return a {@link Closeable} that allows the underlying web socket to be closed. - */ - Closeable onAggTradeEvent(String symbols, BinanceApiCallback callback); + /** + * Open a new web socket to receive {@link AggTradeEvent aggTradeEvents} on a callback. + * + * @param symbols market (one or coma-separated) symbol(s) to subscribe to + * @param callback the callback to call on new events + * @return a {@link Closeable} that allows the underlying web socket to be closed. + */ + Closeable onAggTradeEvent(String symbols, BinanceApiCallback callback); - /** - * Open a new web socket to receive {@link UserDataUpdateEvent userDataUpdateEvents} on a callback. - * - * @param listenKey the listen key to subscribe to. - * @param callback the callback to call on new events - * @return a {@link Closeable} that allows the underlying web socket to be closed. - */ - Closeable onUserDataUpdateEvent(String listenKey, BinanceApiCallback callback); + /** + * Open a new web socket to receive {@link UserDataUpdateEvent userDataUpdateEvents} on a callback. + * + * @param listenKey the listen key to subscribe to. + * @param callback the callback to call on new events + * @return a {@link Closeable} that allows the underlying web socket to be closed. + */ + Closeable onUserDataUpdateEvent(String listenKey, BinanceApiCallback callback); - /** - * Open a new web socket to receive {@link TickerEvent tickerEvents} on a callback. - * - * @param symbols market (one or coma-separated) symbol(s) to subscribe to - * @param callback the callback to call on new events - * @return a {@link Closeable} that allows the underlying web socket to be closed. - */ - Closeable onTickerEvent(String symbols, BinanceApiCallback callback); + /** + * Open a new web socket to receive {@link TickerEvent tickerEvents} on a callback. + * + * @param symbols market (one or coma-separated) symbol(s) to subscribe to + * @param callback the callback to call on new events + * @return a {@link Closeable} that allows the underlying web socket to be closed. + */ + Closeable onTickerEvent(String symbols, BinanceApiCallback callback); - /** - * Open a new web socket to receive {@link List allMarketTickersEvents} on a callback. - * - * @param callback the callback to call on new events - * @return a {@link Closeable} that allows the underlying web socket to be closed. - */ - Closeable onAllMarketTickersEvent(BinanceApiCallback> callback); + /** + * Open a new web socket to receive {@link List allMarketTickersEvents} on a callback. + * + * @param callback the callback to call on new events + * @return a {@link Closeable} that allows the underlying web socket to be closed. + */ + Closeable onAllMarketTickersEvent(BinanceApiCallback> callback); - /** - * Open a new web socket to receive {@link BookTickerEvent bookTickerEvents} on a callback. - * - * @param symbols market (one or coma-separated) symbol(s) to subscribe to - * @param callback the callback to call on new events - * @return a {@link Closeable} that allows the underlying web socket to be closed. - */ - Closeable onBookTickerEvent(String symbols, BinanceApiCallback callback); + /** + * Open a new web socket to receive {@link BookTickerEvent bookTickerEvents} on a callback. + * + * @param symbols market (one or coma-separated) symbol(s) to subscribe to + * @param callback the callback to call on new events + * @return a {@link Closeable} that allows the underlying web socket to be closed. + */ + Closeable onBookTickerEvent(String symbols, BinanceApiCallback callback); - /** - * Open a new web socket to receive {@link TickerEvent allBookTickersEvents} on a callback. - * - * @param callback the callback to call on new events - * @return a {@link Closeable} that allows the underlying web socket to be closed. - */ - Closeable onAllBookTickersEvent(BinanceApiCallback callback); + /** + * Open a new web socket to receive {@link TickerEvent allBookTickersEvents} on a callback. + * + * @param callback the callback to call on new events + * @return a {@link Closeable} that allows the underlying web socket to be closed. + */ + Closeable onAllBookTickersEvent(BinanceApiCallback callback); - /** - * @deprecated This method is no longer functional. Please use the returned {@link Closeable} from any of the other methods to close the web socket. - */ - @Deprecated - void close(); + /** + * @deprecated This method is no longer functional. Please use the returned {@link Closeable} from any of the other methods to close the web socket. + */ + @Deprecated + void close(); } diff --git a/src/main/java/com/binance/api/client/config/BinanceApiConfig.java b/src/main/java/com/binance/api/client/config/BinanceApiConfig.java index f4875297b..63010b943 100755 --- a/src/main/java/com/binance/api/client/config/BinanceApiConfig.java +++ b/src/main/java/com/binance/api/client/config/BinanceApiConfig.java @@ -5,78 +5,78 @@ */ public class BinanceApiConfig { - /** - * Base domain for URLs. - */ - private static String BASE_DOMAIN = "binance.com"; + /** + * Base domain for URLs. + */ + private static String BASE_DOMAIN = "binance.com"; - /** - * Spot Test Network URL. - */ - private static final String TESTNET_DOMAIN = "testnet.binance.vision"; + /** + * Spot Test Network URL. + */ + private static final String TESTNET_DOMAIN = "testnet.binance.vision"; - /** - * Binance Spot Test Network option: - * true if endpoint is spot test network URL; false if endpoint is production spot API URL. - */ - public static boolean useTestnet; + /** + * Binance Spot Test Network option: + * true if endpoint is spot test network URL; false if endpoint is production spot API URL. + */ + public static boolean useTestnet; - /** - * Binance Spot Test Network option: - * true for websocket streaming; false for no streaming. - */ - public static boolean useTestnetStreaming; + /** + * Binance Spot Test Network option: + * true for websocket streaming; false for no streaming. + */ + public static boolean useTestnetStreaming; - /** - * Set the URL base domain name (e.g., binance.com). - * - * @param baseDomain Base domain name - */ - public static void setBaseDomain(final String baseDomain) { - BASE_DOMAIN = baseDomain; - } + /** + * Set the URL base domain name (e.g., binance.com). + * + * @param baseDomain Base domain name + */ + public static void setBaseDomain(final String baseDomain) { + BASE_DOMAIN = baseDomain; + } - /** - * Get the URL base domain name (e.g., binance.com). - * - * @return The base domain for URLs - */ - public static String getBaseDomain() { - return BASE_DOMAIN; - } + /** + * Get the URL base domain name (e.g., binance.com). + * + * @return The base domain for URLs + */ + public static String getBaseDomain() { + return BASE_DOMAIN; + } - /** - * REST API base URL. - */ - public static String getApiBaseUrl() { - return String.format("https://api.%s", getBaseDomain()); - } + /** + * REST API base URL. + */ + public static String getApiBaseUrl() { + return String.format("https://api.%s", getBaseDomain()); + } - /** - * Streaming API base URL. - */ - public static String getStreamApiBaseUrl() { - return String.format("wss://stream.%s:9443/ws", getBaseDomain()); - } + /** + * Streaming API base URL. + */ + public static String getStreamApiBaseUrl() { + return String.format("wss://stream.%s:9443/ws", getBaseDomain()); + } - /** - * Asset info base URL. - */ - public static String getAssetInfoApiBaseUrl() { - return String.format("https://%s/", getBaseDomain()); - } + /** + * Asset info base URL. + */ + public static String getAssetInfoApiBaseUrl() { + return String.format("https://%s/", getBaseDomain()); + } - /** - * Spot Test Network API base URL. - */ - public static String getTestNetBaseUrl() { - return String.format("https://%s", TESTNET_DOMAIN); - } + /** + * Spot Test Network API base URL. + */ + public static String getTestNetBaseUrl() { + return String.format("https://%s", TESTNET_DOMAIN); + } - /** - * Streaming Spot Test Network base URL. - */ - public static String getStreamTestNetBaseUrl() { - return String.format("wss://%s/ws", TESTNET_DOMAIN); - } + /** + * Streaming Spot Test Network base URL. + */ + public static String getStreamTestNetBaseUrl() { + return String.format("wss://%s/ws", TESTNET_DOMAIN); + } } diff --git a/src/main/java/com/binance/api/client/constant/BinanceApiConstants.java b/src/main/java/com/binance/api/client/constant/BinanceApiConstants.java index 8e84256d7..fa0ffe5b0 100755 --- a/src/main/java/com/binance/api/client/constant/BinanceApiConstants.java +++ b/src/main/java/com/binance/api/client/constant/BinanceApiConstants.java @@ -37,7 +37,7 @@ public class BinanceApiConstants { /** * Default ToStringStyle used by toString methods. * Override this to change the output format of the overridden toString methods. - * - Example ToStringStyle.JSON_STYLE + * - Example ToStringStyle.JSON_STYLE */ public static ToStringStyle TO_STRING_BUILDER_STYLE = ToStringStyle.SHORT_PREFIX_STYLE; } diff --git a/src/main/java/com/binance/api/client/constant/Util.java b/src/main/java/com/binance/api/client/constant/Util.java index dae7916f1..0e6e786a2 100755 --- a/src/main/java/com/binance/api/client/constant/Util.java +++ b/src/main/java/com/binance/api/client/constant/Util.java @@ -10,24 +10,24 @@ */ public final class Util { - /** - * List of fiat currencies. - */ - public static final List FIAT_CURRENCY = Collections.unmodifiableList(Arrays.asList("USDT", "BUSD", "PAX", "TUSD", "USDC", "NGN", "RUB", "USDS", "TRY")); + /** + * List of fiat currencies. + */ + public static final List FIAT_CURRENCY = Collections.unmodifiableList(Arrays.asList("USDT", "BUSD", "PAX", "TUSD", "USDC", "NGN", "RUB", "USDS", "TRY")); - public static final String BTC_TICKER = "BTC"; + public static final String BTC_TICKER = "BTC"; - private Util() { + private Util() { - } + } - /** - * Check if the ticker is fiat currency. - */ - public static boolean isFiatCurrency(String symbol) { - for (String fiat : FIAT_CURRENCY) { - if (symbol.equals(fiat)) return true; - } - return false; + /** + * Check if the ticker is fiat currency. + */ + public static boolean isFiatCurrency(String symbol) { + for (String fiat : FIAT_CURRENCY) { + if (symbol.equals(fiat)) return true; } + return false; + } } diff --git a/src/main/java/com/binance/api/client/domain/ContingencyType.java b/src/main/java/com/binance/api/client/domain/ContingencyType.java index f6393a6b4..5b430faab 100755 --- a/src/main/java/com/binance/api/client/domain/ContingencyType.java +++ b/src/main/java/com/binance/api/client/domain/ContingencyType.java @@ -4,5 +4,5 @@ @JsonIgnoreProperties(ignoreUnknown = true) public enum ContingencyType { - OCO + OCO } diff --git a/src/main/java/com/binance/api/client/domain/LiquidityOperationRecordStatus.java b/src/main/java/com/binance/api/client/domain/LiquidityOperationRecordStatus.java index 2574a38e3..8a776e83f 100755 --- a/src/main/java/com/binance/api/client/domain/LiquidityOperationRecordStatus.java +++ b/src/main/java/com/binance/api/client/domain/LiquidityOperationRecordStatus.java @@ -5,12 +5,12 @@ @JsonIgnoreProperties(ignoreUnknown = true) public enum LiquidityOperationRecordStatus { - PENDING, - SUCCESS, - FAILED; + PENDING, + SUCCESS, + FAILED; - @JsonValue - public int toValue() { - return ordinal(); - } + @JsonValue + public int toValue() { + return ordinal(); + } } diff --git a/src/main/java/com/binance/api/client/domain/OCOOrderStatus.java b/src/main/java/com/binance/api/client/domain/OCOOrderStatus.java index 61888fa52..b983f480d 100755 --- a/src/main/java/com/binance/api/client/domain/OCOOrderStatus.java +++ b/src/main/java/com/binance/api/client/domain/OCOOrderStatus.java @@ -4,7 +4,7 @@ @JsonIgnoreProperties(ignoreUnknown = true) public enum OCOOrderStatus { - EXECUTING, - ALL_DONE, - REJECT + EXECUTING, + ALL_DONE, + REJECT } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/domain/OCOStatus.java b/src/main/java/com/binance/api/client/domain/OCOStatus.java index 59c0bd0c9..89eca612c 100755 --- a/src/main/java/com/binance/api/client/domain/OCOStatus.java +++ b/src/main/java/com/binance/api/client/domain/OCOStatus.java @@ -4,7 +4,7 @@ @JsonIgnoreProperties(ignoreUnknown = true) public enum OCOStatus { - RESPONSE, - EXEC_STARTED, - ALL_DONE + RESPONSE, + EXEC_STARTED, + ALL_DONE } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/domain/SwapRemoveType.java b/src/main/java/com/binance/api/client/domain/SwapRemoveType.java index 64db76453..cd96e6231 100755 --- a/src/main/java/com/binance/api/client/domain/SwapRemoveType.java +++ b/src/main/java/com/binance/api/client/domain/SwapRemoveType.java @@ -4,5 +4,5 @@ @JsonIgnoreProperties(ignoreUnknown = true) public enum SwapRemoveType { - SINGLE, COMBINATION + SINGLE, COMBINATION } diff --git a/src/main/java/com/binance/api/client/domain/TimeInForce.java b/src/main/java/com/binance/api/client/domain/TimeInForce.java index 83043ce7f..3bc63590f 100755 --- a/src/main/java/com/binance/api/client/domain/TimeInForce.java +++ b/src/main/java/com/binance/api/client/domain/TimeInForce.java @@ -4,7 +4,7 @@ /** * Time in force to indicate how long an order will remain active before it is executed or expires. - * + *

* GTC (Good-Til-Canceled) orders are effective until they are executed or canceled. * IOC (Immediate or Cancel) orders fills all or part of an order immediately and cancels the remaining part of the order. * FOK (Fill or Kill) orders fills all in its entirety, otherwise, the entire order will be cancelled. diff --git a/src/main/java/com/binance/api/client/domain/account/CrossMarginAssets.java b/src/main/java/com/binance/api/client/domain/account/CrossMarginAssets.java index 33c5fd906..ef7ab9e79 100755 --- a/src/main/java/com/binance/api/client/domain/account/CrossMarginAssets.java +++ b/src/main/java/com/binance/api/client/domain/account/CrossMarginAssets.java @@ -5,70 +5,70 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class CrossMarginAssets { - public String assetFullName; - public String assetName; - public boolean isBorrowable; - public boolean isMortgageable; - public String userMinBorrow; - public String userMinRepay; - - public String getAssetFullName() { - return assetFullName; - } - - public void setAssetFullName(String assetFullName) { - this.assetFullName = assetFullName; - } - - public String getAssetName() { - return assetName; - } - - public void setAssetName(String assetName) { - this.assetName = assetName; - } - - public boolean isBorrowable() { - return isBorrowable; - } - - public void setBorrowable(boolean borrowable) { - isBorrowable = borrowable; - } - - public boolean isMortgageable() { - return isMortgageable; - } - - public void setMortgageable(boolean mortgageable) { - isMortgageable = mortgageable; - } - - public String getUserMinBorrow() { - return userMinBorrow; - } - - public void setUserMinBorrow(String userMinBorrow) { - this.userMinBorrow = userMinBorrow; - } - - public String getUserMinRepay() { - return userMinRepay; - } - - public void setUserMinRepay(String userMinRepay) { - this.userMinRepay = userMinRepay; - } - - @Override - public String toString() { - return "CrossMarginAssets{" + - "assetFullName='" + assetFullName + '\'' + - ", assetName='" + assetName + '\'' + - ", isBorrowable=" + isBorrowable + - ", isMortgageable=" + isMortgageable + - ", userMinBorrow='" + userMinBorrow + '\'' + - ", userMinRepay='" + userMinRepay + '\'' + - '}'; - } + public String assetFullName; + public String assetName; + public boolean isBorrowable; + public boolean isMortgageable; + public String userMinBorrow; + public String userMinRepay; + + public String getAssetFullName() { + return assetFullName; + } + + public void setAssetFullName(String assetFullName) { + this.assetFullName = assetFullName; + } + + public String getAssetName() { + return assetName; + } + + public void setAssetName(String assetName) { + this.assetName = assetName; + } + + public boolean isBorrowable() { + return isBorrowable; + } + + public void setBorrowable(boolean borrowable) { + isBorrowable = borrowable; + } + + public boolean isMortgageable() { + return isMortgageable; + } + + public void setMortgageable(boolean mortgageable) { + isMortgageable = mortgageable; + } + + public String getUserMinBorrow() { + return userMinBorrow; + } + + public void setUserMinBorrow(String userMinBorrow) { + this.userMinBorrow = userMinBorrow; + } + + public String getUserMinRepay() { + return userMinRepay; + } + + public void setUserMinRepay(String userMinRepay) { + this.userMinRepay = userMinRepay; + } + + @Override + public String toString() { + return "CrossMarginAssets{" + + "assetFullName='" + assetFullName + '\'' + + ", assetName='" + assetName + '\'' + + ", isBorrowable=" + isBorrowable + + ", isMortgageable=" + isMortgageable + + ", userMinBorrow='" + userMinBorrow + '\'' + + ", userMinRepay='" + userMinRepay + '\'' + + '}'; + } } diff --git a/src/main/java/com/binance/api/client/domain/account/DustTransferResponse.java b/src/main/java/com/binance/api/client/domain/account/DustTransferResponse.java index a585d2f01..56c3e8356 100755 --- a/src/main/java/com/binance/api/client/domain/account/DustTransferResponse.java +++ b/src/main/java/com/binance/api/client/domain/account/DustTransferResponse.java @@ -10,43 +10,43 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class DustTransferResponse { - private String totalServiceCharge; + private String totalServiceCharge; - private String totalTransfered; + private String totalTransfered; - private List transferResult; + private List transferResult; - public String getTotalServiceCharge() { - return totalServiceCharge; - } + public String getTotalServiceCharge() { + return totalServiceCharge; + } - public void setTotalServiceCharge(String totalServiceCharge) { - this.totalServiceCharge = totalServiceCharge; - } + public void setTotalServiceCharge(String totalServiceCharge) { + this.totalServiceCharge = totalServiceCharge; + } - public String getTotalTransfered() { - return totalTransfered; - } + public String getTotalTransfered() { + return totalTransfered; + } - public void setTotalTransfered(String totalTransfered) { - this.totalTransfered = totalTransfered; - } + public void setTotalTransfered(String totalTransfered) { + this.totalTransfered = totalTransfered; + } - public List getTransferResult() { - return transferResult; - } + public List getTransferResult() { + return transferResult; + } - public void setTransferResult(List transferResult) { - this.transferResult = transferResult; - } + public void setTransferResult(List transferResult) { + this.transferResult = transferResult; + } - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("totalServiceCharge", totalServiceCharge) - .append("totalTransfered", totalTransfered) - .append("transferResult", transferResult) - .toString(); - } + @Override + public String toString() { + return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) + .append("totalServiceCharge", totalServiceCharge) + .append("totalTransfered", totalTransfered) + .append("transferResult", transferResult) + .toString(); + } } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/domain/account/Liquidity.java b/src/main/java/com/binance/api/client/domain/account/Liquidity.java index 83eee88a3..74c085b11 100755 --- a/src/main/java/com/binance/api/client/domain/account/Liquidity.java +++ b/src/main/java/com/binance/api/client/domain/account/Liquidity.java @@ -4,99 +4,99 @@ public class Liquidity { - private String poolId; - private String poolName; - private Long updateTime; - private Map liquidity; - private Share share; - - public String getPoolId() { - return poolId; + private String poolId; + private String poolName; + private Long updateTime; + private Map liquidity; + private Share share; + + public String getPoolId() { + return poolId; + } + + public void setPoolId(String poolId) { + this.poolId = poolId; + } + + public String getPoolName() { + return poolName; + } + + public void setPoolName(String poolName) { + this.poolName = poolName; + } + + public Long getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Long updateTime) { + this.updateTime = updateTime; + } + + public Map getLiquidity() { + return liquidity; + } + + public void setLiquidity(Map liquidity) { + this.liquidity = liquidity; + } + + public Share getShare() { + return share; + } + + public void setShare(Share share) { + this.share = share; + } + + public static class Share { + private double shareAmount; + private double sharePercentage; + private Map asset; + + public double getShareAmount() { + return shareAmount; } - public void setPoolId(String poolId) { - this.poolId = poolId; + public void setShareAmount(double shareAmount) { + this.shareAmount = shareAmount; } - public String getPoolName() { - return poolName; + public double getSharePercentage() { + return sharePercentage; } - public void setPoolName(String poolName) { - this.poolName = poolName; + public void setSharePercentage(double sharePercentage) { + this.sharePercentage = sharePercentage; } - public Long getUpdateTime() { - return updateTime; + public Map getAsset() { + return asset; } - public void setUpdateTime(Long updateTime) { - this.updateTime = updateTime; - } - - public Map getLiquidity() { - return liquidity; - } - - public void setLiquidity(Map liquidity) { - this.liquidity = liquidity; - } - - public Share getShare() { - return share; - } - - public void setShare(Share share) { - this.share = share; - } - - public static class Share { - private double shareAmount; - private double sharePercentage; - private Map asset; - - public double getShareAmount() { - return shareAmount; - } - - public void setShareAmount(double shareAmount) { - this.shareAmount = shareAmount; - } - - public double getSharePercentage() { - return sharePercentage; - } - - public void setSharePercentage(double sharePercentage) { - this.sharePercentage = sharePercentage; - } - - public Map getAsset() { - return asset; - } - - public void setAsset(Map asset) { - this.asset = asset; - } - - @Override - public String toString() { - return "Share{" + - "shareAmount=" + shareAmount + - ", sharePercentage=" + sharePercentage + - ", asset=" + asset + - '}'; - } + public void setAsset(Map asset) { + this.asset = asset; } @Override public String toString() { - return "Liquidity{" + - "poolId=" + poolId + - ", poolName='" + poolName + '\'' + - ", updateTime=" + updateTime + - ", liquidity=" + liquidity + - ", share=" + share + - '}'; + return "Share{" + + "shareAmount=" + shareAmount + + ", sharePercentage=" + sharePercentage + + ", asset=" + asset + + '}'; } + } + + @Override + public String toString() { + return "Liquidity{" + + "poolId=" + poolId + + ", poolName='" + poolName + '\'' + + ", updateTime=" + updateTime + + ", liquidity=" + liquidity + + ", share=" + share + + '}'; + } } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/domain/account/LiquidityOperationRecord.java b/src/main/java/com/binance/api/client/domain/account/LiquidityOperationRecord.java index 2ce393f1c..2043a4390 100755 --- a/src/main/java/com/binance/api/client/domain/account/LiquidityOperationRecord.java +++ b/src/main/java/com/binance/api/client/domain/account/LiquidityOperationRecord.java @@ -4,80 +4,80 @@ public class LiquidityOperationRecord { - private String poolId; - private String operationId; - private String updateTime; - private String operation; - private String shareAmount; - private String poolName; - private LiquidityOperationRecordStatus status; - - public String getPoolId() { - return poolId; - } - - public void setPoolId(String poolId) { - this.poolId = poolId; - } - - public String getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getOperation() { - return operation; - } - - public void setOperation(String operation) { - this.operation = operation; - } - - public String getShareAmount() { - return shareAmount; - } - - public void setShareAmount(String shareAmount) { - this.shareAmount = shareAmount; - } - - public String getPoolName() { - return poolName; - } - - public void setPoolName(String poolName) { - this.poolName = poolName; - } - - public LiquidityOperationRecordStatus getStatus() { - return status; - } - - public void setStatus(LiquidityOperationRecordStatus status) { - this.status = status; - } - - public String getOperationId() { - return operationId; - } - - public void setOperationId(String operationId) { - this.operationId = operationId; - } - - @Override - public String toString() { - return "LiquidityOperationRecord{" + - "poolId='" + poolId + '\'' + - ", operationId='" + operationId + '\'' + - ", updateTime='" + updateTime + '\'' + - ", operation='" + operation + '\'' + - ", shareAmount='" + shareAmount + '\'' + - ", poolName='" + poolName + '\'' + - ", status='" + status + '\'' + - '}'; - } + private String poolId; + private String operationId; + private String updateTime; + private String operation; + private String shareAmount; + private String poolName; + private LiquidityOperationRecordStatus status; + + public String getPoolId() { + return poolId; + } + + public void setPoolId(String poolId) { + this.poolId = poolId; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public String getOperation() { + return operation; + } + + public void setOperation(String operation) { + this.operation = operation; + } + + public String getShareAmount() { + return shareAmount; + } + + public void setShareAmount(String shareAmount) { + this.shareAmount = shareAmount; + } + + public String getPoolName() { + return poolName; + } + + public void setPoolName(String poolName) { + this.poolName = poolName; + } + + public LiquidityOperationRecordStatus getStatus() { + return status; + } + + public void setStatus(LiquidityOperationRecordStatus status) { + this.status = status; + } + + public String getOperationId() { + return operationId; + } + + public void setOperationId(String operationId) { + this.operationId = operationId; + } + + @Override + public String toString() { + return "LiquidityOperationRecord{" + + "poolId='" + poolId + '\'' + + ", operationId='" + operationId + '\'' + + ", updateTime='" + updateTime + '\'' + + ", operation='" + operation + '\'' + + ", shareAmount='" + shareAmount + '\'' + + ", poolName='" + poolName + '\'' + + ", status='" + status + '\'' + + '}'; + } } diff --git a/src/main/java/com/binance/api/client/domain/account/Loan.java b/src/main/java/com/binance/api/client/domain/account/Loan.java index 96389c269..ef14cec75 100755 --- a/src/main/java/com/binance/api/client/domain/account/Loan.java +++ b/src/main/java/com/binance/api/client/domain/account/Loan.java @@ -9,40 +9,40 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class Loan { - private String asset; - private String principal; - private long timestamp; - private LoanStatus status; - - public String getAsset() { - return asset; - } - - public void setAsset(String asset) { - this.asset = asset; - } - - public String getPrincipal() { - return principal; - } - - public void setPrincipal(String principal) { - this.principal = principal; - } - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public LoanStatus getStatus() { - return status; - } - - public void setStatus(LoanStatus status) { - this.status = status; - } + private String asset; + private String principal; + private long timestamp; + private LoanStatus status; + + public String getAsset() { + return asset; + } + + public void setAsset(String asset) { + this.asset = asset; + } + + public String getPrincipal() { + return principal; + } + + public void setPrincipal(String principal) { + this.principal = principal; + } + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public LoanStatus getStatus() { + return status; + } + + public void setStatus(LoanStatus status) { + this.status = status; + } } diff --git a/src/main/java/com/binance/api/client/domain/account/MarginAccount.java b/src/main/java/com/binance/api/client/domain/account/MarginAccount.java index 86bd64f27..8eb278ac6 100755 --- a/src/main/java/com/binance/api/client/domain/account/MarginAccount.java +++ b/src/main/java/com/binance/api/client/domain/account/MarginAccount.java @@ -100,9 +100,9 @@ public void setUserAssets(List userAssets) { */ public MarginAssetBalance getAssetBalance(final String symbol) { return userAssets.stream() - .filter(marginAssetBalance -> marginAssetBalance.getAsset().equals(symbol)) - .findFirst() - .orElse(MarginAssetBalance.of(symbol)); + .filter(marginAssetBalance -> marginAssetBalance.getAsset().equals(symbol)) + .findFirst() + .orElse(MarginAssetBalance.of(symbol)); } @Override diff --git a/src/main/java/com/binance/api/client/domain/account/MarginNewOrder.java b/src/main/java/com/binance/api/client/domain/account/MarginNewOrder.java index 74dd71d0b..1015354c1 100755 --- a/src/main/java/com/binance/api/client/domain/account/MarginNewOrder.java +++ b/src/main/java/com/binance/api/client/domain/account/MarginNewOrder.java @@ -13,277 +13,277 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class MarginNewOrder { - /** - * Symbol to place the order on. - */ - private String symbol; - - /** - * Buy/Sell order side. - */ - private OrderSide side; - - /** - * Type of order. - */ - private OrderType type; - - /** - * Time in force to indicate how long will the order remain active. - */ - private TimeInForce timeInForce; - - /** - * Quantity. - */ - private String quantity; - - /** - * Quote quantity. - */ - private String quoteOrderQty; - - /** - * Price. - */ - private String price; - - /** - * A unique id for the order. Automatically generated if not sent. - */ - private String newClientOrderId; - - /** - * Used with stop orders. - */ - private String stopPrice; - - /** - * Used with iceberg orders. - */ - private String icebergQty; - - /** - * Set the response JSON. ACK, RESULT, or FULL; default: RESULT. - */ - private NewOrderResponseType newOrderRespType; - - /** - * Set the margin order side-effect. NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY; default: NO_SIDE_EFFECT. - */ - private SideEffectType sideEffectType; - - /** - * Receiving window. - */ - private Long recvWindow; - - /** - * Order timestamp. - */ - private long timestamp; - - /** - * Creates a new order with all required parameters. - */ - public MarginNewOrder(String symbol, OrderSide side, OrderType type, TimeInForce timeInForce, String quantity) { - this.symbol = symbol; - this.side = side; - this.type = type; - this.timeInForce = timeInForce; - this.quantity = quantity; - this.newOrderRespType = NewOrderResponseType.RESULT; - this.timestamp = System.currentTimeMillis(); - this.recvWindow = BinanceApiConstants.DEFAULT_RECEIVING_WINDOW; - } - - /** - * Creates a new order with all required parameters plus price, which is optional for MARKET orders. - */ - public MarginNewOrder(String symbol, OrderSide side, OrderType type, TimeInForce timeInForce, String quantity, String price) { - this(symbol, side, type, timeInForce, quantity); - this.price = price; - } - - public String getSymbol() { - return symbol; - } - - public MarginNewOrder symbol(String symbol) { - this.symbol = symbol; - return this; - } - - public OrderSide getSide() { - return side; - } - - public MarginNewOrder side(OrderSide side) { - this.side = side; - return this; - } - - public OrderType getType() { - return type; - } - - public MarginNewOrder type(OrderType type) { - this.type = type; - return this; - } - - public TimeInForce getTimeInForce() { - return timeInForce; - } - - public MarginNewOrder timeInForce(TimeInForce timeInForce) { - this.timeInForce = timeInForce; - return this; - } - - public String getQuantity() { - return quantity; - } - - public MarginNewOrder quantity(String quantity) { - this.quantity = quantity; - return this; - } - - public String getQuoteOrderQty() { - return quoteOrderQty; - } - - public MarginNewOrder quoteOrderQty(String quoteOrderQty) { - this.quoteOrderQty = quoteOrderQty; - return this; - } - - public String getPrice() { - return price; - } - - public MarginNewOrder price(String price) { - this.price = price; - return this; - } - - public String getNewClientOrderId() { - return newClientOrderId; - } - - public MarginNewOrder newClientOrderId(String newClientOrderId) { - this.newClientOrderId = newClientOrderId; - return this; - } - - public String getStopPrice() { - return stopPrice; - } - - public MarginNewOrder stopPrice(String stopPrice) { - this.stopPrice = stopPrice; - return this; - } - - public String getIcebergQty() { - return icebergQty; - } - - public MarginNewOrder icebergQty(String icebergQty) { - this.icebergQty = icebergQty; - return this; - } - - public NewOrderResponseType getNewOrderRespType() { - return newOrderRespType; - } - - public MarginNewOrder newOrderRespType(NewOrderResponseType newOrderRespType) { - this.newOrderRespType = newOrderRespType; - return this; - } - - public SideEffectType getSideEffectType() { - return sideEffectType; - } - - public MarginNewOrder sideEffectType(SideEffectType sideEffectType) { - this.sideEffectType = sideEffectType; - return this; - } - - public Long getRecvWindow() { - return recvWindow; - } - - public MarginNewOrder recvWindow(Long recvWindow) { - this.recvWindow = recvWindow; - return this; - } - - public long getTimestamp() { - return timestamp; - } - - public MarginNewOrder timestamp(long timestamp) { - this.timestamp = timestamp; - return this; - } - - /** - * Places a MARKET buy order for the given quantity. - * - * @return a new order which is pre-configured with MARKET as the order type and BUY as the order side. - */ - public static MarginNewOrder marketBuy(String symbol, String quantity) { - return new MarginNewOrder(symbol, OrderSide.BUY, OrderType.MARKET, null, quantity); - } - - /** - * Places a MARKET sell order for the given quantity. - * - * @return a new order which is pre-configured with MARKET as the order type and SELL as the order side. - */ - public static MarginNewOrder marketSell(String symbol, String quantity) { - return new MarginNewOrder(symbol, OrderSide.SELL, OrderType.MARKET, null, quantity); - } - - /** - * Places a LIMIT buy order for the given quantity and price. - * - * @return a new order which is pre-configured with LIMIT as the order type and BUY as the order side. - */ - public static MarginNewOrder limitBuy(String symbol, TimeInForce timeInForce, String quantity, String price) { - return new MarginNewOrder(symbol, OrderSide.BUY, OrderType.LIMIT, timeInForce, quantity, price); - } - - /** - * Places a LIMIT sell order for the given quantity and price. - * - * @return a new order which is pre-configured with LIMIT as the order type and SELL as the order side. - */ - public static MarginNewOrder limitSell(String symbol, TimeInForce timeInForce, String quantity, String price) { - return new MarginNewOrder(symbol, OrderSide.SELL, OrderType.LIMIT, timeInForce, quantity, price); - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("symbol", symbol) - .append("side", side) - .append("type", type) - .append("timeInForce", timeInForce) - .append("quantity", quantity) - .append("quoteOrderQty", quoteOrderQty) - .append("price", price) - .append("newClientOrderId", newClientOrderId) - .append("stopPrice", stopPrice) - .append("icebergQty", icebergQty) - .append("newOrderRespType", newOrderRespType) - .append("sideEffectType", sideEffectType) - .append("recvWindow", recvWindow) - .append("timestamp", timestamp) - .toString(); - } + /** + * Symbol to place the order on. + */ + private String symbol; + + /** + * Buy/Sell order side. + */ + private OrderSide side; + + /** + * Type of order. + */ + private OrderType type; + + /** + * Time in force to indicate how long will the order remain active. + */ + private TimeInForce timeInForce; + + /** + * Quantity. + */ + private String quantity; + + /** + * Quote quantity. + */ + private String quoteOrderQty; + + /** + * Price. + */ + private String price; + + /** + * A unique id for the order. Automatically generated if not sent. + */ + private String newClientOrderId; + + /** + * Used with stop orders. + */ + private String stopPrice; + + /** + * Used with iceberg orders. + */ + private String icebergQty; + + /** + * Set the response JSON. ACK, RESULT, or FULL; default: RESULT. + */ + private NewOrderResponseType newOrderRespType; + + /** + * Set the margin order side-effect. NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY; default: NO_SIDE_EFFECT. + */ + private SideEffectType sideEffectType; + + /** + * Receiving window. + */ + private Long recvWindow; + + /** + * Order timestamp. + */ + private long timestamp; + + /** + * Creates a new order with all required parameters. + */ + public MarginNewOrder(String symbol, OrderSide side, OrderType type, TimeInForce timeInForce, String quantity) { + this.symbol = symbol; + this.side = side; + this.type = type; + this.timeInForce = timeInForce; + this.quantity = quantity; + this.newOrderRespType = NewOrderResponseType.RESULT; + this.timestamp = System.currentTimeMillis(); + this.recvWindow = BinanceApiConstants.DEFAULT_RECEIVING_WINDOW; + } + + /** + * Creates a new order with all required parameters plus price, which is optional for MARKET orders. + */ + public MarginNewOrder(String symbol, OrderSide side, OrderType type, TimeInForce timeInForce, String quantity, String price) { + this(symbol, side, type, timeInForce, quantity); + this.price = price; + } + + public String getSymbol() { + return symbol; + } + + public MarginNewOrder symbol(String symbol) { + this.symbol = symbol; + return this; + } + + public OrderSide getSide() { + return side; + } + + public MarginNewOrder side(OrderSide side) { + this.side = side; + return this; + } + + public OrderType getType() { + return type; + } + + public MarginNewOrder type(OrderType type) { + this.type = type; + return this; + } + + public TimeInForce getTimeInForce() { + return timeInForce; + } + + public MarginNewOrder timeInForce(TimeInForce timeInForce) { + this.timeInForce = timeInForce; + return this; + } + + public String getQuantity() { + return quantity; + } + + public MarginNewOrder quantity(String quantity) { + this.quantity = quantity; + return this; + } + + public String getQuoteOrderQty() { + return quoteOrderQty; + } + + public MarginNewOrder quoteOrderQty(String quoteOrderQty) { + this.quoteOrderQty = quoteOrderQty; + return this; + } + + public String getPrice() { + return price; + } + + public MarginNewOrder price(String price) { + this.price = price; + return this; + } + + public String getNewClientOrderId() { + return newClientOrderId; + } + + public MarginNewOrder newClientOrderId(String newClientOrderId) { + this.newClientOrderId = newClientOrderId; + return this; + } + + public String getStopPrice() { + return stopPrice; + } + + public MarginNewOrder stopPrice(String stopPrice) { + this.stopPrice = stopPrice; + return this; + } + + public String getIcebergQty() { + return icebergQty; + } + + public MarginNewOrder icebergQty(String icebergQty) { + this.icebergQty = icebergQty; + return this; + } + + public NewOrderResponseType getNewOrderRespType() { + return newOrderRespType; + } + + public MarginNewOrder newOrderRespType(NewOrderResponseType newOrderRespType) { + this.newOrderRespType = newOrderRespType; + return this; + } + + public SideEffectType getSideEffectType() { + return sideEffectType; + } + + public MarginNewOrder sideEffectType(SideEffectType sideEffectType) { + this.sideEffectType = sideEffectType; + return this; + } + + public Long getRecvWindow() { + return recvWindow; + } + + public MarginNewOrder recvWindow(Long recvWindow) { + this.recvWindow = recvWindow; + return this; + } + + public long getTimestamp() { + return timestamp; + } + + public MarginNewOrder timestamp(long timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Places a MARKET buy order for the given quantity. + * + * @return a new order which is pre-configured with MARKET as the order type and BUY as the order side. + */ + public static MarginNewOrder marketBuy(String symbol, String quantity) { + return new MarginNewOrder(symbol, OrderSide.BUY, OrderType.MARKET, null, quantity); + } + + /** + * Places a MARKET sell order for the given quantity. + * + * @return a new order which is pre-configured with MARKET as the order type and SELL as the order side. + */ + public static MarginNewOrder marketSell(String symbol, String quantity) { + return new MarginNewOrder(symbol, OrderSide.SELL, OrderType.MARKET, null, quantity); + } + + /** + * Places a LIMIT buy order for the given quantity and price. + * + * @return a new order which is pre-configured with LIMIT as the order type and BUY as the order side. + */ + public static MarginNewOrder limitBuy(String symbol, TimeInForce timeInForce, String quantity, String price) { + return new MarginNewOrder(symbol, OrderSide.BUY, OrderType.LIMIT, timeInForce, quantity, price); + } + + /** + * Places a LIMIT sell order for the given quantity and price. + * + * @return a new order which is pre-configured with LIMIT as the order type and SELL as the order side. + */ + public static MarginNewOrder limitSell(String symbol, TimeInForce timeInForce, String quantity, String price) { + return new MarginNewOrder(symbol, OrderSide.SELL, OrderType.LIMIT, timeInForce, quantity, price); + } + + @Override + public String toString() { + return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) + .append("symbol", symbol) + .append("side", side) + .append("type", type) + .append("timeInForce", timeInForce) + .append("quantity", quantity) + .append("quoteOrderQty", quoteOrderQty) + .append("price", price) + .append("newClientOrderId", newClientOrderId) + .append("stopPrice", stopPrice) + .append("icebergQty", icebergQty) + .append("newOrderRespType", newOrderRespType) + .append("sideEffectType", sideEffectType) + .append("recvWindow", recvWindow) + .append("timestamp", timestamp) + .toString(); + } } diff --git a/src/main/java/com/binance/api/client/domain/account/MarginNewOrderResponse.java b/src/main/java/com/binance/api/client/domain/account/MarginNewOrderResponse.java index 0d65d82ea..1bdb947f0 100755 --- a/src/main/java/com/binance/api/client/domain/account/MarginNewOrderResponse.java +++ b/src/main/java/com/binance/api/client/domain/account/MarginNewOrderResponse.java @@ -21,190 +21,190 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class MarginNewOrderResponse { - /** - * Order symbol. - */ - private String symbol; + /** + * Order symbol. + */ + private String symbol; - /** - * Order id. - */ - private Long orderId; + /** + * Order id. + */ + private Long orderId; - /** - * This will be either a generated one, or the newClientOrderId parameter - * which was passed when creating the new order. - */ - private String clientOrderId; + /** + * This will be either a generated one, or the newClientOrderId parameter + * which was passed when creating the new order. + */ + private String clientOrderId; - private String price; + private String price; - private String origQty; + private String origQty; - private String executedQty; + private String executedQty; - private String cummulativeQuoteQty; + private String cummulativeQuoteQty; - private OrderStatus status; + private OrderStatus status; - private TimeInForce timeInForce; + private TimeInForce timeInForce; - private OrderType type; + private OrderType type; - private String marginBuyBorrowAmount; + private String marginBuyBorrowAmount; - private String marginBuyBorrowAsset; + private String marginBuyBorrowAsset; - private OrderSide side; + private OrderSide side; - // @JsonSetter(nulls = Nulls.AS_EMPTY) - private List fills; + // @JsonSetter(nulls = Nulls.AS_EMPTY) + private List fills; - /** - * Transact time for this order. - */ - private Long transactTime; + /** + * Transact time for this order. + */ + private Long transactTime; - public String getSymbol() { - return symbol; - } + public String getSymbol() { + return symbol; + } - public void setSymbol(String symbol) { - this.symbol = symbol; - } + public void setSymbol(String symbol) { + this.symbol = symbol; + } - public Long getOrderId() { - return orderId; - } + public Long getOrderId() { + return orderId; + } - public void setOrderId(Long orderId) { - this.orderId = orderId; - } + public void setOrderId(Long orderId) { + this.orderId = orderId; + } - public String getClientOrderId() { - return clientOrderId; - } + public String getClientOrderId() { + return clientOrderId; + } - public void setClientOrderId(String clientOrderId) { - this.clientOrderId = clientOrderId; - } + public void setClientOrderId(String clientOrderId) { + this.clientOrderId = clientOrderId; + } - public Long getTransactTime() { - return transactTime; - } + public Long getTransactTime() { + return transactTime; + } - public void setTransactTime(Long transactTime) { - this.transactTime = transactTime; - } + public void setTransactTime(Long transactTime) { + this.transactTime = transactTime; + } - public String getPrice() { - return price; - } + public String getPrice() { + return price; + } - public void setPrice(String price) { - this.price = price; - } - - public String getOrigQty() { - return origQty; - } - - public void setOrigQty(String origQty) { - this.origQty = origQty; - } - - public String getExecutedQty() { - return executedQty; - } - - public void setExecutedQty(String executedQty) { - this.executedQty = executedQty; - } - - public String getCummulativeQuoteQty() { - return cummulativeQuoteQty; - } + public void setPrice(String price) { + this.price = price; + } + + public String getOrigQty() { + return origQty; + } + + public void setOrigQty(String origQty) { + this.origQty = origQty; + } + + public String getExecutedQty() { + return executedQty; + } + + public void setExecutedQty(String executedQty) { + this.executedQty = executedQty; + } + + public String getCummulativeQuoteQty() { + return cummulativeQuoteQty; + } - public void setCummulativeQuoteQty(String cummulativeQuoteQty) { - this.cummulativeQuoteQty = cummulativeQuoteQty; - } + public void setCummulativeQuoteQty(String cummulativeQuoteQty) { + this.cummulativeQuoteQty = cummulativeQuoteQty; + } - public OrderStatus getStatus() { - return status; - } + public OrderStatus getStatus() { + return status; + } - public void setStatus(OrderStatus status) { - this.status = status; - } + public void setStatus(OrderStatus status) { + this.status = status; + } - public TimeInForce getTimeInForce() { - return timeInForce; - } + public TimeInForce getTimeInForce() { + return timeInForce; + } - public void setTimeInForce(TimeInForce timeInForce) { - this.timeInForce = timeInForce; - } - - public OrderType getType() { - return type; - } - - public void setType(OrderType type) { - this.type = type; - } - - public String getMarginBuyBorrowAmount() { - return marginBuyBorrowAmount; - } - - public void setMarginBuyBorrowAmount(String marginBuyBorrowAmount) { - this.marginBuyBorrowAmount = marginBuyBorrowAmount; - } - - public String getMarginBuyBorrowAsset() { - return marginBuyBorrowAsset; - } - - public void setMarginBuyBorrowAsset(String marginBuyBorrowAsset) { - this.marginBuyBorrowAsset = marginBuyBorrowAsset; - } - - public OrderSide getSide() { - return side; - } - - public void setSide(OrderSide side) { - this.side = side; - } - - public List getFills() { - return fills; - } - - public void setFills(List fills) { - this.fills = fills; - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("symbol", symbol) - .append("orderId", orderId) - .append("clientOrderId", clientOrderId) - .append("transactTime", transactTime) - .append("price", price) - .append("origQty", origQty) - .append("executedQty", executedQty) - .append("status", status) - .append("timeInForce", timeInForce) - .append("type", type) - .append("marginBuyBorrowAmount", marginBuyBorrowAmount) - .append("marginBuyBorrowAsset", marginBuyBorrowAsset) - .append("side", side) - .append("fills", Optional.ofNullable(fills).orElse(Collections.emptyList()) - .stream() - .map(Object::toString) - .collect(Collectors.joining(", "))) - .toString(); - } + public void setTimeInForce(TimeInForce timeInForce) { + this.timeInForce = timeInForce; + } + + public OrderType getType() { + return type; + } + + public void setType(OrderType type) { + this.type = type; + } + + public String getMarginBuyBorrowAmount() { + return marginBuyBorrowAmount; + } + + public void setMarginBuyBorrowAmount(String marginBuyBorrowAmount) { + this.marginBuyBorrowAmount = marginBuyBorrowAmount; + } + + public String getMarginBuyBorrowAsset() { + return marginBuyBorrowAsset; + } + + public void setMarginBuyBorrowAsset(String marginBuyBorrowAsset) { + this.marginBuyBorrowAsset = marginBuyBorrowAsset; + } + + public OrderSide getSide() { + return side; + } + + public void setSide(OrderSide side) { + this.side = side; + } + + public List getFills() { + return fills; + } + + public void setFills(List fills) { + this.fills = fills; + } + + @Override + public String toString() { + return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) + .append("symbol", symbol) + .append("orderId", orderId) + .append("clientOrderId", clientOrderId) + .append("transactTime", transactTime) + .append("price", price) + .append("origQty", origQty) + .append("executedQty", executedQty) + .append("status", status) + .append("timeInForce", timeInForce) + .append("type", type) + .append("marginBuyBorrowAmount", marginBuyBorrowAmount) + .append("marginBuyBorrowAsset", marginBuyBorrowAsset) + .append("side", side) + .append("fills", Optional.ofNullable(fills).orElse(Collections.emptyList()) + .stream() + .map(Object::toString) + .collect(Collectors.joining(", "))) + .toString(); + } } diff --git a/src/main/java/com/binance/api/client/domain/account/MaxBorrowableQueryResult.java b/src/main/java/com/binance/api/client/domain/account/MaxBorrowableQueryResult.java index 8a50fdea4..58ce289bc 100755 --- a/src/main/java/com/binance/api/client/domain/account/MaxBorrowableQueryResult.java +++ b/src/main/java/com/binance/api/client/domain/account/MaxBorrowableQueryResult.java @@ -25,7 +25,7 @@ public void setAmount(String amount) { @Override public String toString() { return "MaxBorrowQueryResult{" + - "amount='" + amount + '\'' + - '}'; + "amount='" + amount + '\'' + + '}'; } } diff --git a/src/main/java/com/binance/api/client/domain/account/NewOCO.java b/src/main/java/com/binance/api/client/domain/account/NewOCO.java index 9ee106b15..6a68c2ebd 100755 --- a/src/main/java/com/binance/api/client/domain/account/NewOCO.java +++ b/src/main/java/com/binance/api/client/domain/account/NewOCO.java @@ -10,232 +10,232 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class NewOCO { - /** - * Symbol to place the order on. - */ - private String symbol; - - /** - * A unique Id for the entire orderList - */ - private String listClientOrderId; - - /** - * Buy/Sell order side. - */ - private OrderSide side; - - /** - * Quantity. - */ - private String quantity; - - /** - * A unique Id for the limit order - */ - private String limitClientOrderId; - - /** - * Price. - */ - private String price; - - /** - * Used to make the LIMIT_MAKER leg an iceberg order. - */ - private String limitIcebergQty; - - /** - * A unique Id for the stop loss/stop loss limit leg - */ - private String stopClientOrderId; - - /** - * Stop Price. - */ - private String stopPrice; - - /** - * If provided, stopLimitTimeInForce is required. - */ - private String stopLimitPrice; - - /** - * Used with STOP_LOSS_LIMIT leg to make an iceberg order. - */ - private String stopIcebergQty; - - /** - * Valid values are GTC/FOK/IOC - */ - private TimeInForce stopLimitTimeInForce; - - /** - * Set the response JSON. ACK, RESULT, or FULL; default: RESULT. - */ - private NewOrderResponseType newOrderRespType; - - /** - * Receiving window. - */ - private Long recvWindow; - - /** - * Order timestamp. - */ - private long timestamp; - - /** - * Creates a new OCO with all required parameters. - */ - public NewOCO(String symbol, OrderSide side, String quantity, String price, String stopPrice) { - this.symbol = symbol; - this.side = side; - this.quantity = quantity; - this.price = price; - this.stopPrice = stopPrice; - this.timestamp = System.currentTimeMillis(); - this.recvWindow = BinanceApiConstants.DEFAULT_RECEIVING_WINDOW; - } - - public String getSymbol() { - return symbol; - } - - public void setSymbol(String symbol) { - this.symbol = symbol; - } - - public String getListClientOrderId() { - return listClientOrderId; - } - - public void setListClientOrderId(String listClientOrderId) { - this.listClientOrderId = listClientOrderId; - } - - public OrderSide getSide() { - return side; - } - - public void setSide(OrderSide side) { - this.side = side; - } - - public String getQuantity() { - return quantity; - } - - public void setQuantity(String quantity) { - this.quantity = quantity; - } - - public String getLimitClientOrderId() { - return limitClientOrderId; - } - - public void setLimitClientOrderId(String limitClientOrderId) { - this.limitClientOrderId = limitClientOrderId; - } - - public String getPrice() { - return price; - } - - public void setPrice(String price) { - this.price = price; - } - - public String getLimitIcebergQty() { - return limitIcebergQty; - } - - public void setLimitIcebergQty(String limitIcebergQty) { - this.limitIcebergQty = limitIcebergQty; - } - - public String getStopClientOrderId() { - return stopClientOrderId; - } - - public void setStopClientOrderId(String stopClientOrderId) { - this.stopClientOrderId = stopClientOrderId; - } - - public String getStopPrice() { - return stopPrice; - } - - public void setStopPrice(String stopPrice) { - this.stopPrice = stopPrice; - } - - public String getStopLimitPrice() { - return stopLimitPrice; - } - - public void setStopLimitPrice(String stopLimitPrice) { - this.stopLimitPrice = stopLimitPrice; - } - - public String getStopIcebergQty() { - return stopIcebergQty; - } - - public void setStopIcebergQty(String stopIcebergQty) { - this.stopIcebergQty = stopIcebergQty; - } - - public TimeInForce getStopLimitTimeInForce() { - return stopLimitTimeInForce; - } - - public void setStopLimitTimeInForce(TimeInForce stopLimitTimeInForce) { - this.stopLimitTimeInForce = stopLimitTimeInForce; - } - - public NewOrderResponseType getNewOrderRespType() { - return newOrderRespType; - } - - public void setNewOrderRespType(NewOrderResponseType newOrderRespType) { - this.newOrderRespType = newOrderRespType; - } - - public Long getRecvWindow() { - return recvWindow; - } - - public void setRecvWindow(Long recvWindow) { - this.recvWindow = recvWindow; - } - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE).append("symbol", symbol) - .append("listClientOrderId", listClientOrderId) - .append("side", side) - .append("quantity", quantity) - .append("limitClientOrderId", limitClientOrderId) - .append("price", price) - .append("limitIcebergQty", limitIcebergQty) - .append("stopClientOrderId", stopClientOrderId) - .append("stopPrice", stopPrice) - .append("stopLimitPrice", stopLimitPrice) - .append("stopIcebergQty", stopIcebergQty) - .append("stopLimitTimeInForce", stopLimitTimeInForce) - .append("newOrderRespType", newOrderRespType) - .append("recvWindow", recvWindow) - .append("timestamp", timestamp) - .toString(); - } + /** + * Symbol to place the order on. + */ + private String symbol; + + /** + * A unique Id for the entire orderList + */ + private String listClientOrderId; + + /** + * Buy/Sell order side. + */ + private OrderSide side; + + /** + * Quantity. + */ + private String quantity; + + /** + * A unique Id for the limit order + */ + private String limitClientOrderId; + + /** + * Price. + */ + private String price; + + /** + * Used to make the LIMIT_MAKER leg an iceberg order. + */ + private String limitIcebergQty; + + /** + * A unique Id for the stop loss/stop loss limit leg + */ + private String stopClientOrderId; + + /** + * Stop Price. + */ + private String stopPrice; + + /** + * If provided, stopLimitTimeInForce is required. + */ + private String stopLimitPrice; + + /** + * Used with STOP_LOSS_LIMIT leg to make an iceberg order. + */ + private String stopIcebergQty; + + /** + * Valid values are GTC/FOK/IOC + */ + private TimeInForce stopLimitTimeInForce; + + /** + * Set the response JSON. ACK, RESULT, or FULL; default: RESULT. + */ + private NewOrderResponseType newOrderRespType; + + /** + * Receiving window. + */ + private Long recvWindow; + + /** + * Order timestamp. + */ + private long timestamp; + + /** + * Creates a new OCO with all required parameters. + */ + public NewOCO(String symbol, OrderSide side, String quantity, String price, String stopPrice) { + this.symbol = symbol; + this.side = side; + this.quantity = quantity; + this.price = price; + this.stopPrice = stopPrice; + this.timestamp = System.currentTimeMillis(); + this.recvWindow = BinanceApiConstants.DEFAULT_RECEIVING_WINDOW; + } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + this.symbol = symbol; + } + + public String getListClientOrderId() { + return listClientOrderId; + } + + public void setListClientOrderId(String listClientOrderId) { + this.listClientOrderId = listClientOrderId; + } + + public OrderSide getSide() { + return side; + } + + public void setSide(OrderSide side) { + this.side = side; + } + + public String getQuantity() { + return quantity; + } + + public void setQuantity(String quantity) { + this.quantity = quantity; + } + + public String getLimitClientOrderId() { + return limitClientOrderId; + } + + public void setLimitClientOrderId(String limitClientOrderId) { + this.limitClientOrderId = limitClientOrderId; + } + + public String getPrice() { + return price; + } + + public void setPrice(String price) { + this.price = price; + } + + public String getLimitIcebergQty() { + return limitIcebergQty; + } + + public void setLimitIcebergQty(String limitIcebergQty) { + this.limitIcebergQty = limitIcebergQty; + } + + public String getStopClientOrderId() { + return stopClientOrderId; + } + + public void setStopClientOrderId(String stopClientOrderId) { + this.stopClientOrderId = stopClientOrderId; + } + + public String getStopPrice() { + return stopPrice; + } + + public void setStopPrice(String stopPrice) { + this.stopPrice = stopPrice; + } + + public String getStopLimitPrice() { + return stopLimitPrice; + } + + public void setStopLimitPrice(String stopLimitPrice) { + this.stopLimitPrice = stopLimitPrice; + } + + public String getStopIcebergQty() { + return stopIcebergQty; + } + + public void setStopIcebergQty(String stopIcebergQty) { + this.stopIcebergQty = stopIcebergQty; + } + + public TimeInForce getStopLimitTimeInForce() { + return stopLimitTimeInForce; + } + + public void setStopLimitTimeInForce(TimeInForce stopLimitTimeInForce) { + this.stopLimitTimeInForce = stopLimitTimeInForce; + } + + public NewOrderResponseType getNewOrderRespType() { + return newOrderRespType; + } + + public void setNewOrderRespType(NewOrderResponseType newOrderRespType) { + this.newOrderRespType = newOrderRespType; + } + + public Long getRecvWindow() { + return recvWindow; + } + + public void setRecvWindow(Long recvWindow) { + this.recvWindow = recvWindow; + } + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + @Override + public String toString() { + return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE).append("symbol", symbol) + .append("listClientOrderId", listClientOrderId) + .append("side", side) + .append("quantity", quantity) + .append("limitClientOrderId", limitClientOrderId) + .append("price", price) + .append("limitIcebergQty", limitIcebergQty) + .append("stopClientOrderId", stopClientOrderId) + .append("stopPrice", stopPrice) + .append("stopLimitPrice", stopLimitPrice) + .append("stopIcebergQty", stopIcebergQty) + .append("stopLimitTimeInForce", stopLimitTimeInForce) + .append("newOrderRespType", newOrderRespType) + .append("recvWindow", recvWindow) + .append("timestamp", timestamp) + .toString(); + } } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/domain/account/NewOCOResponse.java b/src/main/java/com/binance/api/client/domain/account/NewOCOResponse.java index b22580827..45a183680 100755 --- a/src/main/java/com/binance/api/client/domain/account/NewOCOResponse.java +++ b/src/main/java/com/binance/api/client/domain/account/NewOCOResponse.java @@ -10,79 +10,79 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class NewOCOResponse extends OrderList { - private Long orderListId; - private ContingencyType contingencyType; - private OCOStatus listStatusType; - private OCOOrderStatus listOrderStatus; - private String listClientOrderId; - private Long transactionTime; - private String symbol; - private List orderReports; - - // Getters - public Long getOrderListId() { - return this.orderListId; - } - - public ContingencyType getContingencyType() { - return this.contingencyType; - } - - public OCOStatus getListStatusType() { - return this.listStatusType; - } - - public OCOOrderStatus getListOrderStatus() { - return this.listOrderStatus; - } - - public String getListClientOrderId() { - return this.listClientOrderId; - } - - public Long getTransactionTime() { - return this.transactionTime; - } - - public String getSymbol() { - return this.symbol; - } - - public List getOrderReports() { - return orderReports; - } - - // Setter - public void setOrderListId(Long orderListId) { - this.orderListId = orderListId; - } - - public void setContingencyType(ContingencyType contingencyType) { - this.contingencyType = contingencyType; - } - - public void setListStatusType(OCOStatus listStatusType) { - this.listStatusType = listStatusType; - } - - public void setListOrderStatus(OCOOrderStatus listOrderStatus) { - this.listOrderStatus = listOrderStatus; - } - - public void setListClientOrderId(String listClientOrderId) { - this.listClientOrderId = listClientOrderId; - } - - public void setTransactionTime(Long transactionTime) { - this.transactionTime = transactionTime; - } - - public void setSymbol(String symbol) { - this.symbol = symbol; - } - - public void setOrderReports(List orderReports) { - this.orderReports = orderReports; - } + private Long orderListId; + private ContingencyType contingencyType; + private OCOStatus listStatusType; + private OCOOrderStatus listOrderStatus; + private String listClientOrderId; + private Long transactionTime; + private String symbol; + private List orderReports; + + // Getters + public Long getOrderListId() { + return this.orderListId; + } + + public ContingencyType getContingencyType() { + return this.contingencyType; + } + + public OCOStatus getListStatusType() { + return this.listStatusType; + } + + public OCOOrderStatus getListOrderStatus() { + return this.listOrderStatus; + } + + public String getListClientOrderId() { + return this.listClientOrderId; + } + + public Long getTransactionTime() { + return this.transactionTime; + } + + public String getSymbol() { + return this.symbol; + } + + public List getOrderReports() { + return orderReports; + } + + // Setter + public void setOrderListId(Long orderListId) { + this.orderListId = orderListId; + } + + public void setContingencyType(ContingencyType contingencyType) { + this.contingencyType = contingencyType; + } + + public void setListStatusType(OCOStatus listStatusType) { + this.listStatusType = listStatusType; + } + + public void setListOrderStatus(OCOOrderStatus listOrderStatus) { + this.listOrderStatus = listOrderStatus; + } + + public void setListClientOrderId(String listClientOrderId) { + this.listClientOrderId = listClientOrderId; + } + + public void setTransactionTime(Long transactionTime) { + this.transactionTime = transactionTime; + } + + public void setSymbol(String symbol) { + this.symbol = symbol; + } + + public void setOrderReports(List orderReports) { + this.orderReports = orderReports; + } } diff --git a/src/main/java/com/binance/api/client/domain/account/NewOrder.java b/src/main/java/com/binance/api/client/domain/account/NewOrder.java index 6c592219a..607e163bc 100755 --- a/src/main/java/com/binance/api/client/domain/account/NewOrder.java +++ b/src/main/java/com/binance/api/client/domain/account/NewOrder.java @@ -270,20 +270,20 @@ public static NewOrder limitSell(String symbol, TimeInForce timeInForce, String @Override public String toString() { return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("symbol", symbol) - .append("side", side) - .append("type", type) - .append("timeInForce", timeInForce) - .append("quantity", quantity) - .append("quoteOrderQty", quoteOrderQty) - .append("price", price) - .append("newClientOrderId", newClientOrderId) - .append("stopPrice", stopPrice) - .append("stopLimitPrice", stopLimitPrice) - .append("icebergQty", icebergQty) - .append("newOrderRespType", newOrderRespType) - .append("recvWindow", recvWindow) - .append("timestamp", timestamp) - .toString(); + .append("symbol", symbol) + .append("side", side) + .append("type", type) + .append("timeInForce", timeInForce) + .append("quantity", quantity) + .append("quoteOrderQty", quoteOrderQty) + .append("price", price) + .append("newClientOrderId", newClientOrderId) + .append("stopPrice", stopPrice) + .append("stopLimitPrice", stopLimitPrice) + .append("icebergQty", icebergQty) + .append("newOrderRespType", newOrderRespType) + .append("recvWindow", recvWindow) + .append("timestamp", timestamp) + .toString(); } } diff --git a/src/main/java/com/binance/api/client/domain/account/NewOrderResponseType.java b/src/main/java/com/binance/api/client/domain/account/NewOrderResponseType.java index fe1d00e55..b1a7fe924 100755 --- a/src/main/java/com/binance/api/client/domain/account/NewOrderResponseType.java +++ b/src/main/java/com/binance/api/client/domain/account/NewOrderResponseType.java @@ -4,12 +4,13 @@ /** * Desired response type of NewOrder requests. + * * @see NewOrderResponse */ @JsonIgnoreProperties(ignoreUnknown = true) public enum NewOrderResponseType { - ACK, - RESULT, - FULL + ACK, + RESULT, + FULL } diff --git a/src/main/java/com/binance/api/client/domain/account/Order.java b/src/main/java/com/binance/api/client/domain/account/Order.java index 881efd6dc..bcae3c189 100755 --- a/src/main/java/com/binance/api/client/domain/account/Order.java +++ b/src/main/java/com/binance/api/client/domain/account/Order.java @@ -253,24 +253,24 @@ public void setOrigQuoteOrderQty(String origQuoteOrderQty) { @Override public String toString() { return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("symbol", symbol) - .append("orderId", orderId) - .append("clientOrderId", clientOrderId) - .append("price", price) - .append("origQty", origQty) - .append("executedQty", executedQty) - .append("status", status) - .append("timeInForce", timeInForce) - .append("type", type) - .append("side", side) - .append("stopPrice", stopPrice) - .append("stopLimitPrice", stopLimitPrice) - .append("icebergQty", icebergQty) - .append("time", time) - .append("cummulativeQuoteQty", cummulativeQuoteQty) - .append("updateTime", updateTime) - .append("isWorking", working) - .append("origQuoteOrderQty", origQuoteOrderQty) - .toString(); + .append("symbol", symbol) + .append("orderId", orderId) + .append("clientOrderId", clientOrderId) + .append("price", price) + .append("origQty", origQty) + .append("executedQty", executedQty) + .append("status", status) + .append("timeInForce", timeInForce) + .append("type", type) + .append("side", side) + .append("stopPrice", stopPrice) + .append("stopLimitPrice", stopLimitPrice) + .append("icebergQty", icebergQty) + .append("time", time) + .append("cummulativeQuoteQty", cummulativeQuoteQty) + .append("updateTime", updateTime) + .append("isWorking", working) + .append("origQuoteOrderQty", origQuoteOrderQty) + .toString(); } } diff --git a/src/main/java/com/binance/api/client/domain/account/OrderList.java b/src/main/java/com/binance/api/client/domain/account/OrderList.java index 2ee3674d0..7a70f1040 100755 --- a/src/main/java/com/binance/api/client/domain/account/OrderList.java +++ b/src/main/java/com/binance/api/client/domain/account/OrderList.java @@ -13,101 +13,101 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class OrderList { - /** - * Order id. - */ - private Long orderListId; + /** + * Order id. + */ + private Long orderListId; - private ContingencyType contingencyType; + private ContingencyType contingencyType; - private OCOStatus listStatusType; + private OCOStatus listStatusType; - private OCOOrderStatus listOrderStatus; + private OCOOrderStatus listOrderStatus; - private String listClientOrderId; + private String listClientOrderId; - private Long transactionTime; + private Long transactionTime; - private String symbol; + private String symbol; - private List orders; + private List orders; - public Long getOrderListId() { - return orderListId; - } + public Long getOrderListId() { + return orderListId; + } - public void setOrderListId(Long orderListId) { - this.orderListId = orderListId; - } + public void setOrderListId(Long orderListId) { + this.orderListId = orderListId; + } - public ContingencyType getContingencyType() { - return contingencyType; - } + public ContingencyType getContingencyType() { + return contingencyType; + } - public void setContingencyType(ContingencyType contingencyType) { - this.contingencyType = contingencyType; - } + public void setContingencyType(ContingencyType contingencyType) { + this.contingencyType = contingencyType; + } - public OCOStatus getListStatusType() { - return listStatusType; - } + public OCOStatus getListStatusType() { + return listStatusType; + } - public void setListStatusType(OCOStatus listStatusType) { - this.listStatusType = listStatusType; - } + public void setListStatusType(OCOStatus listStatusType) { + this.listStatusType = listStatusType; + } - public OCOOrderStatus getListOrderStatus() { - return listOrderStatus; - } + public OCOOrderStatus getListOrderStatus() { + return listOrderStatus; + } - public void setListOrderStatus(OCOOrderStatus listOrderStatus) { - this.listOrderStatus = listOrderStatus; - } + public void setListOrderStatus(OCOOrderStatus listOrderStatus) { + this.listOrderStatus = listOrderStatus; + } - public String getListClientOrderId() { - return listClientOrderId; - } + public String getListClientOrderId() { + return listClientOrderId; + } - public void setListClientOrderId(String listClientOrderId) { - this.listClientOrderId = listClientOrderId; - } + public void setListClientOrderId(String listClientOrderId) { + this.listClientOrderId = listClientOrderId; + } - public Long getTransactionTime() { - return transactionTime; - } + public Long getTransactionTime() { + return transactionTime; + } - public void setTransactionTime(Long transactionTime) { - this.transactionTime = transactionTime; - } + public void setTransactionTime(Long transactionTime) { + this.transactionTime = transactionTime; + } - public String getSymbol() { - return symbol; - } + public String getSymbol() { + return symbol; + } - public void setSymbol(String symbol) { - this.symbol = symbol; - } + public void setSymbol(String symbol) { + this.symbol = symbol; + } - public List getOrders() { - return orders; - } + public List getOrders() { + return orders; + } - public void setOrders(List orders) { - this.orders = orders; - } + public void setOrders(List orders) { + this.orders = orders; + } - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("orderListId", orderListId) - .append("contingencyType", contingencyType) - .append("listStatusType", listStatusType) - .append("listOrderStatus", listOrderStatus) - .append("listClientOrderId", listClientOrderId) - .append("transactionTime", transactionTime) - .append("symbol", symbol) - .append("orders", orders) - .toString(); - } + @Override + public String toString() { + return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) + .append("orderListId", orderListId) + .append("contingencyType", contingencyType) + .append("listStatusType", listStatusType) + .append("listOrderStatus", listOrderStatus) + .append("listClientOrderId", listClientOrderId) + .append("transactionTime", transactionTime) + .append("symbol", symbol) + .append("orders", orders) + .toString(); + } } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/domain/account/OrderReport.java b/src/main/java/com/binance/api/client/domain/account/OrderReport.java index 041876861..dffe00503 100755 --- a/src/main/java/com/binance/api/client/domain/account/OrderReport.java +++ b/src/main/java/com/binance/api/client/domain/account/OrderReport.java @@ -9,164 +9,164 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class OrderReport { - /** - * Order symbol. - */ - private String symbol; + /** + * Order symbol. + */ + private String symbol; - /** - * Order id. - */ - private Long orderId; + /** + * Order id. + */ + private Long orderId; - private Long orderListId; + private Long orderListId; - /** - * This will be either a generated one, or the newClientOrderId parameter - * which was passed when creating the new order. - */ - private String clientOrderId; + /** + * This will be either a generated one, or the newClientOrderId parameter + * which was passed when creating the new order. + */ + private String clientOrderId; - private String origClientOrderId; + private String origClientOrderId; - private Long transactTime; + private Long transactTime; - private String price; + private String price; - private String origQty; + private String origQty; - private String executedQty; + private String executedQty; - private String cummulativeQuoteQty; + private String cummulativeQuoteQty; - private OrderStatus status; + private OrderStatus status; - private TimeInForce timeInForce; + private TimeInForce timeInForce; - private OrderType type; + private OrderType type; - private OrderSide side; + private OrderSide side; - private String stopPrice; + private String stopPrice; - public String getSymbol() { - return symbol; - } + public String getSymbol() { + return symbol; + } - public void setSymbol(String symbol) { - this.symbol = symbol; - } + public void setSymbol(String symbol) { + this.symbol = symbol; + } - public Long getOrderId() { - return orderId; - } + public Long getOrderId() { + return orderId; + } - public void setOrderId(Long orderId) { - this.orderId = orderId; - } + public void setOrderId(Long orderId) { + this.orderId = orderId; + } - public Long getOrderListId() { - return orderListId; - } + public Long getOrderListId() { + return orderListId; + } - public void setOrderListId(Long orderListId) { - this.orderListId = orderListId; - } + public void setOrderListId(Long orderListId) { + this.orderListId = orderListId; + } - public String getClientOrderId() { - return clientOrderId; - } + public String getClientOrderId() { + return clientOrderId; + } - public void setClientOrderId(String clientOrderId) { - this.clientOrderId = clientOrderId; - } + public void setClientOrderId(String clientOrderId) { + this.clientOrderId = clientOrderId; + } - public String getOrigClientOrderId() { - return origClientOrderId; - } + public String getOrigClientOrderId() { + return origClientOrderId; + } - public void setOrigClientOrderId(String origClientOrderId) { - this.origClientOrderId = origClientOrderId; - } + public void setOrigClientOrderId(String origClientOrderId) { + this.origClientOrderId = origClientOrderId; + } - public Long getTransactTime() { - return transactTime; - } + public Long getTransactTime() { + return transactTime; + } - public void setTransactTime(Long transactTime) { - this.transactTime = transactTime; - } + public void setTransactTime(Long transactTime) { + this.transactTime = transactTime; + } - public String getPrice() { - return price; - } + public String getPrice() { + return price; + } - public void setPrice(String price) { - this.price = price; - } + public void setPrice(String price) { + this.price = price; + } - public String getOrigQty() { - return origQty; - } + public String getOrigQty() { + return origQty; + } - public void setOrigQty(String origQty) { - this.origQty = origQty; - } + public void setOrigQty(String origQty) { + this.origQty = origQty; + } - public String getExecutedQty() { - return executedQty; - } + public String getExecutedQty() { + return executedQty; + } - public void setExecutedQty(String executedQty) { - this.executedQty = executedQty; - } + public void setExecutedQty(String executedQty) { + this.executedQty = executedQty; + } - public String getCummulativeQuoteQty() { - return cummulativeQuoteQty; - } + public String getCummulativeQuoteQty() { + return cummulativeQuoteQty; + } - public void setCummulativeQuoteQty(String cummulativeQuoteQty) { - this.cummulativeQuoteQty = cummulativeQuoteQty; - } + public void setCummulativeQuoteQty(String cummulativeQuoteQty) { + this.cummulativeQuoteQty = cummulativeQuoteQty; + } - public OrderStatus getStatus() { - return status; - } + public OrderStatus getStatus() { + return status; + } - public void setStatus(OrderStatus status) { - this.status = status; - } + public void setStatus(OrderStatus status) { + this.status = status; + } - public TimeInForce getTimeInForce() { - return timeInForce; - } + public TimeInForce getTimeInForce() { + return timeInForce; + } - public void setTimeInForce(TimeInForce timeInForce) { - this.timeInForce = timeInForce; - } + public void setTimeInForce(TimeInForce timeInForce) { + this.timeInForce = timeInForce; + } - public OrderType getType() { - return type; - } + public OrderType getType() { + return type; + } - public void setType(OrderType type) { - this.type = type; - } + public void setType(OrderType type) { + this.type = type; + } - public OrderSide getSide() { - return side; - } + public OrderSide getSide() { + return side; + } - public void setSide(OrderSide side) { - this.side = side; - } + public void setSide(OrderSide side) { + this.side = side; + } - public String getStopPrice() { - return stopPrice; - } + public String getStopPrice() { + return stopPrice; + } - public void setStopPrice(String stopPrice) { - this.stopPrice = stopPrice; - } + public void setStopPrice(String stopPrice) { + this.stopPrice = stopPrice; + } } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/domain/account/Pool.java b/src/main/java/com/binance/api/client/domain/account/Pool.java index 413d301f2..2b6e72986 100755 --- a/src/main/java/com/binance/api/client/domain/account/Pool.java +++ b/src/main/java/com/binance/api/client/domain/account/Pool.java @@ -4,40 +4,40 @@ public class Pool { - private String poolId; - private String poolName; - private List assets; - - public String getPoolId() { - return poolId; - } - - public void setPoolId(String poolId) { - this.poolId = poolId; - } - - public List getAssets() { - return assets; - } - - public void setAssets(List assets) { - this.assets = assets; - } - - public String getPoolName() { - return poolName; - } - - public void setPoolName(String poolName) { - this.poolName = poolName; - } - - @Override - public String toString() { - return "Pool{" + - "poolId='" + poolId + '\'' + - ", poolName='" + poolName + '\'' + - ", assets=" + assets + - '}'; - } + private String poolId; + private String poolName; + private List assets; + + public String getPoolId() { + return poolId; + } + + public void setPoolId(String poolId) { + this.poolId = poolId; + } + + public List getAssets() { + return assets; + } + + public void setAssets(List assets) { + this.assets = assets; + } + + public String getPoolName() { + return poolName; + } + + public void setPoolName(String poolName) { + this.poolName = poolName; + } + + @Override + public String toString() { + return "Pool{" + + "poolId='" + poolId + '\'' + + ", poolName='" + poolName + '\'' + + ", assets=" + assets + + '}'; + } } diff --git a/src/main/java/com/binance/api/client/domain/account/Repay.java b/src/main/java/com/binance/api/client/domain/account/Repay.java index 22f3e7b0e..cb2e414de 100755 --- a/src/main/java/com/binance/api/client/domain/account/Repay.java +++ b/src/main/java/com/binance/api/client/domain/account/Repay.java @@ -6,80 +6,80 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class Repay { - private String amount; - private String asset; - private String interest; - private String principal; - LoanStatus status; - private long timestamp; - private String txId; - - public String getAmount() { - return amount; - } - - public void setAmount(String amount) { - this.amount = amount; - } - - public String getAsset() { - return asset; - } - - public void setAsset(String asset) { - this.asset = asset; - } - - public String getInterest() { - return interest; - } - - public void setInterest(String interest) { - this.interest = interest; - } - - public String getPrincipal() { - return principal; - } - - public void setPrincipal(String principal) { - this.principal = principal; - } - - public LoanStatus getStatus() { - return status; - } - - public void setStatus(LoanStatus status) { - this.status = status; - } - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public String getTxId() { - return txId; - } - - public void setTxId(String txId) { - this.txId = txId; - } - - @Override - public String toString() { - return "Repay{" + - "amount='" + amount + '\'' + - ", asset='" + asset + '\'' + - ", interest='" + interest + '\'' + - ", principal='" + principal + '\'' + - ", status=" + status + - ", timestamp=" + timestamp + - ", txId='" + txId + '\'' + - '}'; - } + private String amount; + private String asset; + private String interest; + private String principal; + LoanStatus status; + private long timestamp; + private String txId; + + public String getAmount() { + return amount; + } + + public void setAmount(String amount) { + this.amount = amount; + } + + public String getAsset() { + return asset; + } + + public void setAsset(String asset) { + this.asset = asset; + } + + public String getInterest() { + return interest; + } + + public void setInterest(String interest) { + this.interest = interest; + } + + public String getPrincipal() { + return principal; + } + + public void setPrincipal(String principal) { + this.principal = principal; + } + + public LoanStatus getStatus() { + return status; + } + + public void setStatus(LoanStatus status) { + this.status = status; + } + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public String getTxId() { + return txId; + } + + public void setTxId(String txId) { + this.txId = txId; + } + + @Override + public String toString() { + return "Repay{" + + "amount='" + amount + '\'' + + ", asset='" + asset + '\'' + + ", interest='" + interest + '\'' + + ", principal='" + principal + '\'' + + ", status=" + status + + ", timestamp=" + timestamp + + ", txId='" + txId + '\'' + + '}'; + } } diff --git a/src/main/java/com/binance/api/client/domain/account/RepayQueryResult.java b/src/main/java/com/binance/api/client/domain/account/RepayQueryResult.java index 4221e9df5..2f0d2514c 100755 --- a/src/main/java/com/binance/api/client/domain/account/RepayQueryResult.java +++ b/src/main/java/com/binance/api/client/domain/account/RepayQueryResult.java @@ -34,8 +34,8 @@ public void setRows(List rows) { @Override public String toString() { return "RepayQueryResult{" + - "total=" + total + - ", rows=" + rows + - '}'; + "total=" + total + + ", rows=" + rows + + '}'; } } diff --git a/src/main/java/com/binance/api/client/domain/account/SideEffectType.java b/src/main/java/com/binance/api/client/domain/account/SideEffectType.java index 940490e16..36d92da7d 100755 --- a/src/main/java/com/binance/api/client/domain/account/SideEffectType.java +++ b/src/main/java/com/binance/api/client/domain/account/SideEffectType.java @@ -10,8 +10,8 @@ */ @JsonIgnoreProperties(ignoreUnknown = true) public enum SideEffectType { - NO_SIDE_EFFECT, - MARGIN_BUY, - AUTO_REPAY + NO_SIDE_EFFECT, + MARGIN_BUY, + AUTO_REPAY } diff --git a/src/main/java/com/binance/api/client/domain/account/SubAccountTransfer.java b/src/main/java/com/binance/api/client/domain/account/SubAccountTransfer.java index 69b7d70cf..fd76dc286 100755 --- a/src/main/java/com/binance/api/client/domain/account/SubAccountTransfer.java +++ b/src/main/java/com/binance/api/client/domain/account/SubAccountTransfer.java @@ -8,144 +8,152 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class SubAccountTransfer { - /** - * Counter party name - */ - private String counterParty; - - /** - * Counter party email - */ - private String email; - - /** - * Transfer in or transfer out - */ - private Integer type; // 1 for transfer in, 2 for transfer out - - /** - * Transfer asset - */ - private String asset; - - /** - * Quantity of transfer asset - */ - private String qty; - - /** - * Type of from account - */ - private String fromAccountType; - - /** - * Type of to account - */ - private String toAccountType; - - /** - * Transfer status - */ - private String status; - - /** - * Transfer ID - */ - private Long tranId; - - /** - * Transfer time - */ - private Long time; - - // Setter - public void setCounterParty(String counterParty) { - this.counterParty = counterParty; - } - - public void setEmail(String email) { - this.email = email; - } - - public void setType(Integer type) { - this.type = type; - } - - public void setAsset(String asset) { - this.asset = asset; - } - - public void setQty(String qty) { - this.qty = qty; - } - - public void setFromAccountType(String fromAccountType) { this.fromAccountType = fromAccountType; } - - public void setToAccountType(String toAccountType) { this.toAccountType = toAccountType; } - - public void setStatus(String status) { - this.status = status; - } - - public void setTranId(Long tranId) { - this.tranId = tranId; - } - - public void setTime(Long time) { - this.time = time; - } - - // Getter - public String getCounterParty() { - return this.counterParty; - } - - public String getEmail() { - return this.email; - } - - public Integer getType() { - return this.type; - } - - public String getAsset() { - return this.asset; - } - - public String getQty() { - return this.qty; - } - - public String getFromAccountType() { return this.fromAccountType; } - - public String getToAccountType() { return this.toAccountType; } - - public String getStatus() { - return this.status; - } - - public Long getTranId() { - return this.tranId; - } - - public Long getTime() { - return this.time; - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("counterParty", this.counterParty) - .append("email", this.email) - .append("type", this.type) - .append("asset", this.asset) - .append("qty", this.qty) - .append("fromAccountType", this.fromAccountType) - .append("toAccountType", this.toAccountType) - .append("status", this.status) - .append("tranId", this.tranId) - .append("time", this.time) - .toString(); - } + /** + * Counter party name + */ + private String counterParty; + + /** + * Counter party email + */ + private String email; + + /** + * Transfer in or transfer out + */ + private Integer type; // 1 for transfer in, 2 for transfer out + + /** + * Transfer asset + */ + private String asset; + + /** + * Quantity of transfer asset + */ + private String qty; + + /** + * Type of from account + */ + private String fromAccountType; + + /** + * Type of to account + */ + private String toAccountType; + + /** + * Transfer status + */ + private String status; + + /** + * Transfer ID + */ + private Long tranId; + + /** + * Transfer time + */ + private Long time; + + // Setter + public void setCounterParty(String counterParty) { + this.counterParty = counterParty; + } + + public void setEmail(String email) { + this.email = email; + } + + public void setType(Integer type) { + this.type = type; + } + + public void setAsset(String asset) { + this.asset = asset; + } + + public void setQty(String qty) { + this.qty = qty; + } + + public void setFromAccountType(String fromAccountType) { + this.fromAccountType = fromAccountType; + } + + public void setToAccountType(String toAccountType) { + this.toAccountType = toAccountType; + } + + public void setStatus(String status) { + this.status = status; + } + + public void setTranId(Long tranId) { + this.tranId = tranId; + } + + public void setTime(Long time) { + this.time = time; + } + + // Getter + public String getCounterParty() { + return this.counterParty; + } + + public String getEmail() { + return this.email; + } + + public Integer getType() { + return this.type; + } + + public String getAsset() { + return this.asset; + } + + public String getQty() { + return this.qty; + } + + public String getFromAccountType() { + return this.fromAccountType; + } + + public String getToAccountType() { + return this.toAccountType; + } + + public String getStatus() { + return this.status; + } + + public Long getTranId() { + return this.tranId; + } + + public Long getTime() { + return this.time; + } + + @Override + public String toString() { + return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) + .append("counterParty", this.counterParty) + .append("email", this.email) + .append("type", this.type) + .append("asset", this.asset) + .append("qty", this.qty) + .append("fromAccountType", this.fromAccountType) + .append("toAccountType", this.toAccountType) + .append("status", this.status) + .append("tranId", this.tranId) + .append("time", this.time) + .toString(); + } } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/domain/account/SwapHistory.java b/src/main/java/com/binance/api/client/domain/account/SwapHistory.java index b4c7c785c..4854fc8c4 100755 --- a/src/main/java/com/binance/api/client/domain/account/SwapHistory.java +++ b/src/main/java/com/binance/api/client/domain/account/SwapHistory.java @@ -2,100 +2,100 @@ public class SwapHistory { - private String quoteQty; - private Long swapTime; - private String swapId; - private String price; - private String fee; - private String baseQty; - private String baseAsset; - private String quoteAsset; - private SwapStatus status; - - public String getQuoteQty() { - return quoteQty; - } - - public void setQuoteQty(String quoteQty) { - this.quoteQty = quoteQty; - } - - public Long getSwapTime() { - return swapTime; - } - - public void setSwapTime(Long swapTime) { - this.swapTime = swapTime; - } - - public String getSwapId() { - return swapId; - } - - public void setSwapId(String swapId) { - this.swapId = swapId; - } - - public String getPrice() { - return price; - } - - public void setPrice(String price) { - this.price = price; - } - - public String getFee() { - return fee; - } - - public void setFee(String fee) { - this.fee = fee; - } - - public String getBaseQty() { - return baseQty; - } - - public void setBaseQty(String baseQty) { - this.baseQty = baseQty; - } - - public String getBaseAsset() { - return baseAsset; - } - - public void setBaseAsset(String baseAsset) { - this.baseAsset = baseAsset; - } - - public String getQuoteAsset() { - return quoteAsset; - } - - public void setQuoteAsset(String quoteAsset) { - this.quoteAsset = quoteAsset; - } - - public SwapStatus getStatus() { - return status; - } - - public void setStatus(SwapStatus status) { - this.status = status; - } - - @Override - public String toString() { - return "SwapHistory{" + - "quoteQty='" + quoteQty + '\'' + - ", swapTime=" + swapTime + - ", swapId='" + swapId + '\'' + - ", price='" + price + '\'' + - ", fee='" + fee + '\'' + - ", baseQty='" + baseQty + '\'' + - ", baseAsset='" + baseAsset + '\'' + - ", quoteAsset='" + quoteAsset + '\'' + - ", status='" + status + '\'' + - '}'; - } + private String quoteQty; + private Long swapTime; + private String swapId; + private String price; + private String fee; + private String baseQty; + private String baseAsset; + private String quoteAsset; + private SwapStatus status; + + public String getQuoteQty() { + return quoteQty; + } + + public void setQuoteQty(String quoteQty) { + this.quoteQty = quoteQty; + } + + public Long getSwapTime() { + return swapTime; + } + + public void setSwapTime(Long swapTime) { + this.swapTime = swapTime; + } + + public String getSwapId() { + return swapId; + } + + public void setSwapId(String swapId) { + this.swapId = swapId; + } + + public String getPrice() { + return price; + } + + public void setPrice(String price) { + this.price = price; + } + + public String getFee() { + return fee; + } + + public void setFee(String fee) { + this.fee = fee; + } + + public String getBaseQty() { + return baseQty; + } + + public void setBaseQty(String baseQty) { + this.baseQty = baseQty; + } + + public String getBaseAsset() { + return baseAsset; + } + + public void setBaseAsset(String baseAsset) { + this.baseAsset = baseAsset; + } + + public String getQuoteAsset() { + return quoteAsset; + } + + public void setQuoteAsset(String quoteAsset) { + this.quoteAsset = quoteAsset; + } + + public SwapStatus getStatus() { + return status; + } + + public void setStatus(SwapStatus status) { + this.status = status; + } + + @Override + public String toString() { + return "SwapHistory{" + + "quoteQty='" + quoteQty + '\'' + + ", swapTime=" + swapTime + + ", swapId='" + swapId + '\'' + + ", price='" + price + '\'' + + ", fee='" + fee + '\'' + + ", baseQty='" + baseQty + '\'' + + ", baseAsset='" + baseAsset + '\'' + + ", quoteAsset='" + quoteAsset + '\'' + + ", status='" + status + '\'' + + '}'; + } } diff --git a/src/main/java/com/binance/api/client/domain/account/SwapQuote.java b/src/main/java/com/binance/api/client/domain/account/SwapQuote.java index c776750f8..fdce77258 100755 --- a/src/main/java/com/binance/api/client/domain/account/SwapQuote.java +++ b/src/main/java/com/binance/api/client/domain/account/SwapQuote.java @@ -1,81 +1,81 @@ package com.binance.api.client.domain.account; public class SwapQuote { - private String quoteQty; - private String price; - private String fee; - private String baseQty; - private String baseAsset; - private String slippage; - private String quoteAsset; - - public String getQuoteQty() { - return quoteQty; - } - - public void setQuoteQty(String quoteQty) { - this.quoteQty = quoteQty; - } - - public String getPrice() { - return price; - } - - public void setPrice(String price) { - this.price = price; - } - - public String getFee() { - return fee; - } - - public void setFee(String fee) { - this.fee = fee; - } - - public String getBaseQty() { - return baseQty; - } - - public void setBaseQty(String baseQty) { - this.baseQty = baseQty; - } - - public String getBaseAsset() { - return baseAsset; - } - - public void setBaseAsset(String baseAsset) { - this.baseAsset = baseAsset; - } - - public String getSlippage() { - return slippage; - } - - public void setSlippage(String slippage) { - this.slippage = slippage; - } - - public String getQuoteAsset() { - return quoteAsset; - } - - public void setQuoteAsset(String quoteAsset) { - this.quoteAsset = quoteAsset; - } - - @Override - public String toString() { - return "SwapQuote{" + - "quoteQty='" + quoteQty + '\'' + - ", price='" + price + '\'' + - ", fee='" + fee + '\'' + - ", baseQty='" + baseQty + '\'' + - ", baseAsset='" + baseAsset + '\'' + - ", slippage='" + slippage + '\'' + - ", quoteAsset='" + quoteAsset + '\'' + - '}'; - } + private String quoteQty; + private String price; + private String fee; + private String baseQty; + private String baseAsset; + private String slippage; + private String quoteAsset; + + public String getQuoteQty() { + return quoteQty; + } + + public void setQuoteQty(String quoteQty) { + this.quoteQty = quoteQty; + } + + public String getPrice() { + return price; + } + + public void setPrice(String price) { + this.price = price; + } + + public String getFee() { + return fee; + } + + public void setFee(String fee) { + this.fee = fee; + } + + public String getBaseQty() { + return baseQty; + } + + public void setBaseQty(String baseQty) { + this.baseQty = baseQty; + } + + public String getBaseAsset() { + return baseAsset; + } + + public void setBaseAsset(String baseAsset) { + this.baseAsset = baseAsset; + } + + public String getSlippage() { + return slippage; + } + + public void setSlippage(String slippage) { + this.slippage = slippage; + } + + public String getQuoteAsset() { + return quoteAsset; + } + + public void setQuoteAsset(String quoteAsset) { + this.quoteAsset = quoteAsset; + } + + @Override + public String toString() { + return "SwapQuote{" + + "quoteQty='" + quoteQty + '\'' + + ", price='" + price + '\'' + + ", fee='" + fee + '\'' + + ", baseQty='" + baseQty + '\'' + + ", baseAsset='" + baseAsset + '\'' + + ", slippage='" + slippage + '\'' + + ", quoteAsset='" + quoteAsset + '\'' + + '}'; + } } diff --git a/src/main/java/com/binance/api/client/domain/account/SwapRecord.java b/src/main/java/com/binance/api/client/domain/account/SwapRecord.java index 085af3068..d4d9198aa 100755 --- a/src/main/java/com/binance/api/client/domain/account/SwapRecord.java +++ b/src/main/java/com/binance/api/client/domain/account/SwapRecord.java @@ -2,20 +2,20 @@ public class SwapRecord { - private String swapId; + private String swapId; - public String getSwapId() { - return swapId; - } + public String getSwapId() { + return swapId; + } - public void setSwapId(String swapId) { - this.swapId = swapId; - } + public void setSwapId(String swapId) { + this.swapId = swapId; + } - @Override - public String toString() { - return "SwapRecord{" + - "swapId='" + swapId + '\'' + - '}'; - } + @Override + public String toString() { + return "SwapRecord{" + + "swapId='" + swapId + '\'' + + '}'; + } } diff --git a/src/main/java/com/binance/api/client/domain/account/SwapStatus.java b/src/main/java/com/binance/api/client/domain/account/SwapStatus.java index b1a0dc9eb..82ab74007 100755 --- a/src/main/java/com/binance/api/client/domain/account/SwapStatus.java +++ b/src/main/java/com/binance/api/client/domain/account/SwapStatus.java @@ -5,14 +5,14 @@ @JsonIgnoreProperties(ignoreUnknown = true) public enum SwapStatus { - PENDING, - SUCCESS, - FAILED; + PENDING, + SUCCESS, + FAILED; - @JsonValue - public int toValue() { - return ordinal(); - } + @JsonValue + public int toValue() { + return ordinal(); + } } diff --git a/src/main/java/com/binance/api/client/domain/account/TradeHistoryItem.java b/src/main/java/com/binance/api/client/domain/account/TradeHistoryItem.java index babc10760..e7b5ec268 100755 --- a/src/main/java/com/binance/api/client/domain/account/TradeHistoryItem.java +++ b/src/main/java/com/binance/api/client/domain/account/TradeHistoryItem.java @@ -10,95 +10,95 @@ */ @JsonIgnoreProperties(ignoreUnknown = true) public class TradeHistoryItem { - /** - * Trade id. - */ - private long id; - - /** - * Price. - */ - private String price; - - /** - * Quantity. - */ - private String qty; - - /** - * Trade execution time. - */ - private long time; - - /** - * Is buyer maker ? - */ - @JsonProperty("isBuyerMaker") - private boolean isBuyerMaker; - - /** - * Is best match ? - */ - @JsonProperty("isBestMatch") - private boolean isBestMatch; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getPrice() { - return price; - } - - public void setPrice(String price) { - this.price = price; - } - - public String getQty() { - return qty; - } - - public void setQty(String qty) { - this.qty = qty; - } - - public long getTime() { - return time; - } - - public void setTime(long time) { - this.time = time; - } - - public boolean isBuyerMaker() { - return isBuyerMaker; - } - - public void setBuyerMaker(boolean buyerMaker) { - isBuyerMaker = buyerMaker; - } - - public boolean isBestMatch() { - return isBestMatch; - } - - public void setBestMatch(boolean bestMatch) { - isBestMatch = bestMatch; - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("id", id) - .append("price", price) - .append("qty", qty) - .append("time", time) - .append("isBuyerMaker", isBuyerMaker) - .append("isBestMatch", isBestMatch) - .toString(); - } + /** + * Trade id. + */ + private long id; + + /** + * Price. + */ + private String price; + + /** + * Quantity. + */ + private String qty; + + /** + * Trade execution time. + */ + private long time; + + /** + * Is buyer maker ? + */ + @JsonProperty("isBuyerMaker") + private boolean isBuyerMaker; + + /** + * Is best match ? + */ + @JsonProperty("isBestMatch") + private boolean isBestMatch; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getPrice() { + return price; + } + + public void setPrice(String price) { + this.price = price; + } + + public String getQty() { + return qty; + } + + public void setQty(String qty) { + this.qty = qty; + } + + public long getTime() { + return time; + } + + public void setTime(long time) { + this.time = time; + } + + public boolean isBuyerMaker() { + return isBuyerMaker; + } + + public void setBuyerMaker(boolean buyerMaker) { + isBuyerMaker = buyerMaker; + } + + public boolean isBestMatch() { + return isBestMatch; + } + + public void setBestMatch(boolean bestMatch) { + isBestMatch = bestMatch; + } + + @Override + public String toString() { + return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) + .append("id", id) + .append("price", price) + .append("qty", qty) + .append("time", time) + .append("isBuyerMaker", isBuyerMaker) + .append("isBestMatch", isBestMatch) + .toString(); + } } diff --git a/src/main/java/com/binance/api/client/domain/account/TransferResult.java b/src/main/java/com/binance/api/client/domain/account/TransferResult.java index a07f12c56..e678b2999 100755 --- a/src/main/java/com/binance/api/client/domain/account/TransferResult.java +++ b/src/main/java/com/binance/api/client/domain/account/TransferResult.java @@ -11,81 +11,80 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class TransferResult { - private String amount; + private String amount; - private String fromAsset; + private String fromAsset; - /** - * Order timestamp. - */ - private long operateTime; + /** + * Order timestamp. + */ + private long operateTime; - private String serviceChargeAmount; + private String serviceChargeAmount; - private long tranId; + private long tranId; - private String transferedAmount; + private String transferedAmount; + public String getAmount() { + return amount; + } - public String getAmount() { - return amount; - } + public void setAmount(String amount) { + this.amount = amount; + } - public void setAmount(String amount) { - this.amount = amount; - } + public String getFromAsset() { + return fromAsset; + } - public String getFromAsset() { - return fromAsset; - } + public void setFromAsset(String fromAsset) { + this.fromAsset = fromAsset; + } - public void setFromAsset(String fromAsset) { - this.fromAsset = fromAsset; - } + public long getOperateTime() { + return operateTime; + } - public long getOperateTime() { - return operateTime; - } + public void setOperateTime(long operateTime) { + this.operateTime = operateTime; + } - public void setOperateTime(long operateTime) { - this.operateTime = operateTime; - } + public String getServiceChargeAmount() { + return serviceChargeAmount; + } - public String getServiceChargeAmount() { - return serviceChargeAmount; - } + public void setServiceChargeAmount(String serviceChargeAmount) { + this.serviceChargeAmount = serviceChargeAmount; + } - public void setServiceChargeAmount(String serviceChargeAmount) { - this.serviceChargeAmount = serviceChargeAmount; - } + public long getTranId() { + return tranId; + } - public long getTranId() { - return tranId; - } + public void setTranId(long tranId) { + this.tranId = tranId; + } - public void setTranId(long tranId) { - this.tranId = tranId; - } + public String getTransferedAmount() { + return transferedAmount; + } - public String getTransferedAmount() { - return transferedAmount; - } + public void setTransferedAmount(String transferedAmount) { + this.transferedAmount = transferedAmount; + } - public void setTransferedAmount(String transferedAmount) { - this.transferedAmount = transferedAmount; - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("amount", amount) - .append("fromAsset", fromAsset) - .append("operateTime", operateTime) - .append("serviceChargeAmount", serviceChargeAmount) - .append("tranId", tranId) - .append("transderedAmount", transferedAmount) - .toString(); - } + @Override + public String toString() { + return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) + .append("amount", amount) + .append("fromAsset", fromAsset) + .append("operateTime", operateTime) + .append("serviceChargeAmount", serviceChargeAmount) + .append("tranId", tranId) + .append("transderedAmount", transferedAmount) + .toString(); + } } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/domain/account/WithdrawResult.java b/src/main/java/com/binance/api/client/domain/account/WithdrawResult.java index b9ebded80..0544af065 100755 --- a/src/main/java/com/binance/api/client/domain/account/WithdrawResult.java +++ b/src/main/java/com/binance/api/client/domain/account/WithdrawResult.java @@ -10,53 +10,53 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class WithdrawResult { - /** - * Withdraw message. - */ - private String msg; - - /** - * Withdraw success. - */ - private boolean success; - - /** - * Withdraw id. - */ - private String id; - - public String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } - - public boolean isSuccess() { - return success; - } - - public void setSuccess(boolean success) { - this.success = success; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - @Override - public String toString() { - return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) - .append("msg", msg) - .append("success", success) - .append("id", id) - .toString(); - } + /** + * Withdraw message. + */ + private String msg; + + /** + * Withdraw success. + */ + private boolean success; + + /** + * Withdraw id. + */ + private String id; + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) + .append("msg", msg) + .append("success", success) + .append("id", id) + .toString(); + } } diff --git a/src/main/java/com/binance/api/client/domain/account/request/AllOrderListRequest.java b/src/main/java/com/binance/api/client/domain/account/request/AllOrderListRequest.java index 6d7be4740..d5ad35a29 100755 --- a/src/main/java/com/binance/api/client/domain/account/request/AllOrderListRequest.java +++ b/src/main/java/com/binance/api/client/domain/account/request/AllOrderListRequest.java @@ -6,72 +6,72 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class AllOrderListRequest { - private static final Integer DEFAULT_LIMIT = 500; + private static final Integer DEFAULT_LIMIT = 500; - private Long fromId; + private Long fromId; - private Long startTime; + private Long startTime; - private Long endTime; + private Long endTime; - private Integer limit; + private Integer limit; - private Long recvWindow; + private Long recvWindow; - private Long timestamp; + private Long timestamp; - public AllOrderListRequest() { - this.limit = DEFAULT_LIMIT; - this.timestamp = System.currentTimeMillis(); - this.recvWindow = BinanceApiConstants.DEFAULT_RECEIVING_WINDOW; - } + public AllOrderListRequest() { + this.limit = DEFAULT_LIMIT; + this.timestamp = System.currentTimeMillis(); + this.recvWindow = BinanceApiConstants.DEFAULT_RECEIVING_WINDOW; + } - public Long getFromId() { - return fromId; - } + public Long getFromId() { + return fromId; + } - public void setFromId(Long fromId) { - this.fromId = fromId; - } + public void setFromId(Long fromId) { + this.fromId = fromId; + } - public Long getStartTime() { - return startTime; - } + public Long getStartTime() { + return startTime; + } - public void setStartTime(Long startTime) { - this.startTime = startTime; - } + public void setStartTime(Long startTime) { + this.startTime = startTime; + } - public Long getEndTime() { - return endTime; - } + public Long getEndTime() { + return endTime; + } - public void setEndTime(Long endTime) { - this.endTime = endTime; - } + public void setEndTime(Long endTime) { + this.endTime = endTime; + } - public Integer getLimit() { - return limit; - } + public Integer getLimit() { + return limit; + } - public void setLimit(Integer limit) { - this.limit = limit; - } + public void setLimit(Integer limit) { + this.limit = limit; + } - public Long getRecvWindow() { - return recvWindow; - } + public Long getRecvWindow() { + return recvWindow; + } - public void setRecvWindow(Long recvWindow) { - this.recvWindow = recvWindow; - } + public void setRecvWindow(Long recvWindow) { + this.recvWindow = recvWindow; + } - public Long getTimestamp() { - return timestamp; - } + public Long getTimestamp() { + return timestamp; + } - public void setTimestamp(Long timestamp) { - this.timestamp = timestamp; - } + public void setTimestamp(Long timestamp) { + this.timestamp = timestamp; + } } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/domain/account/request/CancelOrderListRequest.java b/src/main/java/com/binance/api/client/domain/account/request/CancelOrderListRequest.java index 07d057ba3..5adf29f64 100755 --- a/src/main/java/com/binance/api/client/domain/account/request/CancelOrderListRequest.java +++ b/src/main/java/com/binance/api/client/domain/account/request/CancelOrderListRequest.java @@ -6,78 +6,78 @@ public class CancelOrderListRequest { - private String symbol; + private String symbol; - private Long orderListId; + private Long orderListId; - private String listClientOrderId; + private String listClientOrderId; - /** - * Used to uniquely identify this cancel. Automatically generated by default - */ - private String newClientOrderId; + /** + * Used to uniquely identify this cancel. Automatically generated by default + */ + private String newClientOrderId; - private Long recvWindow; + private Long recvWindow; - private Long timestamp; + private Long timestamp; - public CancelOrderListRequest(String symbol) { - this.symbol = symbol; - this.timestamp = System.currentTimeMillis(); - this.recvWindow = BinanceApiConstants.DEFAULT_RECEIVING_WINDOW; - } + public CancelOrderListRequest(String symbol) { + this.symbol = symbol; + this.timestamp = System.currentTimeMillis(); + this.recvWindow = BinanceApiConstants.DEFAULT_RECEIVING_WINDOW; + } - public String getSymbol() { - return symbol; - } + public String getSymbol() { + return symbol; + } - public void setSymbol(String symbol) { - this.symbol = symbol; - } + public void setSymbol(String symbol) { + this.symbol = symbol; + } - public Long getOrderListId() { - return orderListId; - } + public Long getOrderListId() { + return orderListId; + } - public void setOrderListId(Long orderListId) { - this.orderListId = orderListId; - } + public void setOrderListId(Long orderListId) { + this.orderListId = orderListId; + } - public String getListClientOrderId() { - return listClientOrderId; - } + public String getListClientOrderId() { + return listClientOrderId; + } - public void setListClientOrderId(String listClientOrderId) { - this.listClientOrderId = listClientOrderId; - } + public void setListClientOrderId(String listClientOrderId) { + this.listClientOrderId = listClientOrderId; + } - public String getNewClientOrderId() { - return newClientOrderId; - } + public String getNewClientOrderId() { + return newClientOrderId; + } - public void setNewClientOrderId(String newClientOrderId) { - this.newClientOrderId = newClientOrderId; - } + public void setNewClientOrderId(String newClientOrderId) { + this.newClientOrderId = newClientOrderId; + } - public Long getRecvWindow() { - return recvWindow; - } + public Long getRecvWindow() { + return recvWindow; + } - public void setRecvWindow(Long recvWindow) { - this.recvWindow = recvWindow; - } + public void setRecvWindow(Long recvWindow) { + this.recvWindow = recvWindow; + } - public Long getTimestamp() { - return timestamp; - } + public Long getTimestamp() { + return timestamp; + } - public void setTimestamp(Long timestamp) { - this.timestamp = timestamp; - } + public void setTimestamp(Long timestamp) { + this.timestamp = timestamp; + } - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE).append("symbol", symbol).append("orderListId", orderListId).append("listClientOrderId", listClientOrderId).append("newClientOrderId", newClientOrderId).append("recvWindow", recvWindow).append("timestamp", timestamp).toString(); - } + @Override + public String toString() { + return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE).append("symbol", symbol).append("orderListId", orderListId).append("listClientOrderId", listClientOrderId).append("newClientOrderId", newClientOrderId).append("recvWindow", recvWindow).append("timestamp", timestamp).toString(); + } } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/domain/account/request/CancelOrderResponse.java b/src/main/java/com/binance/api/client/domain/account/request/CancelOrderResponse.java index 20fc07912..ec76125a8 100755 --- a/src/main/java/com/binance/api/client/domain/account/request/CancelOrderResponse.java +++ b/src/main/java/com/binance/api/client/domain/account/request/CancelOrderResponse.java @@ -80,10 +80,10 @@ public CancelOrderResponse setClientOrderId(String clientOrderId) { @Override public String toString() { return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("symbol", symbol) - .append("origClientOrderId", origClientOrderId) - .append("orderId", orderId) - .append("clientOrderId", clientOrderId) - .toString(); + .append("symbol", symbol) + .append("origClientOrderId", origClientOrderId) + .append("orderId", orderId) + .append("clientOrderId", clientOrderId) + .toString(); } } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/domain/account/request/OrderListStatusRequest.java b/src/main/java/com/binance/api/client/domain/account/request/OrderListStatusRequest.java index 648bf708b..cbe987b73 100755 --- a/src/main/java/com/binance/api/client/domain/account/request/OrderListStatusRequest.java +++ b/src/main/java/com/binance/api/client/domain/account/request/OrderListStatusRequest.java @@ -6,50 +6,50 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class OrderListStatusRequest { - private Long orderListId; + private Long orderListId; - private String origClientOrderId; + private String origClientOrderId; - private Long recvWindow; + private Long recvWindow; - private Long timestamp; + private Long timestamp; - public OrderListStatusRequest(Long orderListId) { - this.orderListId = orderListId; - this.timestamp = System.currentTimeMillis(); - this.recvWindow = BinanceApiConstants.DEFAULT_RECEIVING_WINDOW; - } + public OrderListStatusRequest(Long orderListId) { + this.orderListId = orderListId; + this.timestamp = System.currentTimeMillis(); + this.recvWindow = BinanceApiConstants.DEFAULT_RECEIVING_WINDOW; + } - public Long getOrderListId() { - return orderListId; - } + public Long getOrderListId() { + return orderListId; + } - public void setOrderListId(Long orderListId) { - this.orderListId = orderListId; - } + public void setOrderListId(Long orderListId) { + this.orderListId = orderListId; + } - public String getOrigClientOrderId() { - return origClientOrderId; - } + public String getOrigClientOrderId() { + return origClientOrderId; + } - public void setOrigClientOrderId(String origClientOrderId) { - this.origClientOrderId = origClientOrderId; - } + public void setOrigClientOrderId(String origClientOrderId) { + this.origClientOrderId = origClientOrderId; + } - public Long getRecvWindow() { - return recvWindow; - } + public Long getRecvWindow() { + return recvWindow; + } - public void setRecvWindow(Long recvWindow) { - this.recvWindow = recvWindow; - } + public void setRecvWindow(Long recvWindow) { + this.recvWindow = recvWindow; + } - public Long getTimestamp() { - return timestamp; - } + public Long getTimestamp() { + return timestamp; + } - public void setTimestamp(Long timestamp) { - this.timestamp = timestamp; - } + public void setTimestamp(Long timestamp) { + this.timestamp = timestamp; + } } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/domain/event/AccountUpdateEvent.java b/src/main/java/com/binance/api/client/domain/event/AccountUpdateEvent.java index e5a28c6e8..7c14e723e 100755 --- a/src/main/java/com/binance/api/client/domain/event/AccountUpdateEvent.java +++ b/src/main/java/com/binance/api/client/domain/event/AccountUpdateEvent.java @@ -11,7 +11,7 @@ /** * Account update event which will reflect the current position/balances of the account. - * + *

* This event is embedded as part of a user data update event. * * @see UserDataUpdateEvent diff --git a/src/main/java/com/binance/api/client/domain/event/BookTickerEvent.java b/src/main/java/com/binance/api/client/domain/event/BookTickerEvent.java index d3612194f..8ce05a888 100755 --- a/src/main/java/com/binance/api/client/domain/event/BookTickerEvent.java +++ b/src/main/java/com/binance/api/client/domain/event/BookTickerEvent.java @@ -12,101 +12,101 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class BookTickerEvent { - @JsonProperty("u") - private long updateId; - - @JsonProperty("s") - private String symbol; - - @JsonProperty("b") - private String bidPrice; - - @JsonProperty("B") - private String bidQuantity; - - @JsonProperty("a") - private String askPrice; - - @JsonProperty("A") - private String askQuantity; - - public BookTickerEvent() { - super(); - } - - public BookTickerEvent(long updateId, String symbol, String bidPrice, String bidQuantity, String askPrice, - String askQuantity) { - super(); - this.updateId = updateId; - this.symbol = symbol; - this.bidPrice = bidPrice; - this.bidQuantity = bidQuantity; - this.askPrice = askPrice; - this.askQuantity = askQuantity; - } - - public BookTickerEvent(String symbol, String bidPrice, String bidQuantity, String askPrice, String askQuantity) { - super(); - this.symbol = symbol; - this.bidPrice = bidPrice; - this.bidQuantity = bidQuantity; - this.askPrice = askPrice; - this.askQuantity = askQuantity; - } - - public long getUpdateId() { - return updateId; - } - - public void setUpdateId(long updateId) { - this.updateId = updateId; - } - - public String getSymbol() { - return symbol; - } - - public void setSymbol(String symbol) { - this.symbol = symbol; - } - - public String getBidPrice() { - return bidPrice; - } - - public void setBidPrice(String bidPrice) { - this.bidPrice = bidPrice; - } - - public String getBidQuantity() { - return bidQuantity; - } - - public void setBidQuantity(String bidQuantity) { - this.bidQuantity = bidQuantity; - } - - public String getAskPrice() { - return askPrice; - } - - public void setAskPrice(String askPrice) { - this.askPrice = askPrice; - } - - public String getAskQuantity() { - return askQuantity; - } - - public void setAskQuantity(String askQuantity) { - this.askQuantity = askQuantity; - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE).append("eventType", "BookTicker") - .append("updateId", updateId).append("symbol", symbol).append("bidPrice", bidPrice) - .append("bidQuantity", bidQuantity).append("askPrice", askPrice).append("askQuantity", askQuantity) - .toString(); - } + @JsonProperty("u") + private long updateId; + + @JsonProperty("s") + private String symbol; + + @JsonProperty("b") + private String bidPrice; + + @JsonProperty("B") + private String bidQuantity; + + @JsonProperty("a") + private String askPrice; + + @JsonProperty("A") + private String askQuantity; + + public BookTickerEvent() { + super(); + } + + public BookTickerEvent(long updateId, String symbol, String bidPrice, String bidQuantity, String askPrice, + String askQuantity) { + super(); + this.updateId = updateId; + this.symbol = symbol; + this.bidPrice = bidPrice; + this.bidQuantity = bidQuantity; + this.askPrice = askPrice; + this.askQuantity = askQuantity; + } + + public BookTickerEvent(String symbol, String bidPrice, String bidQuantity, String askPrice, String askQuantity) { + super(); + this.symbol = symbol; + this.bidPrice = bidPrice; + this.bidQuantity = bidQuantity; + this.askPrice = askPrice; + this.askQuantity = askQuantity; + } + + public long getUpdateId() { + return updateId; + } + + public void setUpdateId(long updateId) { + this.updateId = updateId; + } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + this.symbol = symbol; + } + + public String getBidPrice() { + return bidPrice; + } + + public void setBidPrice(String bidPrice) { + this.bidPrice = bidPrice; + } + + public String getBidQuantity() { + return bidQuantity; + } + + public void setBidQuantity(String bidQuantity) { + this.bidQuantity = bidQuantity; + } + + public String getAskPrice() { + return askPrice; + } + + public void setAskPrice(String askPrice) { + this.askPrice = askPrice; + } + + public String getAskQuantity() { + return askQuantity; + } + + public void setAskQuantity(String askQuantity) { + this.askQuantity = askQuantity; + } + + @Override + public String toString() { + return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE).append("eventType", "BookTicker") + .append("updateId", updateId).append("symbol", symbol).append("bidPrice", bidPrice) + .append("bidQuantity", bidQuantity).append("askPrice", askPrice).append("askQuantity", askQuantity) + .toString(); + } } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/domain/event/CandlestickEventSerializer.java b/src/main/java/com/binance/api/client/domain/event/CandlestickEventSerializer.java index 2ceb99956..e4a022997 100755 --- a/src/main/java/com/binance/api/client/domain/event/CandlestickEventSerializer.java +++ b/src/main/java/com/binance/api/client/domain/event/CandlestickEventSerializer.java @@ -16,12 +16,12 @@ public class CandlestickEventSerializer extends JsonSerializer @Override public void serialize(CandlestickEvent candlestickEvent, JsonGenerator gen, SerializerProvider serializers) throws IOException { gen.writeStartObject(); - + // Write header gen.writeStringField("e", candlestickEvent.getEventType()); gen.writeNumberField("E", candlestickEvent.getEventTime()); gen.writeStringField("s", candlestickEvent.getSymbol()); - + // Write candlestick data gen.writeObjectFieldStart("k"); gen.writeNumberField("t", candlestickEvent.getOpenTime()); diff --git a/src/main/java/com/binance/api/client/domain/event/TickerEvent.java b/src/main/java/com/binance/api/client/domain/event/TickerEvent.java index c0c7e97f1..fa89287dd 100755 --- a/src/main/java/com/binance/api/client/domain/event/TickerEvent.java +++ b/src/main/java/com/binance/api/client/domain/event/TickerEvent.java @@ -11,285 +11,285 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class TickerEvent { - @JsonProperty("e") - private String eventType; + @JsonProperty("e") + private String eventType; - @JsonProperty("E") - private long eventTime; + @JsonProperty("E") + private long eventTime; - @JsonProperty("s") - private String symbol; + @JsonProperty("s") + private String symbol; - @JsonProperty("p") - private String priceChange; + @JsonProperty("p") + private String priceChange; - @JsonProperty("P") - private String priceChangePercent; + @JsonProperty("P") + private String priceChangePercent; - @JsonProperty("w") - private String weightedAveragePrice; + @JsonProperty("w") + private String weightedAveragePrice; - @JsonProperty("x") - private String previousDaysClosePrice; + @JsonProperty("x") + private String previousDaysClosePrice; - @JsonProperty("c") - private String currentDaysClosePrice; + @JsonProperty("c") + private String currentDaysClosePrice; - @JsonProperty("Q") - private String closeTradesQuantity; + @JsonProperty("Q") + private String closeTradesQuantity; - @JsonProperty("b") - private String bestBidPrice; + @JsonProperty("b") + private String bestBidPrice; - @JsonProperty("B") - private String bestBidQuantity; + @JsonProperty("B") + private String bestBidQuantity; - @JsonProperty("a") - private String bestAskPrice; + @JsonProperty("a") + private String bestAskPrice; - @JsonProperty("A") - private String bestAskQuantity; + @JsonProperty("A") + private String bestAskQuantity; - @JsonProperty("o") - private String openPrice; + @JsonProperty("o") + private String openPrice; - @JsonProperty("h") - private String highPrice; + @JsonProperty("h") + private String highPrice; - @JsonProperty("l") - private String lowPrice; + @JsonProperty("l") + private String lowPrice; - @JsonProperty("v") - private String totalTradedBaseAssetVolume; + @JsonProperty("v") + private String totalTradedBaseAssetVolume; - @JsonProperty("q") - private String totalTradedQuoteAssetVolume; + @JsonProperty("q") + private String totalTradedQuoteAssetVolume; - @JsonProperty("O") - private long statisticsOpenTime; + @JsonProperty("O") + private long statisticsOpenTime; - @JsonProperty("C") - private long statisticsCloseTime; + @JsonProperty("C") + private long statisticsCloseTime; - @JsonProperty("F") - private long firstTradeId; + @JsonProperty("F") + private long firstTradeId; - @JsonProperty("L") - private long lastTradeId; + @JsonProperty("L") + private long lastTradeId; - @JsonProperty("n") - private long totalNumberOfTrades; + @JsonProperty("n") + private long totalNumberOfTrades; - public String getEventType() { - return eventType; - } + public String getEventType() { + return eventType; + } - public void setEventType(String eventType) { - this.eventType = eventType; - } + public void setEventType(String eventType) { + this.eventType = eventType; + } - public long getEventTime() { - return eventTime; - } + public long getEventTime() { + return eventTime; + } - public void setEventTime(long eventTime) { - this.eventTime = eventTime; - } + public void setEventTime(long eventTime) { + this.eventTime = eventTime; + } - public String getSymbol() { - return symbol; - } + public String getSymbol() { + return symbol; + } - public void setSymbol(String symbol) { - this.symbol = symbol; - } + public void setSymbol(String symbol) { + this.symbol = symbol; + } - public String getPriceChange() { - return priceChange; - } + public String getPriceChange() { + return priceChange; + } - public void setPriceChange(String priceChange) { - this.priceChange = priceChange; - } + public void setPriceChange(String priceChange) { + this.priceChange = priceChange; + } - public String getPriceChangePercent() { - return priceChangePercent; - } + public String getPriceChangePercent() { + return priceChangePercent; + } - public void setPriceChangePercent(String priceChangePercent) { - this.priceChangePercent = priceChangePercent; - } + public void setPriceChangePercent(String priceChangePercent) { + this.priceChangePercent = priceChangePercent; + } - public String getWeightedAveragePrice() { - return weightedAveragePrice; - } + public String getWeightedAveragePrice() { + return weightedAveragePrice; + } - public void setWeightedAveragePrice(String weightedAveragePrice) { - this.weightedAveragePrice = weightedAveragePrice; - } + public void setWeightedAveragePrice(String weightedAveragePrice) { + this.weightedAveragePrice = weightedAveragePrice; + } - public String getPreviousDaysClosePrice() { - return previousDaysClosePrice; - } + public String getPreviousDaysClosePrice() { + return previousDaysClosePrice; + } - public void setPreviousDaysClosePrice(String previousDaysClosePrice) { - this.previousDaysClosePrice = previousDaysClosePrice; - } + public void setPreviousDaysClosePrice(String previousDaysClosePrice) { + this.previousDaysClosePrice = previousDaysClosePrice; + } - public String getCurrentDaysClosePrice() { - return currentDaysClosePrice; - } + public String getCurrentDaysClosePrice() { + return currentDaysClosePrice; + } - public void setCurrentDaysClosePrice(String currentDaysClosePrice) { - this.currentDaysClosePrice = currentDaysClosePrice; - } + public void setCurrentDaysClosePrice(String currentDaysClosePrice) { + this.currentDaysClosePrice = currentDaysClosePrice; + } - public String getCloseTradesQuantity() { - return closeTradesQuantity; - } + public String getCloseTradesQuantity() { + return closeTradesQuantity; + } - public void setCloseTradesQuantity(String closeTradesQuantity) { - this.closeTradesQuantity = closeTradesQuantity; - } + public void setCloseTradesQuantity(String closeTradesQuantity) { + this.closeTradesQuantity = closeTradesQuantity; + } - public String getBestBidPrice() { - return bestBidPrice; - } + public String getBestBidPrice() { + return bestBidPrice; + } - public void setBestBidPrice(String bestBidPrice) { - this.bestBidPrice = bestBidPrice; - } + public void setBestBidPrice(String bestBidPrice) { + this.bestBidPrice = bestBidPrice; + } - public String getBestBidQuantity() { - return bestBidQuantity; - } + public String getBestBidQuantity() { + return bestBidQuantity; + } - public void setBestBidQuantity(String bestBidQuantity) { - this.bestBidQuantity = bestBidQuantity; - } + public void setBestBidQuantity(String bestBidQuantity) { + this.bestBidQuantity = bestBidQuantity; + } - public String getBestAskPrice() { - return bestAskPrice; - } - - public void setBestAskPrice(String bestAskPrice) { - this.bestAskPrice = bestAskPrice; - } - - public String getBestAskQuantity() { - return bestAskQuantity; - } - - public void setBestAskQuantity(String bestAskQuantity) { - this.bestAskQuantity = bestAskQuantity; - } - - public String getOpenPrice() { - return openPrice; - } - - public void setOpenPrice(String openPrice) { - this.openPrice = openPrice; - } - - public String getHighPrice() { - return highPrice; - } - - public void setHighPrice(String highPrice) { - this.highPrice = highPrice; - } - - public String getLowPrice() { - return lowPrice; - } - - public void setLowPrice(String lowPrice) { - this.lowPrice = lowPrice; - } - - public String getTotalTradedBaseAssetVolume() { - return totalTradedBaseAssetVolume; - } - - public void setTotalTradedBaseAssetVolume(String totalTradedBaseAssetVolume) { - this.totalTradedBaseAssetVolume = totalTradedBaseAssetVolume; - } - - public String getTotalTradedQuoteAssetVolume() { - return totalTradedQuoteAssetVolume; - } - - public void setTotalTradedQuoteAssetVolume(String totalTradedQuoteAssetVolume) { - this.totalTradedQuoteAssetVolume = totalTradedQuoteAssetVolume; - } - - public long getStatisticsOpenTime() { - return statisticsOpenTime; - } - - public void setStatisticsOpenTime(long statisticsOpenTime) { - this.statisticsOpenTime = statisticsOpenTime; - } - - public long getStatisticsCloseTime() { - return statisticsCloseTime; - } - - public void setStatisticsCloseTime(long statisticsCloseTime) { - this.statisticsCloseTime = statisticsCloseTime; - } - - public long getFirstTradeId() { - return firstTradeId; - } - - public void setFirstTradeId(long firstTradeId) { - this.firstTradeId = firstTradeId; - } - - public long getLastTradeId() { - return lastTradeId; - } - - public void setLastTradeId(long lastTradeId) { - this.lastTradeId = lastTradeId; - } - - public long getTotalNumberOfTrades() { - return totalNumberOfTrades; - } - - public void setTotalNumberOfTrades(long totalNumberOfTrades) { - this.totalNumberOfTrades = totalNumberOfTrades; - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("eventType", eventType) - .append("eventTime", eventTime) - .append("symbol", symbol) - .append("priceChange", priceChange) - .append("priceChangePercent", priceChangePercent) - .append("weightedAveragePrice", weightedAveragePrice) - .append("previousDaysClosePrice", previousDaysClosePrice) - .append("currentDaysClosePrice", currentDaysClosePrice) - .append("closeTradesQuantity", closeTradesQuantity) - .append("bestBidPrice", bestBidPrice) - .append("bestBidQuantity", bestBidQuantity) - .append("bestAskPrice", bestAskPrice) - .append("bestAskQuantity", bestAskQuantity) - .append("openPrice", openPrice) - .append("highPrice", highPrice) - .append("lowPrice", lowPrice) - .append("totalTradedBaseAssetVolume", totalTradedBaseAssetVolume) - .append("totalTradedQuoteAssetVolume", totalTradedQuoteAssetVolume) - .append("statisticsOpenTime", statisticsOpenTime) - .append("statisticsCloseTime", statisticsCloseTime) - .append("firstTradeId", firstTradeId) - .append("lastTradeId", lastTradeId) - .append("totalNumberOfTrades", totalNumberOfTrades) - .toString(); - } + public String getBestAskPrice() { + return bestAskPrice; + } + + public void setBestAskPrice(String bestAskPrice) { + this.bestAskPrice = bestAskPrice; + } + + public String getBestAskQuantity() { + return bestAskQuantity; + } + + public void setBestAskQuantity(String bestAskQuantity) { + this.bestAskQuantity = bestAskQuantity; + } + + public String getOpenPrice() { + return openPrice; + } + + public void setOpenPrice(String openPrice) { + this.openPrice = openPrice; + } + + public String getHighPrice() { + return highPrice; + } + + public void setHighPrice(String highPrice) { + this.highPrice = highPrice; + } + + public String getLowPrice() { + return lowPrice; + } + + public void setLowPrice(String lowPrice) { + this.lowPrice = lowPrice; + } + + public String getTotalTradedBaseAssetVolume() { + return totalTradedBaseAssetVolume; + } + + public void setTotalTradedBaseAssetVolume(String totalTradedBaseAssetVolume) { + this.totalTradedBaseAssetVolume = totalTradedBaseAssetVolume; + } + + public String getTotalTradedQuoteAssetVolume() { + return totalTradedQuoteAssetVolume; + } + + public void setTotalTradedQuoteAssetVolume(String totalTradedQuoteAssetVolume) { + this.totalTradedQuoteAssetVolume = totalTradedQuoteAssetVolume; + } + + public long getStatisticsOpenTime() { + return statisticsOpenTime; + } + + public void setStatisticsOpenTime(long statisticsOpenTime) { + this.statisticsOpenTime = statisticsOpenTime; + } + + public long getStatisticsCloseTime() { + return statisticsCloseTime; + } + + public void setStatisticsCloseTime(long statisticsCloseTime) { + this.statisticsCloseTime = statisticsCloseTime; + } + + public long getFirstTradeId() { + return firstTradeId; + } + + public void setFirstTradeId(long firstTradeId) { + this.firstTradeId = firstTradeId; + } + + public long getLastTradeId() { + return lastTradeId; + } + + public void setLastTradeId(long lastTradeId) { + this.lastTradeId = lastTradeId; + } + + public long getTotalNumberOfTrades() { + return totalNumberOfTrades; + } + + public void setTotalNumberOfTrades(long totalNumberOfTrades) { + this.totalNumberOfTrades = totalNumberOfTrades; + } + + @Override + public String toString() { + return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) + .append("eventType", eventType) + .append("eventTime", eventTime) + .append("symbol", symbol) + .append("priceChange", priceChange) + .append("priceChangePercent", priceChangePercent) + .append("weightedAveragePrice", weightedAveragePrice) + .append("previousDaysClosePrice", previousDaysClosePrice) + .append("currentDaysClosePrice", currentDaysClosePrice) + .append("closeTradesQuantity", closeTradesQuantity) + .append("bestBidPrice", bestBidPrice) + .append("bestBidQuantity", bestBidQuantity) + .append("bestAskPrice", bestAskPrice) + .append("bestAskQuantity", bestAskQuantity) + .append("openPrice", openPrice) + .append("highPrice", highPrice) + .append("lowPrice", lowPrice) + .append("totalTradedBaseAssetVolume", totalTradedBaseAssetVolume) + .append("totalTradedQuoteAssetVolume", totalTradedQuoteAssetVolume) + .append("statisticsOpenTime", statisticsOpenTime) + .append("statisticsCloseTime", statisticsCloseTime) + .append("firstTradeId", firstTradeId) + .append("lastTradeId", lastTradeId) + .append("totalNumberOfTrades", totalNumberOfTrades) + .toString(); + } } diff --git a/src/main/java/com/binance/api/client/domain/event/UserDataUpdateEvent.java b/src/main/java/com/binance/api/client/domain/event/UserDataUpdateEvent.java index 062565790..4164b2de0 100755 --- a/src/main/java/com/binance/api/client/domain/event/UserDataUpdateEvent.java +++ b/src/main/java/com/binance/api/client/domain/event/UserDataUpdateEvent.java @@ -94,11 +94,17 @@ public String toString() { } public enum UserDataUpdateEventType { - /** Corresponds to "outboundAccountPosition" events. */ + /** + * Corresponds to "outboundAccountPosition" events. + */ ACCOUNT_POSITION_UPDATE("outboundAccountPosition"), - /** Corresponds to "balanceUpdate" events. */ + /** + * Corresponds to "balanceUpdate" events. + */ BALANCE_UPDATE("balanceUpdate"), - /** Corresponds to "executionReport" events. */ + /** + * Corresponds to "executionReport" events. + */ ORDER_TRADE_UPDATE("executionReport"), ; diff --git a/src/main/java/com/binance/api/client/domain/general/Asset.java b/src/main/java/com/binance/api/client/domain/general/Asset.java index 715190f31..133d97b06 100755 --- a/src/main/java/com/binance/api/client/domain/general/Asset.java +++ b/src/main/java/com/binance/api/client/domain/general/Asset.java @@ -8,116 +8,116 @@ /** * An asset Binance supports. */ - @JsonIgnoreProperties(ignoreUnknown = true) - public class Asset { +@JsonIgnoreProperties(ignoreUnknown = true) +public class Asset { - @JsonProperty("id") - private String id; + @JsonProperty("id") + private String id; - @JsonProperty("assetCode") - private String assetCode; + @JsonProperty("assetCode") + private String assetCode; - @JsonProperty("assetName") - private String assetName; - - @JsonProperty("unit") - private String unit; - - @JsonProperty("transactionFee") - private String transactionFee; - - @JsonProperty("commissionRate") - private String commissionRate; - - @JsonProperty("freeAuditWithdrawAmt") - private String freeAuditWithdrawAmount; - - @JsonProperty("freeUserChargeAmount") - private String freeUserChargeAmount; - - @JsonProperty("minProductWithdraw") - private String minProductWithdraw; - - @JsonProperty("withdrawIntegerMultiple") - private String withdrawIntegerMultiple; - - @JsonProperty("confirmTimes") - private long confirmTimes; - - @JsonProperty("enableWithdraw") - private boolean enableWithdraw; - - @JsonProperty("isLegalMoney") - private boolean isLegalMoney; - - public String getId() { - return id; - } - - public String getAssetCode() { - return assetCode; - } - - public String getAssetName() { - return assetName; - } - - public String getUnit() { - return unit; - } - - public String getTransactionFee() { - return transactionFee; - } - - public String getCommissionRate() { - return commissionRate; - } - - public String getFreeAuditWithdrawAmount() { - return freeAuditWithdrawAmount; - } - - public String getFreeUserChargeAmount() { - return freeUserChargeAmount; - } - - public String minProductWithdraw() { - return minProductWithdraw; - } - - public String getWithdrawIntegerMultiple() { - return withdrawIntegerMultiple; - } - - public long getConfirmTimes() { - return confirmTimes; - } - - public boolean canWithraw() { - return enableWithdraw; - } - - public boolean isLegalMoney() { - return isLegalMoney; - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("id", id) - .append("assetCode", assetCode) - .append("assetName", assetName) - .append("unit", unit) - .append("transactionFee", transactionFee) - .append("commissionRate", commissionRate) - .append("freeAuditWithdrawAmount", freeAuditWithdrawAmount) - .append("freeUserChargeAmount", freeUserChargeAmount) - .append("minProductWithdraw", minProductWithdraw) - .append("withdrawIntegerMultiple", withdrawIntegerMultiple) - .append("confirmTimes", confirmTimes) - .append("enableWithdraw", enableWithdraw) - .append("isLegalMoney", isLegalMoney) - .toString(); - } - } + @JsonProperty("assetName") + private String assetName; + + @JsonProperty("unit") + private String unit; + + @JsonProperty("transactionFee") + private String transactionFee; + + @JsonProperty("commissionRate") + private String commissionRate; + + @JsonProperty("freeAuditWithdrawAmt") + private String freeAuditWithdrawAmount; + + @JsonProperty("freeUserChargeAmount") + private String freeUserChargeAmount; + + @JsonProperty("minProductWithdraw") + private String minProductWithdraw; + + @JsonProperty("withdrawIntegerMultiple") + private String withdrawIntegerMultiple; + + @JsonProperty("confirmTimes") + private long confirmTimes; + + @JsonProperty("enableWithdraw") + private boolean enableWithdraw; + + @JsonProperty("isLegalMoney") + private boolean isLegalMoney; + + public String getId() { + return id; + } + + public String getAssetCode() { + return assetCode; + } + + public String getAssetName() { + return assetName; + } + + public String getUnit() { + return unit; + } + + public String getTransactionFee() { + return transactionFee; + } + + public String getCommissionRate() { + return commissionRate; + } + + public String getFreeAuditWithdrawAmount() { + return freeAuditWithdrawAmount; + } + + public String getFreeUserChargeAmount() { + return freeUserChargeAmount; + } + + public String minProductWithdraw() { + return minProductWithdraw; + } + + public String getWithdrawIntegerMultiple() { + return withdrawIntegerMultiple; + } + + public long getConfirmTimes() { + return confirmTimes; + } + + public boolean canWithraw() { + return enableWithdraw; + } + + public boolean isLegalMoney() { + return isLegalMoney; + } + + @Override + public String toString() { + return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) + .append("id", id) + .append("assetCode", assetCode) + .append("assetName", assetName) + .append("unit", unit) + .append("transactionFee", transactionFee) + .append("commissionRate", commissionRate) + .append("freeAuditWithdrawAmount", freeAuditWithdrawAmount) + .append("freeUserChargeAmount", freeUserChargeAmount) + .append("minProductWithdraw", minProductWithdraw) + .append("withdrawIntegerMultiple", withdrawIntegerMultiple) + .append("confirmTimes", confirmTimes) + .append("enableWithdraw", enableWithdraw) + .append("isLegalMoney", isLegalMoney) + .toString(); + } +} diff --git a/src/main/java/com/binance/api/client/domain/general/ExchangeFilter.java b/src/main/java/com/binance/api/client/domain/general/ExchangeFilter.java index e367deaef..ce92e392d 100755 --- a/src/main/java/com/binance/api/client/domain/general/ExchangeFilter.java +++ b/src/main/java/com/binance/api/client/domain/general/ExchangeFilter.java @@ -6,9 +6,9 @@ /** * Exchange Filters define trading rules an exchange. - * + *

* The MAX_NUM_ORDERS filter defines the maximum number of orders an account is allowed to have open on the exchange. Note that both "algo" orders and normal orders are counted for this filter. - * + *

* The MAX_ALGO_ORDERS filter defines the maximum number of "algo" orders an account is allowed to have open on the exchange. "Algo" orders are STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders. */ @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/src/main/java/com/binance/api/client/domain/general/SymbolFilter.java b/src/main/java/com/binance/api/client/domain/general/SymbolFilter.java index e6a8b98c8..6b3e48e87 100755 --- a/src/main/java/com/binance/api/client/domain/general/SymbolFilter.java +++ b/src/main/java/com/binance/api/client/domain/general/SymbolFilter.java @@ -4,15 +4,15 @@ /** * Filters define trading rules on a symbol or an exchange. Filters come in two forms: symbol filters and exchange filters. - * + *

* The PRICE_FILTER defines the price rules for a symbol. - * + *

* The LOT_SIZE filter defines the quantity (aka "lots" in auction terms) rules for a symbol. - * + *

* The MIN_NOTIONAL filter defines the minimum notional value allowed for an order on a symbol. An order's notional value is the price * quantity. - * + *

* The MAX_NUM_ORDERS filter defines the maximum number of orders an account is allowed to have open on a symbol. Note that both "algo" orders and normal orders are counted for this filter. - * + *

* The MAX_ALGO_ORDERS filter defines the maximum number of "algo" orders an account is allowed to have open on a symbol. "Algo" orders are STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders. */ @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/src/main/java/com/binance/api/client/domain/market/OrderBookEntrySerializer.java b/src/main/java/com/binance/api/client/domain/market/OrderBookEntrySerializer.java index 132f8914a..b17ba9b83 100755 --- a/src/main/java/com/binance/api/client/domain/market/OrderBookEntrySerializer.java +++ b/src/main/java/com/binance/api/client/domain/market/OrderBookEntrySerializer.java @@ -12,7 +12,7 @@ public class OrderBookEntrySerializer extends JsonSerializer { @Override - public void serialize(OrderBookEntry orderBookEntry, JsonGenerator gen, SerializerProvider serializers) throws IOException { + public void serialize(OrderBookEntry orderBookEntry, JsonGenerator gen, SerializerProvider serializers) throws IOException { gen.writeStartArray(); gen.writeString(orderBookEntry.getPrice()); gen.writeString(orderBookEntry.getQty()); diff --git a/src/main/java/com/binance/api/client/domain/market/TickerStatistics.java b/src/main/java/com/binance/api/client/domain/market/TickerStatistics.java index 7cd3a08ca..b8b721e38 100755 --- a/src/main/java/com/binance/api/client/domain/market/TickerStatistics.java +++ b/src/main/java/com/binance/api/client/domain/market/TickerStatistics.java @@ -222,13 +222,13 @@ public long getCount() { public void setCount(long count) { this.count = count; } - + public String getSymbol() { - return symbol; + return symbol; } public void setSymbol(String symbol) { - this.symbol = symbol; + this.symbol = symbol; } @Override diff --git a/src/main/java/com/binance/api/client/exception/BinanceApiException.java b/src/main/java/com/binance/api/client/exception/BinanceApiException.java index 80430fd8d..7cbe556cb 100755 --- a/src/main/java/com/binance/api/client/exception/BinanceApiException.java +++ b/src/main/java/com/binance/api/client/exception/BinanceApiException.java @@ -7,8 +7,8 @@ */ public class BinanceApiException extends RuntimeException { - private static final long serialVersionUID = 3788669840036201041L; -/** + private static final long serialVersionUID = 3788669840036201041L; + /** * Error response object returned by Binance API. */ private BinanceApiError error; @@ -51,7 +51,7 @@ public BinanceApiException(Throwable cause) { * Instantiates a new binance api exception. * * @param message the message - * @param cause the cause + * @param cause the cause */ public BinanceApiException(String message, Throwable cause) { super(message, cause); diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncMarginRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncMarginRestClientImpl.java index d3e5c22f6..a0821df80 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncMarginRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncMarginRestClientImpl.java @@ -20,84 +20,84 @@ */ public class BinanceApiAsyncMarginRestClientImpl implements BinanceApiAsyncMarginRestClient { - private final BinanceApiService binanceApiService; - - public BinanceApiAsyncMarginRestClientImpl(String apiKey, String secret) { - binanceApiService = createService(BinanceApiService.class, apiKey, secret); - } - - // Margin Account endpoints - - @Override - public void getAccount(Long recvWindow, Long timestamp, BinanceApiCallback callback) { - binanceApiService.getMarginAccount(recvWindow, timestamp).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void getAccount(BinanceApiCallback callback) { - long timestamp = System.currentTimeMillis(); - binanceApiService.getMarginAccount(BinanceApiConstants.DEFAULT_MARGIN_RECEIVING_WINDOW, timestamp).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void getOpenOrders(OrderRequest orderRequest, BinanceApiCallback> callback) { - binanceApiService.getOpenMarginOrders(orderRequest.getSymbol(), orderRequest.getRecvWindow(), - orderRequest.getTimestamp()).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void newOrder(MarginNewOrder order, BinanceApiCallback callback) { - binanceApiService.newMarginOrder(order.getSymbol(), order.getSide(), order.getType(), order.getTimeInForce(), - order.getQuantity(), order.getPrice(), order.getNewClientOrderId(), order.getStopPrice(), order.getIcebergQty(), - order.getNewOrderRespType(), order.getSideEffectType(), order.getRecvWindow(), order.getTimestamp()).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void cancelOrder(CancelOrderRequest cancelOrderRequest, BinanceApiCallback callback) { - binanceApiService.cancelMarginOrder(cancelOrderRequest.getSymbol(), - cancelOrderRequest.getOrderId(), cancelOrderRequest.getOrigClientOrderId(), cancelOrderRequest.getNewClientOrderId(), - cancelOrderRequest.getRecvWindow(), cancelOrderRequest.getTimestamp()).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void getOrderStatus(OrderStatusRequest orderStatusRequest, BinanceApiCallback callback) { - binanceApiService.getMarginOrderStatus(orderStatusRequest.getSymbol(), - orderStatusRequest.getOrderId(), orderStatusRequest.getOrigClientOrderId(), - orderStatusRequest.getRecvWindow(), orderStatusRequest.getTimestamp()).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void getMyTrades(String symbol, BinanceApiCallback> callback) { - binanceApiService.getMyTrades(symbol, null, null, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - // user stream endpoints - - @Override - public void startUserDataStream(BinanceApiCallback callback) { - binanceApiService.startMarginUserDataStream().enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void keepAliveUserDataStream(String listenKey, BinanceApiCallback callback) { - binanceApiService.keepAliveMarginUserDataStream(listenKey).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void transfer(String asset, String amount, TransferType type, BinanceApiCallback callback) { - long timestamp = System.currentTimeMillis(); - binanceApiService.transfer(asset, amount, type.getValue(), BinanceApiConstants.DEFAULT_MARGIN_RECEIVING_WINDOW, timestamp).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void borrow(String asset, String amount, BinanceApiCallback callback) { - long timestamp = System.currentTimeMillis(); - binanceApiService.borrow(asset, amount, BinanceApiConstants.DEFAULT_MARGIN_RECEIVING_WINDOW, timestamp).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void repay(String asset, String amount, BinanceApiCallback callback) { - long timestamp = System.currentTimeMillis(); - binanceApiService.repay(asset, amount, BinanceApiConstants.DEFAULT_MARGIN_RECEIVING_WINDOW, timestamp).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } + private final BinanceApiService binanceApiService; + + public BinanceApiAsyncMarginRestClientImpl(String apiKey, String secret) { + binanceApiService = createService(BinanceApiService.class, apiKey, secret); + } + + // Margin Account endpoints + + @Override + public void getAccount(Long recvWindow, Long timestamp, BinanceApiCallback callback) { + binanceApiService.getMarginAccount(recvWindow, timestamp).enqueue(new BinanceApiCallbackAdapter<>(callback)); + } + + @Override + public void getAccount(BinanceApiCallback callback) { + long timestamp = System.currentTimeMillis(); + binanceApiService.getMarginAccount(BinanceApiConstants.DEFAULT_MARGIN_RECEIVING_WINDOW, timestamp).enqueue(new BinanceApiCallbackAdapter<>(callback)); + } + + @Override + public void getOpenOrders(OrderRequest orderRequest, BinanceApiCallback> callback) { + binanceApiService.getOpenMarginOrders(orderRequest.getSymbol(), orderRequest.getRecvWindow(), + orderRequest.getTimestamp()).enqueue(new BinanceApiCallbackAdapter<>(callback)); + } + + @Override + public void newOrder(MarginNewOrder order, BinanceApiCallback callback) { + binanceApiService.newMarginOrder(order.getSymbol(), order.getSide(), order.getType(), order.getTimeInForce(), + order.getQuantity(), order.getPrice(), order.getNewClientOrderId(), order.getStopPrice(), order.getIcebergQty(), + order.getNewOrderRespType(), order.getSideEffectType(), order.getRecvWindow(), order.getTimestamp()).enqueue(new BinanceApiCallbackAdapter<>(callback)); + } + + @Override + public void cancelOrder(CancelOrderRequest cancelOrderRequest, BinanceApiCallback callback) { + binanceApiService.cancelMarginOrder(cancelOrderRequest.getSymbol(), + cancelOrderRequest.getOrderId(), cancelOrderRequest.getOrigClientOrderId(), cancelOrderRequest.getNewClientOrderId(), + cancelOrderRequest.getRecvWindow(), cancelOrderRequest.getTimestamp()).enqueue(new BinanceApiCallbackAdapter<>(callback)); + } + + @Override + public void getOrderStatus(OrderStatusRequest orderStatusRequest, BinanceApiCallback callback) { + binanceApiService.getMarginOrderStatus(orderStatusRequest.getSymbol(), + orderStatusRequest.getOrderId(), orderStatusRequest.getOrigClientOrderId(), + orderStatusRequest.getRecvWindow(), orderStatusRequest.getTimestamp()).enqueue(new BinanceApiCallbackAdapter<>(callback)); + } + + @Override + public void getMyTrades(String symbol, BinanceApiCallback> callback) { + binanceApiService.getMyTrades(symbol, null, null, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()).enqueue(new BinanceApiCallbackAdapter<>(callback)); + } + + // user stream endpoints + + @Override + public void startUserDataStream(BinanceApiCallback callback) { + binanceApiService.startMarginUserDataStream().enqueue(new BinanceApiCallbackAdapter<>(callback)); + } + + @Override + public void keepAliveUserDataStream(String listenKey, BinanceApiCallback callback) { + binanceApiService.keepAliveMarginUserDataStream(listenKey).enqueue(new BinanceApiCallbackAdapter<>(callback)); + } + + @Override + public void transfer(String asset, String amount, TransferType type, BinanceApiCallback callback) { + long timestamp = System.currentTimeMillis(); + binanceApiService.transfer(asset, amount, type.getValue(), BinanceApiConstants.DEFAULT_MARGIN_RECEIVING_WINDOW, timestamp).enqueue(new BinanceApiCallbackAdapter<>(callback)); + } + + @Override + public void borrow(String asset, String amount, BinanceApiCallback callback) { + long timestamp = System.currentTimeMillis(); + binanceApiService.borrow(asset, amount, BinanceApiConstants.DEFAULT_MARGIN_RECEIVING_WINDOW, timestamp).enqueue(new BinanceApiCallbackAdapter<>(callback)); + } + + @Override + public void repay(String asset, String amount, BinanceApiCallback callback) { + long timestamp = System.currentTimeMillis(); + binanceApiService.repay(asset, amount, BinanceApiConstants.DEFAULT_MARGIN_RECEIVING_WINDOW, timestamp).enqueue(new BinanceApiCallbackAdapter<>(callback)); + } } diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java index e6ea387b9..149cc7bc2 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java @@ -122,7 +122,7 @@ public void getAllPrices(BinanceApiCallback> callback) { } @Override - public void getPrice(String symbol , BinanceApiCallback callback) { + public void getPrice(String symbol, BinanceApiCallback callback) { binanceApiService.getLatestPrice(symbol).enqueue(new BinanceApiCallbackAdapter<>(callback)); } diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiMarginRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiMarginRestClientImpl.java index 959fa2a5f..fe7830559 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiMarginRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiMarginRestClientImpl.java @@ -19,101 +19,101 @@ */ public class BinanceApiMarginRestClientImpl implements BinanceApiMarginRestClient { - private final BinanceApiService binanceApiService; - - public BinanceApiMarginRestClientImpl(String apiKey, String secret) { - binanceApiService = createService(BinanceApiService.class, apiKey, secret); - } - - @Override - public MarginAccount getAccount() { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.getMarginAccount(BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, timestamp)); - } - - @Override - public List getOpenOrders(OrderRequest orderRequest) { - return executeSync(binanceApiService.getOpenMarginOrders(orderRequest.getSymbol(), orderRequest.getRecvWindow(), - orderRequest.getTimestamp())); - } - - @Override - public MarginNewOrderResponse newOrder(MarginNewOrder order) { - return executeSync(binanceApiService.newMarginOrder(order.getSymbol(), order.getSide(), order.getType(), - order.getTimeInForce(), order.getQuantity(), order.getPrice(), order.getNewClientOrderId(), order.getStopPrice(), - order.getIcebergQty(), order.getNewOrderRespType(), order.getSideEffectType(), order.getRecvWindow(), order.getTimestamp())); - } - - @Override - public CancelOrderResponse cancelOrder(CancelOrderRequest cancelOrderRequest) { - return executeSync(binanceApiService.cancelMarginOrder(cancelOrderRequest.getSymbol(), - cancelOrderRequest.getOrderId(), cancelOrderRequest.getOrigClientOrderId(), cancelOrderRequest.getNewClientOrderId(), - cancelOrderRequest.getRecvWindow(), cancelOrderRequest.getTimestamp())); - } - - @Override - public Order getOrderStatus(OrderStatusRequest orderStatusRequest) { - return executeSync(binanceApiService.getMarginOrderStatus(orderStatusRequest.getSymbol(), - orderStatusRequest.getOrderId(), orderStatusRequest.getOrigClientOrderId(), - orderStatusRequest.getRecvWindow(), orderStatusRequest.getTimestamp())); - } - - @Override - public List getMyTrades(String symbol) { - return executeSync(binanceApiService.getMyTrades(symbol, null, null, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); - } - - // user stream endpoints - - @Override - public String startUserDataStream() { - return executeSync(binanceApiService.startMarginUserDataStream()).toString(); - } - - @Override - public void keepAliveUserDataStream(String listenKey) { - executeSync(binanceApiService.keepAliveMarginUserDataStream(listenKey)); - } - - @Override - public MarginTransaction transfer(String asset, String amount, TransferType type) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.transfer(asset, amount, type.getValue(), BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, timestamp)); - } - - @Override - public MarginTransaction borrow(String asset, String amount) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.borrow(asset, amount, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, timestamp)); - } - - @Override - public LoanQueryResult queryLoan(String asset, String txId) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.queryLoan(asset, txId, timestamp)); - } - - @Override - public RepayQueryResult queryRepay(String asset, String txId) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.queryRepay(asset, txId, timestamp)); - } - - @Override - public RepayQueryResult queryRepay(String asset, long startTime) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.queryRepay(asset, startTime, timestamp)); - } - - @Override - public MaxBorrowableQueryResult queryMaxBorrowable(String asset) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.queryMaxBorrowable(asset, timestamp)); - } - - @Override - public MarginTransaction repay(String asset, String amount) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.repay(asset, amount, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, timestamp)); - } + private final BinanceApiService binanceApiService; + + public BinanceApiMarginRestClientImpl(String apiKey, String secret) { + binanceApiService = createService(BinanceApiService.class, apiKey, secret); + } + + @Override + public MarginAccount getAccount() { + long timestamp = System.currentTimeMillis(); + return executeSync(binanceApiService.getMarginAccount(BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, timestamp)); + } + + @Override + public List getOpenOrders(OrderRequest orderRequest) { + return executeSync(binanceApiService.getOpenMarginOrders(orderRequest.getSymbol(), orderRequest.getRecvWindow(), + orderRequest.getTimestamp())); + } + + @Override + public MarginNewOrderResponse newOrder(MarginNewOrder order) { + return executeSync(binanceApiService.newMarginOrder(order.getSymbol(), order.getSide(), order.getType(), + order.getTimeInForce(), order.getQuantity(), order.getPrice(), order.getNewClientOrderId(), order.getStopPrice(), + order.getIcebergQty(), order.getNewOrderRespType(), order.getSideEffectType(), order.getRecvWindow(), order.getTimestamp())); + } + + @Override + public CancelOrderResponse cancelOrder(CancelOrderRequest cancelOrderRequest) { + return executeSync(binanceApiService.cancelMarginOrder(cancelOrderRequest.getSymbol(), + cancelOrderRequest.getOrderId(), cancelOrderRequest.getOrigClientOrderId(), cancelOrderRequest.getNewClientOrderId(), + cancelOrderRequest.getRecvWindow(), cancelOrderRequest.getTimestamp())); + } + + @Override + public Order getOrderStatus(OrderStatusRequest orderStatusRequest) { + return executeSync(binanceApiService.getMarginOrderStatus(orderStatusRequest.getSymbol(), + orderStatusRequest.getOrderId(), orderStatusRequest.getOrigClientOrderId(), + orderStatusRequest.getRecvWindow(), orderStatusRequest.getTimestamp())); + } + + @Override + public List getMyTrades(String symbol) { + return executeSync(binanceApiService.getMyTrades(symbol, null, null, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); + } + + // user stream endpoints + + @Override + public String startUserDataStream() { + return executeSync(binanceApiService.startMarginUserDataStream()).toString(); + } + + @Override + public void keepAliveUserDataStream(String listenKey) { + executeSync(binanceApiService.keepAliveMarginUserDataStream(listenKey)); + } + + @Override + public MarginTransaction transfer(String asset, String amount, TransferType type) { + long timestamp = System.currentTimeMillis(); + return executeSync(binanceApiService.transfer(asset, amount, type.getValue(), BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, timestamp)); + } + + @Override + public MarginTransaction borrow(String asset, String amount) { + long timestamp = System.currentTimeMillis(); + return executeSync(binanceApiService.borrow(asset, amount, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, timestamp)); + } + + @Override + public LoanQueryResult queryLoan(String asset, String txId) { + long timestamp = System.currentTimeMillis(); + return executeSync(binanceApiService.queryLoan(asset, txId, timestamp)); + } + + @Override + public RepayQueryResult queryRepay(String asset, String txId) { + long timestamp = System.currentTimeMillis(); + return executeSync(binanceApiService.queryRepay(asset, txId, timestamp)); + } + + @Override + public RepayQueryResult queryRepay(String asset, long startTime) { + long timestamp = System.currentTimeMillis(); + return executeSync(binanceApiService.queryRepay(asset, startTime, timestamp)); + } + + @Override + public MaxBorrowableQueryResult queryMaxBorrowable(String asset) { + long timestamp = System.currentTimeMillis(); + return executeSync(binanceApiService.queryMaxBorrowable(asset, timestamp)); + } + + @Override + public MarginTransaction repay(String asset, String amount) { + long timestamp = System.currentTimeMillis(); + return executeSync(binanceApiService.repay(asset, amount, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, timestamp)); + } } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java index c80c7a06d..214f0fb1b 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java @@ -21,261 +21,261 @@ */ public class BinanceApiRestClientImpl implements BinanceApiRestClient { - private final BinanceApiService binanceApiService; - - public BinanceApiRestClientImpl(String apiKey, String secret) { - binanceApiService = createService(BinanceApiService.class, apiKey, secret); - } - - // General endpoints - - @Override - public void ping() { - executeSync(binanceApiService.ping()); - } - - @Override - public Long getServerTime() { - return executeSync(binanceApiService.getServerTime()).getServerTime(); - } - - @Override - public ExchangeInfo getExchangeInfo() { - return executeSync(binanceApiService.getExchangeInfo()); - } - - @Override - public List getAllAssets() { - return executeSync(binanceApiService - .getAllAssets(BinanceApiConfig.getAssetInfoApiBaseUrl() + "assetWithdraw/getAllAsset.html")); - } - - // Market Data endpoints - - @Override - public OrderBook getOrderBook(String symbol, Integer limit) { - return executeSync(binanceApiService.getOrderBook(symbol, limit)); - } - - @Override - public List getTrades(String symbol, Integer limit) { - return executeSync(binanceApiService.getTrades(symbol, limit)); - } - - @Override - public List getHistoricalTrades(String symbol, Integer limit, Long fromId) { - return executeSync(binanceApiService.getHistoricalTrades(symbol, limit, fromId)); - } - - @Override - public List getAggTrades(String symbol, String fromId, Integer limit, Long startTime, Long endTime) { - return executeSync(binanceApiService.getAggTrades(symbol, fromId, limit, startTime, endTime)); - } - - @Override - public List getAggTrades(String symbol) { - return getAggTrades(symbol, null, null, null, null); - } - - @Override - public List getCandlestickBars(String symbol, CandlestickInterval interval, Integer limit, - Long startTime, Long endTime) { - return executeSync( - binanceApiService.getCandlestickBars(symbol, interval.getIntervalId(), limit, startTime, endTime)); - } - - @Override - public List getCandlestickBars(String symbol, CandlestickInterval interval) { - return getCandlestickBars(symbol, interval, null, null, null); - } - - @Override - public TickerStatistics get24HrPriceStatistics(String symbol) { - return executeSync(binanceApiService.get24HrPriceStatistics(symbol)); - } - - @Override - public List getAll24HrPriceStatistics() { - return executeSync(binanceApiService.getAll24HrPriceStatistics()); - } - - @Override - public TickerPrice getPrice(String symbol) { - return executeSync(binanceApiService.getLatestPrice(symbol)); - } - - @Override - public List getAllPrices() { - return executeSync(binanceApiService.getLatestPrices()); - } - - @Override - public List getBookTickers() { - return executeSync(binanceApiService.getBookTickers()); - } - - @Override - public NewOrderResponse newOrder(NewOrder order) { - final Call call; - if (order.getQuoteOrderQty() == null) { - call = binanceApiService.newOrder(order.getSymbol(), order.getSide(), order.getType(), - order.getTimeInForce(), order.getQuantity(), order.getPrice(), order.getNewClientOrderId(), - order.getStopPrice(), order.getIcebergQty(), order.getNewOrderRespType(), order.getRecvWindow(), - order.getTimestamp()); - } else { - call = binanceApiService.newOrderQuoteQty(order.getSymbol(), order.getSide(), order.getType(), - order.getTimeInForce(), order.getQuoteOrderQty(), order.getPrice(), order.getNewClientOrderId(), - order.getStopPrice(), order.getIcebergQty(), order.getNewOrderRespType(), order.getRecvWindow(), - order.getTimestamp()); - } - return executeSync(call); - } - - @Override - public void newOrderTest(NewOrder order) { - executeSync(binanceApiService.newOrderTest(order.getSymbol(), order.getSide(), order.getType(), - order.getTimeInForce(), order.getQuantity(), order.getPrice(), order.getNewClientOrderId(), - order.getStopPrice(), order.getIcebergQty(), order.getNewOrderRespType(), order.getRecvWindow(), - order.getTimestamp())); - } - - // Account endpoints - - @Override - public Order getOrderStatus(OrderStatusRequest orderStatusRequest) { - return executeSync(binanceApiService.getOrderStatus(orderStatusRequest.getSymbol(), - orderStatusRequest.getOrderId(), orderStatusRequest.getOrigClientOrderId(), - orderStatusRequest.getRecvWindow(), orderStatusRequest.getTimestamp())); - } - - @Override - public CancelOrderResponse cancelOrder(CancelOrderRequest cancelOrderRequest) { - return executeSync( - binanceApiService.cancelOrder(cancelOrderRequest.getSymbol(), cancelOrderRequest.getOrderId(), - cancelOrderRequest.getOrigClientOrderId(), cancelOrderRequest.getNewClientOrderId(), - cancelOrderRequest.getRecvWindow(), cancelOrderRequest.getTimestamp())); - } - - @Override - public List getOpenOrders(OrderRequest orderRequest) { - return executeSync(binanceApiService.getOpenOrders(orderRequest.getSymbol(), orderRequest.getRecvWindow(), - orderRequest.getTimestamp())); - } - - @Override - public List getAllOrders(AllOrdersRequest orderRequest) { - return executeSync(binanceApiService.getAllOrders(orderRequest.getSymbol(), orderRequest.getOrderId(), - orderRequest.getLimit(), orderRequest.getRecvWindow(), orderRequest.getTimestamp())); - } - - @Override - public NewOCOResponse newOCO(NewOCO oco) { - return executeSync(binanceApiService.newOCO(oco.getSymbol(), oco.getListClientOrderId(), oco.getSide(), - oco.getQuantity(), oco.getLimitClientOrderId(), oco.getPrice(), oco.getLimitIcebergQty(), - oco.getStopClientOrderId(), oco.getStopPrice(), oco.getStopLimitPrice(), oco.getStopIcebergQty(), - oco.getStopLimitTimeInForce(), oco.getNewOrderRespType(), oco.getRecvWindow(), oco.getTimestamp())); - } - - @Override - public CancelOrderListResponse cancelOrderList(CancelOrderListRequest cancelOrderListRequest) { - return executeSync(binanceApiService.cancelOrderList(cancelOrderListRequest.getSymbol(), cancelOrderListRequest.getOrderListId(), - cancelOrderListRequest.getListClientOrderId(), cancelOrderListRequest.getNewClientOrderId(), - cancelOrderListRequest.getRecvWindow(), cancelOrderListRequest.getTimestamp())); - } - - @Override - public OrderList getOrderListStatus(OrderListStatusRequest orderListStatusRequest) { - return executeSync(binanceApiService.getOrderListStatus(orderListStatusRequest.getOrderListId(), orderListStatusRequest.getOrigClientOrderId(), - orderListStatusRequest.getRecvWindow(), orderListStatusRequest.getTimestamp())); - } - - @Override - public List getAllOrderList(AllOrderListRequest allOrderListRequest) { - return executeSync(binanceApiService.getAllOrderList(allOrderListRequest.getFromId(), allOrderListRequest.getStartTime(), - allOrderListRequest.getEndTime(), allOrderListRequest.getLimit(), allOrderListRequest.getRecvWindow(), allOrderListRequest.getTimestamp())); - } - - @Override - public Account getAccount(Long recvWindow, Long timestamp) { - return executeSync(binanceApiService.getAccount(recvWindow, timestamp)); - } - - @Override - public Account getAccount() { - return getAccount(BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()); - } - - @Override - public List getMyTrades(String symbol, Integer limit, Long fromId, Long recvWindow, Long timestamp) { - return executeSync(binanceApiService.getMyTrades(symbol, limit, fromId, recvWindow, timestamp)); - } - - @Override - public List getMyTrades(String symbol, Integer limit) { - return getMyTrades(symbol, limit, null, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - System.currentTimeMillis()); - } - - @Override - public List getMyTrades(String symbol) { - return getMyTrades(symbol, null, null, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - System.currentTimeMillis()); - } - - @Override - public List getMyTrades(String symbol, Long fromId) { - return getMyTrades(symbol, null, fromId, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - System.currentTimeMillis()); - } - - @Override - public WithdrawResult withdraw(String asset, String address, String amount, String name, String addressTag) { - return executeSync(binanceApiService.withdraw(asset, address, amount, name, addressTag, - BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); - } - - @Override - public DustTransferResponse dustTranfer(List asset) { - return executeSync(binanceApiService.dustTransfer(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); - } - - @Override - public DepositHistory getDepositHistory(String asset) { - return executeSync(binanceApiService.getDepositHistory(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - System.currentTimeMillis())); - } - - @Override - public WithdrawHistory getWithdrawHistory(String asset) { - return executeSync(binanceApiService.getWithdrawHistory(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - System.currentTimeMillis())); - } - - @Override - public List getSubAccountTransfers() { - return executeSync(binanceApiService.getSubAccountTransfers(System.currentTimeMillis())); - } - - @Override - public DepositAddress getDepositAddress(String asset) { - return executeSync(binanceApiService.getDepositAddress(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - System.currentTimeMillis())); - } - - // User stream endpoints - - @Override - public String startUserDataStream() { - return executeSync(binanceApiService.startUserDataStream()).toString(); - } - - @Override - public void keepAliveUserDataStream(String listenKey) { - executeSync(binanceApiService.keepAliveUserDataStream(listenKey)); - } - - @Override - public void closeUserDataStream(String listenKey) { - executeSync(binanceApiService.closeAliveUserDataStream(listenKey)); - } + private final BinanceApiService binanceApiService; + + public BinanceApiRestClientImpl(String apiKey, String secret) { + binanceApiService = createService(BinanceApiService.class, apiKey, secret); + } + + // General endpoints + + @Override + public void ping() { + executeSync(binanceApiService.ping()); + } + + @Override + public Long getServerTime() { + return executeSync(binanceApiService.getServerTime()).getServerTime(); + } + + @Override + public ExchangeInfo getExchangeInfo() { + return executeSync(binanceApiService.getExchangeInfo()); + } + + @Override + public List getAllAssets() { + return executeSync(binanceApiService + .getAllAssets(BinanceApiConfig.getAssetInfoApiBaseUrl() + "assetWithdraw/getAllAsset.html")); + } + + // Market Data endpoints + + @Override + public OrderBook getOrderBook(String symbol, Integer limit) { + return executeSync(binanceApiService.getOrderBook(symbol, limit)); + } + + @Override + public List getTrades(String symbol, Integer limit) { + return executeSync(binanceApiService.getTrades(symbol, limit)); + } + + @Override + public List getHistoricalTrades(String symbol, Integer limit, Long fromId) { + return executeSync(binanceApiService.getHistoricalTrades(symbol, limit, fromId)); + } + + @Override + public List getAggTrades(String symbol, String fromId, Integer limit, Long startTime, Long endTime) { + return executeSync(binanceApiService.getAggTrades(symbol, fromId, limit, startTime, endTime)); + } + + @Override + public List getAggTrades(String symbol) { + return getAggTrades(symbol, null, null, null, null); + } + + @Override + public List getCandlestickBars(String symbol, CandlestickInterval interval, Integer limit, + Long startTime, Long endTime) { + return executeSync( + binanceApiService.getCandlestickBars(symbol, interval.getIntervalId(), limit, startTime, endTime)); + } + + @Override + public List getCandlestickBars(String symbol, CandlestickInterval interval) { + return getCandlestickBars(symbol, interval, null, null, null); + } + + @Override + public TickerStatistics get24HrPriceStatistics(String symbol) { + return executeSync(binanceApiService.get24HrPriceStatistics(symbol)); + } + + @Override + public List getAll24HrPriceStatistics() { + return executeSync(binanceApiService.getAll24HrPriceStatistics()); + } + + @Override + public TickerPrice getPrice(String symbol) { + return executeSync(binanceApiService.getLatestPrice(symbol)); + } + + @Override + public List getAllPrices() { + return executeSync(binanceApiService.getLatestPrices()); + } + + @Override + public List getBookTickers() { + return executeSync(binanceApiService.getBookTickers()); + } + + @Override + public NewOrderResponse newOrder(NewOrder order) { + final Call call; + if (order.getQuoteOrderQty() == null) { + call = binanceApiService.newOrder(order.getSymbol(), order.getSide(), order.getType(), + order.getTimeInForce(), order.getQuantity(), order.getPrice(), order.getNewClientOrderId(), + order.getStopPrice(), order.getIcebergQty(), order.getNewOrderRespType(), order.getRecvWindow(), + order.getTimestamp()); + } else { + call = binanceApiService.newOrderQuoteQty(order.getSymbol(), order.getSide(), order.getType(), + order.getTimeInForce(), order.getQuoteOrderQty(), order.getPrice(), order.getNewClientOrderId(), + order.getStopPrice(), order.getIcebergQty(), order.getNewOrderRespType(), order.getRecvWindow(), + order.getTimestamp()); + } + return executeSync(call); + } + + @Override + public void newOrderTest(NewOrder order) { + executeSync(binanceApiService.newOrderTest(order.getSymbol(), order.getSide(), order.getType(), + order.getTimeInForce(), order.getQuantity(), order.getPrice(), order.getNewClientOrderId(), + order.getStopPrice(), order.getIcebergQty(), order.getNewOrderRespType(), order.getRecvWindow(), + order.getTimestamp())); + } + + // Account endpoints + + @Override + public Order getOrderStatus(OrderStatusRequest orderStatusRequest) { + return executeSync(binanceApiService.getOrderStatus(orderStatusRequest.getSymbol(), + orderStatusRequest.getOrderId(), orderStatusRequest.getOrigClientOrderId(), + orderStatusRequest.getRecvWindow(), orderStatusRequest.getTimestamp())); + } + + @Override + public CancelOrderResponse cancelOrder(CancelOrderRequest cancelOrderRequest) { + return executeSync( + binanceApiService.cancelOrder(cancelOrderRequest.getSymbol(), cancelOrderRequest.getOrderId(), + cancelOrderRequest.getOrigClientOrderId(), cancelOrderRequest.getNewClientOrderId(), + cancelOrderRequest.getRecvWindow(), cancelOrderRequest.getTimestamp())); + } + + @Override + public List getOpenOrders(OrderRequest orderRequest) { + return executeSync(binanceApiService.getOpenOrders(orderRequest.getSymbol(), orderRequest.getRecvWindow(), + orderRequest.getTimestamp())); + } + + @Override + public List getAllOrders(AllOrdersRequest orderRequest) { + return executeSync(binanceApiService.getAllOrders(orderRequest.getSymbol(), orderRequest.getOrderId(), + orderRequest.getLimit(), orderRequest.getRecvWindow(), orderRequest.getTimestamp())); + } + + @Override + public NewOCOResponse newOCO(NewOCO oco) { + return executeSync(binanceApiService.newOCO(oco.getSymbol(), oco.getListClientOrderId(), oco.getSide(), + oco.getQuantity(), oco.getLimitClientOrderId(), oco.getPrice(), oco.getLimitIcebergQty(), + oco.getStopClientOrderId(), oco.getStopPrice(), oco.getStopLimitPrice(), oco.getStopIcebergQty(), + oco.getStopLimitTimeInForce(), oco.getNewOrderRespType(), oco.getRecvWindow(), oco.getTimestamp())); + } + + @Override + public CancelOrderListResponse cancelOrderList(CancelOrderListRequest cancelOrderListRequest) { + return executeSync(binanceApiService.cancelOrderList(cancelOrderListRequest.getSymbol(), cancelOrderListRequest.getOrderListId(), + cancelOrderListRequest.getListClientOrderId(), cancelOrderListRequest.getNewClientOrderId(), + cancelOrderListRequest.getRecvWindow(), cancelOrderListRequest.getTimestamp())); + } + + @Override + public OrderList getOrderListStatus(OrderListStatusRequest orderListStatusRequest) { + return executeSync(binanceApiService.getOrderListStatus(orderListStatusRequest.getOrderListId(), orderListStatusRequest.getOrigClientOrderId(), + orderListStatusRequest.getRecvWindow(), orderListStatusRequest.getTimestamp())); + } + + @Override + public List getAllOrderList(AllOrderListRequest allOrderListRequest) { + return executeSync(binanceApiService.getAllOrderList(allOrderListRequest.getFromId(), allOrderListRequest.getStartTime(), + allOrderListRequest.getEndTime(), allOrderListRequest.getLimit(), allOrderListRequest.getRecvWindow(), allOrderListRequest.getTimestamp())); + } + + @Override + public Account getAccount(Long recvWindow, Long timestamp) { + return executeSync(binanceApiService.getAccount(recvWindow, timestamp)); + } + + @Override + public Account getAccount() { + return getAccount(BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()); + } + + @Override + public List getMyTrades(String symbol, Integer limit, Long fromId, Long recvWindow, Long timestamp) { + return executeSync(binanceApiService.getMyTrades(symbol, limit, fromId, recvWindow, timestamp)); + } + + @Override + public List getMyTrades(String symbol, Integer limit) { + return getMyTrades(symbol, limit, null, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + System.currentTimeMillis()); + } + + @Override + public List getMyTrades(String symbol) { + return getMyTrades(symbol, null, null, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + System.currentTimeMillis()); + } + + @Override + public List getMyTrades(String symbol, Long fromId) { + return getMyTrades(symbol, null, fromId, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + System.currentTimeMillis()); + } + + @Override + public WithdrawResult withdraw(String asset, String address, String amount, String name, String addressTag) { + return executeSync(binanceApiService.withdraw(asset, address, amount, name, addressTag, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); + } + + @Override + public DustTransferResponse dustTranfer(List asset) { + return executeSync(binanceApiService.dustTransfer(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); + } + + @Override + public DepositHistory getDepositHistory(String asset) { + return executeSync(binanceApiService.getDepositHistory(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + System.currentTimeMillis())); + } + + @Override + public WithdrawHistory getWithdrawHistory(String asset) { + return executeSync(binanceApiService.getWithdrawHistory(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + System.currentTimeMillis())); + } + + @Override + public List getSubAccountTransfers() { + return executeSync(binanceApiService.getSubAccountTransfers(System.currentTimeMillis())); + } + + @Override + public DepositAddress getDepositAddress(String asset) { + return executeSync(binanceApiService.getDepositAddress(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + System.currentTimeMillis())); + } + + // User stream endpoints + + @Override + public String startUserDataStream() { + return executeSync(binanceApiService.startUserDataStream()).toString(); + } + + @Override + public void keepAliveUserDataStream(String listenKey) { + executeSync(binanceApiService.keepAliveUserDataStream(listenKey)); + } + + @Override + public void closeUserDataStream(String listenKey) { + executeSync(binanceApiService.closeAliveUserDataStream(listenKey)); + } } diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiService.java b/src/main/java/com/binance/api/client/impl/BinanceApiService.java index 5825f9844..b64d68bd4 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiService.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiService.java @@ -23,312 +23,312 @@ */ public interface BinanceApiService { - // General endpoints + // General endpoints - @GET("/api/v1/ping") - Call ping(); + @GET("/api/v1/ping") + Call ping(); - @GET("/api/v1/time") - Call getServerTime(); + @GET("/api/v1/time") + Call getServerTime(); - @GET("/api/v3/exchangeInfo") - Call getExchangeInfo(); + @GET("/api/v3/exchangeInfo") + Call getExchangeInfo(); - @GET - Call> getAllAssets(@Url String url); + @GET + Call> getAllAssets(@Url String url); - // Market data endpoints + // Market data endpoints - @GET("/api/v1/depth") - Call getOrderBook(@Query("symbol") String symbol, @Query("limit") Integer limit); + @GET("/api/v1/depth") + Call getOrderBook(@Query("symbol") String symbol, @Query("limit") Integer limit); - @GET("/api/v1/trades") - Call> getTrades(@Query("symbol") String symbol, @Query("limit") Integer limit); + @GET("/api/v1/trades") + Call> getTrades(@Query("symbol") String symbol, @Query("limit") Integer limit); - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) - @GET("/api/v1/historicalTrades") - Call> getHistoricalTrades(@Query("symbol") String symbol, @Query("limit") Integer limit, @Query("fromId") Long fromId); + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) + @GET("/api/v1/historicalTrades") + Call> getHistoricalTrades(@Query("symbol") String symbol, @Query("limit") Integer limit, @Query("fromId") Long fromId); - @GET("/api/v1/aggTrades") - Call> getAggTrades(@Query("symbol") String symbol, @Query("fromId") String fromId, @Query("limit") Integer limit, - @Query("startTime") Long startTime, @Query("endTime") Long endTime); + @GET("/api/v1/aggTrades") + Call> getAggTrades(@Query("symbol") String symbol, @Query("fromId") String fromId, @Query("limit") Integer limit, + @Query("startTime") Long startTime, @Query("endTime") Long endTime); - @GET("/api/v1/klines") - Call> getCandlestickBars(@Query("symbol") String symbol, @Query("interval") String interval, @Query("limit") Integer limit, - @Query("startTime") Long startTime, @Query("endTime") Long endTime); + @GET("/api/v1/klines") + Call> getCandlestickBars(@Query("symbol") String symbol, @Query("interval") String interval, @Query("limit") Integer limit, + @Query("startTime") Long startTime, @Query("endTime") Long endTime); - @GET("/api/v1/ticker/24hr") - Call get24HrPriceStatistics(@Query("symbol") String symbol); + @GET("/api/v1/ticker/24hr") + Call get24HrPriceStatistics(@Query("symbol") String symbol); - @GET("/api/v1/ticker/24hr") - Call> getAll24HrPriceStatistics(); + @GET("/api/v1/ticker/24hr") + Call> getAll24HrPriceStatistics(); - @GET("/api/v1/ticker/allPrices") - Call> getLatestPrices(); + @GET("/api/v1/ticker/allPrices") + Call> getLatestPrices(); - @GET("/api/v3/ticker/price") - Call getLatestPrice(@Query("symbol") String symbol); + @GET("/api/v3/ticker/price") + Call getLatestPrice(@Query("symbol") String symbol); - @GET("/api/v1/ticker/allBookTickers") - Call> getBookTickers(); + @GET("/api/v1/ticker/allBookTickers") + Call> getBookTickers(); - // Account endpoints + // Account endpoints - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @POST("/api/v3/order") - Call newOrder(@Query("symbol") String symbol, @Query("side") OrderSide side, @Query("type") OrderType type, - @Query("timeInForce") TimeInForce timeInForce, @Query("quantity") String quantity, @Query("price") String price, - @Query("newClientOrderId") String newClientOrderId, @Query("stopPrice") String stopPrice, - @Query("icebergQty") String icebergQty, @Query("newOrderRespType") NewOrderResponseType newOrderRespType, - @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @POST("/api/v3/order") - Call newOrderQuoteQty(@Query("symbol") String symbol, @Query("side") OrderSide side, @Query("type") OrderType type, - @Query("timeInForce") TimeInForce timeInForce, @Query("quoteOrderQty") String quoteOrderQty, @Query("price") String price, - @Query("newClientOrderId") String newClientOrderId, @Query("stopPrice") String stopPrice, - @Query("icebergQty") String icebergQty, @Query("newOrderRespType") NewOrderResponseType newOrderRespType, - @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @POST("/api/v3/order/test") - Call newOrderTest(@Query("symbol") String symbol, @Query("side") OrderSide side, @Query("type") OrderType type, - @Query("timeInForce") TimeInForce timeInForce, @Query("quantity") String quantity, @Query("price") String price, - @Query("newClientOrderId") String newClientOrderId, @Query("stopPrice") String stopPrice, - @Query("icebergQty") String icebergQty, @Query("newOrderRespType") NewOrderResponseType newOrderRespType, - @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/api/v3/order") - Call getOrderStatus(@Query("symbol") String symbol, @Query("orderId") Long orderId, - @Query("origClientOrderId") String origClientOrderId, @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @DELETE("/api/v3/order") - Call cancelOrder(@Query("symbol") String symbol, @Query("orderId") Long orderId, - @Query("origClientOrderId") String origClientOrderId, @Query("newClientOrderId") String newClientOrderId, - @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/api/v3/openOrders") - Call> getOpenOrders(@Query("symbol") String symbol, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/api/v3/allOrders") - Call> getAllOrders(@Query("symbol") String symbol, @Query("orderId") Long orderId, - @Query("limit") Integer limit, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @POST("/api/v3/order/oco") - Call newOCO(@Query("symbol") String symbol, @Query("listClientOrderId") String listClientOrderId, @Query("side") OrderSide side, - @Query("quantity") String quantity, @Query("limitClientOrderId") String limitClientOrderId, @Query("price") String price, - @Query("limitIcebergQty") String limitIcebergQty, @Query("stopClientOrderId")String stopClientOrderId, @Query("stopPrice") String stopPrice, - @Query("stopLimitPrice")String stopLimitPrice, @Query("stopIcebergQty") String stopIcebergQty, @Query("stopLimitTimeInForce") TimeInForce stopLimitTimeInForce, - @Query("newOrderRespType") NewOrderResponseType newOrderRespType, @Query("recvWindow") Long recvWindow, @Query("timestamp") long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @DELETE("/api/v3/orderList") - Call cancelOrderList(@Query("symbol") String symbol, @Query("orderListId") Long orderListId, @Query("listClientOrderId") String listClientOrderId, - @Query("newClientOrderId") String newClientOrderId, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/api/v3/orderList") - Call getOrderListStatus(@Query("orderListId") Long orderListId, @Query("origClientOrderId") String origClientOrderId, - @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/api/v3/allOrderList") - Call> getAllOrderList(@Query("fromId") Long fromId, @Query("startTime") Long startTime, @Query("endTime") Long endTime, - @Query("limit") Integer limit, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/api/v3/account") - Call getAccount(@Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/api/v3/myTrades") - Call> getMyTrades(@Query("symbol") String symbol, @Query("limit") Integer limit, @Query("fromId") Long fromId, - @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @POST("/wapi/v3/withdraw.html") - Call withdraw(@Query("asset") String asset, @Query("address") String address, @Query("amount") String amount, @Query("name") String name, @Query("addressTag") String addressTag, + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @POST("/api/v3/order") + Call newOrder(@Query("symbol") String symbol, @Query("side") OrderSide side, @Query("type") OrderType type, + @Query("timeInForce") TimeInForce timeInForce, @Query("quantity") String quantity, @Query("price") String price, + @Query("newClientOrderId") String newClientOrderId, @Query("stopPrice") String stopPrice, + @Query("icebergQty") String icebergQty, @Query("newOrderRespType") NewOrderResponseType newOrderRespType, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @POST("/api/v3/order") + Call newOrderQuoteQty(@Query("symbol") String symbol, @Query("side") OrderSide side, @Query("type") OrderType type, + @Query("timeInForce") TimeInForce timeInForce, @Query("quoteOrderQty") String quoteOrderQty, @Query("price") String price, + @Query("newClientOrderId") String newClientOrderId, @Query("stopPrice") String stopPrice, + @Query("icebergQty") String icebergQty, @Query("newOrderRespType") NewOrderResponseType newOrderRespType, + @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/wapi/v3/depositHistory.html") - Call getDepositHistory(@Query("asset") String asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/wapi/v3/withdrawHistory.html") - Call getWithdrawHistory(@Query("asset") String asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/wapi/v3/depositAddress.html") - Call getDepositAddress(@Query("asset") String asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @POST("/sapi/v1/asset/dust") - Call dustTransfer(@Query("asset") List asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/sapi/v1/sub-account/transfer/subUserHistory") - Call> getSubAccountTransfers(@Query("timestamp") Long timestamp); - - // User stream endpoints - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) - @POST("/api/v1/userDataStream") - Call startUserDataStream(); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) - @PUT("/api/v1/userDataStream") - Call keepAliveUserDataStream(@Query("listenKey") String listenKey); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) - @DELETE("/api/v1/userDataStream") - Call closeAliveUserDataStream(@Query("listenKey") String listenKey); - - // Margin Account endpoints - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @POST("/sapi/v1/margin/transfer") - Call transfer(@Query("asset") String asset, @Query("amount") String amount, @Query("type") String type, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @POST("/sapi/v1/margin/loan") - Call borrow(@Query("asset") String asset, @Query("amount") String amount, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/margin/loan") - Call queryLoan(@Query("asset") String asset, @Query("txId") String txId, @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/margin/repay") - Call queryRepay(@Query("asset") String asset, @Query("txId") String txId, @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/margin/maxBorrowable") - Call queryMaxBorrowable(@Query("asset") String asset, @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/margin/repay") - Call queryRepay(@Query("asset") String asset, @Query("startTime") Long starttime, @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @POST("/sapi/v1/margin/repay") - Call repay(@Query("asset") String asset, @Query("amount") String amount, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/margin/account") - Call getMarginAccount(@Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/margin/openOrders") - Call> getOpenMarginOrders(@Query("symbol") String symbol, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @POST("/sapi/v1/margin/order") - Call newMarginOrder(@Query("symbol") String symbol, @Query("side") OrderSide side, @Query("type") OrderType type, - @Query("timeInForce") TimeInForce timeInForce, @Query("quantity") String quantity, - @Query("price") String price, @Query("newClientOrderId") String newClientOrderId, @Query("stopPrice") String stopPrice, - @Query("icebergQty") String icebergQty, @Query("newOrderRespType") NewOrderResponseType newOrderRespType, - @Query("sideEffectType") SideEffectType sideEffectType, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @DELETE("/sapi/v1/margin/order") - Call cancelMarginOrder(@Query("symbol") String symbol, @Query("orderId") Long orderId, - @Query("origClientOrderId") String origClientOrderId, @Query("newClientOrderId") String newClientOrderId, - @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/sapi/v1/margin/order") - Call getMarginOrderStatus(@Query("symbol") String symbol, @Query("orderId") Long orderId, - @Query("origClientOrderId") String origClientOrderId, @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/sapi/v1/margin/myTrades") - Call> getMyMarginTrades(@Query("symbol") String symbol, @Query("limit") Integer limit, @Query("fromId") Long fromId, + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @POST("/api/v3/order/test") + Call newOrderTest(@Query("symbol") String symbol, @Query("side") OrderSide side, @Query("type") OrderType type, + @Query("timeInForce") TimeInForce timeInForce, @Query("quantity") String quantity, @Query("price") String price, + @Query("newClientOrderId") String newClientOrderId, @Query("stopPrice") String stopPrice, + @Query("icebergQty") String icebergQty, @Query("newOrderRespType") NewOrderResponseType newOrderRespType, + @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @GET("/api/v3/order") + Call getOrderStatus(@Query("symbol") String symbol, @Query("orderId") Long orderId, + @Query("origClientOrderId") String origClientOrderId, @Query("recvWindow") Long recvWindow, + @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @DELETE("/api/v3/order") + Call cancelOrder(@Query("symbol") String symbol, @Query("orderId") Long orderId, + @Query("origClientOrderId") String origClientOrderId, @Query("newClientOrderId") String newClientOrderId, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) - @POST("/sapi/v1/userDataStream") - Call startMarginUserDataStream(); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) - @PUT("/sapi/v1/userDataStream") - Call keepAliveMarginUserDataStream(@Query("listenKey") String listenKey); - - // Binance Liquidity Swap Pool endpoints - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) - @GET("/sapi/v1/bswap/pools") - Call> listAllSwapPools(); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/bswap/liquidity") - Call> getPoolLiquidityInfo(@Query("poolId") String poolId, - @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @POST("/sapi/v1/bswap/liquidityAdd") - Call addLiquidity(@Query("poolId") String poolId, - @Query("asset") String asset, - @Query("quantity") String quantity, - @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @POST("/sapi/v1/bswap/liquidityRemove") - Call removeLiquidity(@Query("poolId") String poolId, - @Query("type") SwapRemoveType type, - @Query("asset") List asset, - @Query("shareAmount") String shareAmount, - @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/bswap/liquidityOps") - Call> getPoolLiquidityOperationRecords( - @Query("poolId") String poolId, - @Query("limit") Integer limit, - @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/bswap/liquidityOps") - Call> getLiquidityOperationRecord( - @Query("operationId") String operationId, - @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/bswap/quote") - Call requestQuote( - @Query("quoteAsset") String quoteAsset, - @Query("baseAsset") String baseAsset, - @Query("quoteQty") String quoteQty, - @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @POST("/sapi/v1/bswap/swap") - Call swap( - @Query("quoteAsset") String quoteAsset, - @Query("baseAsset") String baseAsset, - @Query("quoteQty") String quoteQty, - @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/bswap/swap") - Call> getSwapHistory( - @Query("swapId") String swapId, - @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @GET("/api/v3/openOrders") + Call> getOpenOrders(@Query("symbol") String symbol, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @GET("/api/v3/allOrders") + Call> getAllOrders(@Query("symbol") String symbol, @Query("orderId") Long orderId, + @Query("limit") Integer limit, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @POST("/api/v3/order/oco") + Call newOCO(@Query("symbol") String symbol, @Query("listClientOrderId") String listClientOrderId, @Query("side") OrderSide side, + @Query("quantity") String quantity, @Query("limitClientOrderId") String limitClientOrderId, @Query("price") String price, + @Query("limitIcebergQty") String limitIcebergQty, @Query("stopClientOrderId") String stopClientOrderId, @Query("stopPrice") String stopPrice, + @Query("stopLimitPrice") String stopLimitPrice, @Query("stopIcebergQty") String stopIcebergQty, @Query("stopLimitTimeInForce") TimeInForce stopLimitTimeInForce, + @Query("newOrderRespType") NewOrderResponseType newOrderRespType, @Query("recvWindow") Long recvWindow, @Query("timestamp") long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @DELETE("/api/v3/orderList") + Call cancelOrderList(@Query("symbol") String symbol, @Query("orderListId") Long orderListId, @Query("listClientOrderId") String listClientOrderId, + @Query("newClientOrderId") String newClientOrderId, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @GET("/api/v3/orderList") + Call getOrderListStatus(@Query("orderListId") Long orderListId, @Query("origClientOrderId") String origClientOrderId, + @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @GET("/api/v3/allOrderList") + Call> getAllOrderList(@Query("fromId") Long fromId, @Query("startTime") Long startTime, @Query("endTime") Long endTime, + @Query("limit") Integer limit, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @GET("/api/v3/account") + Call getAccount(@Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @GET("/api/v3/myTrades") + Call> getMyTrades(@Query("symbol") String symbol, @Query("limit") Integer limit, @Query("fromId") Long fromId, + @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @POST("/wapi/v3/withdraw.html") + Call withdraw(@Query("asset") String asset, @Query("address") String address, @Query("amount") String amount, @Query("name") String name, @Query("addressTag") String addressTag, + @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @GET("/wapi/v3/depositHistory.html") + Call getDepositHistory(@Query("asset") String asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @GET("/wapi/v3/withdrawHistory.html") + Call getWithdrawHistory(@Query("asset") String asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @GET("/wapi/v3/depositAddress.html") + Call getDepositAddress(@Query("asset") String asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @POST("/sapi/v1/asset/dust") + Call dustTransfer(@Query("asset") List asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @GET("/sapi/v1/sub-account/transfer/subUserHistory") + Call> getSubAccountTransfers(@Query("timestamp") Long timestamp); + + // User stream endpoints + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) + @POST("/api/v1/userDataStream") + Call startUserDataStream(); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) + @PUT("/api/v1/userDataStream") + Call keepAliveUserDataStream(@Query("listenKey") String listenKey); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) + @DELETE("/api/v1/userDataStream") + Call closeAliveUserDataStream(@Query("listenKey") String listenKey); + + // Margin Account endpoints + @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) + @POST("/sapi/v1/margin/transfer") + Call transfer(@Query("asset") String asset, @Query("amount") String amount, @Query("type") String type, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) + @POST("/sapi/v1/margin/loan") + Call borrow(@Query("asset") String asset, @Query("amount") String amount, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) + @GET("/sapi/v1/margin/loan") + Call queryLoan(@Query("asset") String asset, @Query("txId") String txId, @Query("timestamp") Long timestamp); + + @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) + @GET("/sapi/v1/margin/repay") + Call queryRepay(@Query("asset") String asset, @Query("txId") String txId, @Query("timestamp") Long timestamp); + + @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) + @GET("/sapi/v1/margin/maxBorrowable") + Call queryMaxBorrowable(@Query("asset") String asset, @Query("timestamp") Long timestamp); + + @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) + @GET("/sapi/v1/margin/repay") + Call queryRepay(@Query("asset") String asset, @Query("startTime") Long starttime, @Query("timestamp") Long timestamp); + + @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) + @POST("/sapi/v1/margin/repay") + Call repay(@Query("asset") String asset, @Query("amount") String amount, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) + @GET("/sapi/v1/margin/account") + Call getMarginAccount(@Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) + @GET("/sapi/v1/margin/openOrders") + Call> getOpenMarginOrders(@Query("symbol") String symbol, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @POST("/sapi/v1/margin/order") + Call newMarginOrder(@Query("symbol") String symbol, @Query("side") OrderSide side, @Query("type") OrderType type, + @Query("timeInForce") TimeInForce timeInForce, @Query("quantity") String quantity, + @Query("price") String price, @Query("newClientOrderId") String newClientOrderId, @Query("stopPrice") String stopPrice, + @Query("icebergQty") String icebergQty, @Query("newOrderRespType") NewOrderResponseType newOrderRespType, + @Query("sideEffectType") SideEffectType sideEffectType, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @DELETE("/sapi/v1/margin/order") + Call cancelMarginOrder(@Query("symbol") String symbol, @Query("orderId") Long orderId, + @Query("origClientOrderId") String origClientOrderId, @Query("newClientOrderId") String newClientOrderId, + @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @GET("/sapi/v1/margin/order") + Call getMarginOrderStatus(@Query("symbol") String symbol, @Query("orderId") Long orderId, + @Query("origClientOrderId") String origClientOrderId, @Query("recvWindow") Long recvWindow, + @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @GET("/sapi/v1/margin/myTrades") + Call> getMyMarginTrades(@Query("symbol") String symbol, @Query("limit") Integer limit, @Query("fromId") Long fromId, + @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) + @POST("/sapi/v1/userDataStream") + Call startMarginUserDataStream(); + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) + @PUT("/sapi/v1/userDataStream") + Call keepAliveMarginUserDataStream(@Query("listenKey") String listenKey); + + // Binance Liquidity Swap Pool endpoints + + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) + @GET("/sapi/v1/bswap/pools") + Call> listAllSwapPools(); + + @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) + @GET("/sapi/v1/bswap/liquidity") + Call> getPoolLiquidityInfo(@Query("poolId") String poolId, + @Query("recvWindow") Long recvWindow, + @Query("timestamp") Long timestamp); + + @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) + @POST("/sapi/v1/bswap/liquidityAdd") + Call addLiquidity(@Query("poolId") String poolId, + @Query("asset") String asset, + @Query("quantity") String quantity, + @Query("recvWindow") Long recvWindow, + @Query("timestamp") Long timestamp); + + @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) + @POST("/sapi/v1/bswap/liquidityRemove") + Call removeLiquidity(@Query("poolId") String poolId, + @Query("type") SwapRemoveType type, + @Query("asset") List asset, + @Query("shareAmount") String shareAmount, + @Query("recvWindow") Long recvWindow, + @Query("timestamp") Long timestamp); + + @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) + @GET("/sapi/v1/bswap/liquidityOps") + Call> getPoolLiquidityOperationRecords( + @Query("poolId") String poolId, + @Query("limit") Integer limit, + @Query("recvWindow") Long recvWindow, + @Query("timestamp") Long timestamp); + + @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) + @GET("/sapi/v1/bswap/liquidityOps") + Call> getLiquidityOperationRecord( + @Query("operationId") String operationId, + @Query("recvWindow") Long recvWindow, + @Query("timestamp") Long timestamp); + + @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) + @GET("/sapi/v1/bswap/quote") + Call requestQuote( + @Query("quoteAsset") String quoteAsset, + @Query("baseAsset") String baseAsset, + @Query("quoteQty") String quoteQty, + @Query("recvWindow") Long recvWindow, + @Query("timestamp") Long timestamp); + + @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) + @POST("/sapi/v1/bswap/swap") + Call swap( + @Query("quoteAsset") String quoteAsset, + @Query("baseAsset") String baseAsset, + @Query("quoteQty") String quoteQty, + @Query("recvWindow") Long recvWindow, + @Query("timestamp") Long timestamp); + + @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) + @GET("/sapi/v1/bswap/swap") + Call> getSwapHistory( + @Query("swapId") String swapId, + @Query("recvWindow") Long recvWindow, + @Query("timestamp") Long timestamp); } diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiServiceGenerator.java b/src/main/java/com/binance/api/client/impl/BinanceApiServiceGenerator.java index dec8d3047..0caeddac3 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiServiceGenerator.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiServiceGenerator.java @@ -23,91 +23,91 @@ */ public class BinanceApiServiceGenerator { - private static final OkHttpClient sharedClient; - private static final Converter.Factory converterFactory = JacksonConverterFactory.create(); + private static final OkHttpClient sharedClient; + private static final Converter.Factory converterFactory = JacksonConverterFactory.create(); - static { - Dispatcher dispatcher = new Dispatcher(); - dispatcher.setMaxRequestsPerHost(500); - dispatcher.setMaxRequests(500); - sharedClient = new OkHttpClient.Builder() - .dispatcher(dispatcher) - .pingInterval(20, TimeUnit.SECONDS) - .build(); - } + static { + Dispatcher dispatcher = new Dispatcher(); + dispatcher.setMaxRequestsPerHost(500); + dispatcher.setMaxRequests(500); + sharedClient = new OkHttpClient.Builder() + .dispatcher(dispatcher) + .pingInterval(20, TimeUnit.SECONDS) + .build(); + } - @SuppressWarnings("unchecked") - private static final Converter errorBodyConverter = - (Converter)converterFactory.responseBodyConverter( - BinanceApiError.class, new Annotation[0], null); + @SuppressWarnings("unchecked") + private static final Converter errorBodyConverter = + (Converter) converterFactory.responseBodyConverter( + BinanceApiError.class, new Annotation[0], null); - public static S createService(Class serviceClass) { - return createService(serviceClass, null, null); - } + public static S createService(Class serviceClass) { + return createService(serviceClass, null, null); + } - /** - * Create a Binance API service. - * - * @param serviceClass the type of service. - * @param apiKey Binance API key. - * @param secret Binance secret. - * - * @return a new implementation of the API endpoints for the Binance API service. - */ - public static S createService(Class serviceClass, String apiKey, String secret) { - String baseUrl = null; - if (!BinanceApiConfig.useTestnet) { baseUrl = BinanceApiConfig.getApiBaseUrl(); } - else { - baseUrl = /*BinanceApiConfig.useTestnetStreaming ? + /** + * Create a Binance API service. + * + * @param serviceClass the type of service. + * @param apiKey Binance API key. + * @param secret Binance secret. + * @return a new implementation of the API endpoints for the Binance API service. + */ + public static S createService(Class serviceClass, String apiKey, String secret) { + String baseUrl = null; + if (!BinanceApiConfig.useTestnet) { + baseUrl = BinanceApiConfig.getApiBaseUrl(); + } else { + baseUrl = /*BinanceApiConfig.useTestnetStreaming ? BinanceApiConfig.getStreamTestNetBaseUrl() :*/ - BinanceApiConfig.getTestNetBaseUrl(); - } - - Retrofit.Builder retrofitBuilder = new Retrofit.Builder() - .baseUrl(baseUrl) - .addConverterFactory(converterFactory); + BinanceApiConfig.getTestNetBaseUrl(); + } - if (StringUtils.isEmpty(apiKey) || StringUtils.isEmpty(secret)) { - retrofitBuilder.client(sharedClient); - } else { - // `adaptedClient` will use its own interceptor, but share thread pool etc with the 'parent' client - AuthenticationInterceptor interceptor = new AuthenticationInterceptor(apiKey, secret); - OkHttpClient adaptedClient = sharedClient.newBuilder().addInterceptor(interceptor).build(); - retrofitBuilder.client(adaptedClient); - } + Retrofit.Builder retrofitBuilder = new Retrofit.Builder() + .baseUrl(baseUrl) + .addConverterFactory(converterFactory); - Retrofit retrofit = retrofitBuilder.build(); - return retrofit.create(serviceClass); + if (StringUtils.isEmpty(apiKey) || StringUtils.isEmpty(secret)) { + retrofitBuilder.client(sharedClient); + } else { + // `adaptedClient` will use its own interceptor, but share thread pool etc with the 'parent' client + AuthenticationInterceptor interceptor = new AuthenticationInterceptor(apiKey, secret); + OkHttpClient adaptedClient = sharedClient.newBuilder().addInterceptor(interceptor).build(); + retrofitBuilder.client(adaptedClient); } - /** - * Execute a REST call and block until the response is received. - */ - public static T executeSync(Call call) { - try { - Response response = call.execute(); - if (response.isSuccessful()) { - return response.body(); - } else { - BinanceApiError apiError = getBinanceApiError(response); - throw new BinanceApiException(apiError); - } - } catch (IOException e) { - throw new BinanceApiException(e); - } - } + Retrofit retrofit = retrofitBuilder.build(); + return retrofit.create(serviceClass); + } - /** - * Extracts and converts the response error body into an object. - */ - public static BinanceApiError getBinanceApiError(Response response) throws IOException, BinanceApiException { - return errorBodyConverter.convert(response.errorBody()); + /** + * Execute a REST call and block until the response is received. + */ + public static T executeSync(Call call) { + try { + Response response = call.execute(); + if (response.isSuccessful()) { + return response.body(); + } else { + BinanceApiError apiError = getBinanceApiError(response); + throw new BinanceApiException(apiError); + } + } catch (IOException e) { + throw new BinanceApiException(e); } + } - /** - * Returns the shared OkHttpClient instance. - */ - public static OkHttpClient getSharedClient() { - return sharedClient; - } + /** + * Extracts and converts the response error body into an object. + */ + public static BinanceApiError getBinanceApiError(Response response) throws IOException, BinanceApiException { + return errorBodyConverter.convert(response.errorBody()); + } + + /** + * Returns the shared OkHttpClient instance. + */ + public static OkHttpClient getSharedClient() { + return sharedClient; + } } diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiSwapRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiSwapRestClientImpl.java index 4f1a18bc4..2ffdbf9c1 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiSwapRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiSwapRestClientImpl.java @@ -15,101 +15,101 @@ */ public class BinanceApiSwapRestClientImpl implements BinanceApiSwapRestClient { - private final BinanceApiService binanceApiService; - - public BinanceApiSwapRestClientImpl(String apiKey, String secret) { - binanceApiService = createService(BinanceApiService.class, apiKey, secret); - } - - @Override - public List listAllSwapPools() { - return executeSync(binanceApiService.listAllSwapPools()); - } - - @Override - public Liquidity getPoolLiquidityInfo(String poolId) { - long timestamp = System.currentTimeMillis(); - List liquidities = executeSync(binanceApiService.getPoolLiquidityInfo(poolId, - BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - timestamp)); - if (liquidities != null && !liquidities.isEmpty()) { - return liquidities.get(0); - } - return null; - } - - @Override - public LiquidityOperationRecord addLiquidity(String poolId, String asset, String quantity) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.addLiquidity(poolId, - asset, - quantity, - BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - timestamp)); - } - - @Override - public LiquidityOperationRecord removeLiquidity(String poolId, SwapRemoveType type, List asset, String shareAmount) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.removeLiquidity(poolId, - type, - asset, - shareAmount, - BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - timestamp)); + private final BinanceApiService binanceApiService; + + public BinanceApiSwapRestClientImpl(String apiKey, String secret) { + binanceApiService = createService(BinanceApiService.class, apiKey, secret); + } + + @Override + public List listAllSwapPools() { + return executeSync(binanceApiService.listAllSwapPools()); + } + + @Override + public Liquidity getPoolLiquidityInfo(String poolId) { + long timestamp = System.currentTimeMillis(); + List liquidities = executeSync(binanceApiService.getPoolLiquidityInfo(poolId, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + timestamp)); + if (liquidities != null && !liquidities.isEmpty()) { + return liquidities.get(0); } - - @Override - public List getPoolLiquidityOperationRecords(String poolId, Integer limit) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.getPoolLiquidityOperationRecords( - poolId, - limit, - BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - timestamp)); - + return null; + } + + @Override + public LiquidityOperationRecord addLiquidity(String poolId, String asset, String quantity) { + long timestamp = System.currentTimeMillis(); + return executeSync(binanceApiService.addLiquidity(poolId, + asset, + quantity, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + timestamp)); + } + + @Override + public LiquidityOperationRecord removeLiquidity(String poolId, SwapRemoveType type, List asset, String shareAmount) { + long timestamp = System.currentTimeMillis(); + return executeSync(binanceApiService.removeLiquidity(poolId, + type, + asset, + shareAmount, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + timestamp)); + } + + @Override + public List getPoolLiquidityOperationRecords(String poolId, Integer limit) { + long timestamp = System.currentTimeMillis(); + return executeSync(binanceApiService.getPoolLiquidityOperationRecords( + poolId, + limit, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + timestamp)); + + } + + @Override + public LiquidityOperationRecord getLiquidityOperationRecord(String operationId) { + long timestamp = System.currentTimeMillis(); + List records = executeSync(binanceApiService.getLiquidityOperationRecord( + operationId, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + timestamp)); + if (records != null && !records.isEmpty()) { + return records.get(0); } - - @Override - public LiquidityOperationRecord getLiquidityOperationRecord(String operationId) { - long timestamp = System.currentTimeMillis(); - List records = executeSync(binanceApiService.getLiquidityOperationRecord( - operationId, - BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - timestamp)); - if (records != null && !records.isEmpty()) { - return records.get(0); - } - return null; - } - - @Override - public SwapQuote requestQuote(String quoteAsset, - String baseAsset, - String quoteQty) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.requestQuote(quoteAsset, baseAsset, quoteQty, - BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - timestamp)); - } - - @Override - public SwapRecord swap(String quoteAsset, String baseAsset, String quoteQty) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.swap(quoteAsset, baseAsset, quoteQty, - BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - timestamp)); - } - - @Override - public SwapHistory getSwapHistory(String swapId) { - long timestamp = System.currentTimeMillis(); - List history = executeSync(binanceApiService.getSwapHistory(swapId, - BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - timestamp)); - if (history != null && !history.isEmpty()) { - return history.get(0); - } - return null; + return null; + } + + @Override + public SwapQuote requestQuote(String quoteAsset, + String baseAsset, + String quoteQty) { + long timestamp = System.currentTimeMillis(); + return executeSync(binanceApiService.requestQuote(quoteAsset, baseAsset, quoteQty, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + timestamp)); + } + + @Override + public SwapRecord swap(String quoteAsset, String baseAsset, String quoteQty) { + long timestamp = System.currentTimeMillis(); + return executeSync(binanceApiService.swap(quoteAsset, baseAsset, quoteQty, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + timestamp)); + } + + @Override + public SwapHistory getSwapHistory(String swapId) { + long timestamp = System.currentTimeMillis(); + List history = executeSync(binanceApiService.getSwapHistory(swapId, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + timestamp)); + if (history != null && !history.isEmpty()) { + return history.get(0); } + return null; + } } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiWebSocketClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiWebSocketClientImpl.java index 4d68fb436..cb95bdb5a 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiWebSocketClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiWebSocketClientImpl.java @@ -20,87 +20,87 @@ */ public class BinanceApiWebSocketClientImpl implements BinanceApiWebSocketClient, Closeable { - private final OkHttpClient client; + private final OkHttpClient client; - public BinanceApiWebSocketClientImpl(OkHttpClient client) { - this.client = client; - } + public BinanceApiWebSocketClientImpl(OkHttpClient client) { + this.client = client; + } - @Override - public Closeable onDepthEvent(String symbols, BinanceApiCallback callback) { - final String channel = Arrays.stream(symbols.split(",")) - .map(String::trim) - .map(s -> String.format("%s@depth", s)) - .collect(Collectors.joining("/")); - return createNewWebSocket(channel, new BinanceApiWebSocketListener<>(callback, DepthEvent.class)); - } + @Override + public Closeable onDepthEvent(String symbols, BinanceApiCallback callback) { + final String channel = Arrays.stream(symbols.split(",")) + .map(String::trim) + .map(s -> String.format("%s@depth", s)) + .collect(Collectors.joining("/")); + return createNewWebSocket(channel, new BinanceApiWebSocketListener<>(callback, DepthEvent.class)); + } - @Override - public Closeable onCandlestickEvent(String symbols, CandlestickInterval interval, BinanceApiCallback callback) { - final String channel = Arrays.stream(symbols.split(",")) - .map(String::trim) - .map(s -> String.format("%s@kline_%s", s, interval.getIntervalId())) - .collect(Collectors.joining("/")); - return createNewWebSocket(channel, new BinanceApiWebSocketListener<>(callback, CandlestickEvent.class)); - } + @Override + public Closeable onCandlestickEvent(String symbols, CandlestickInterval interval, BinanceApiCallback callback) { + final String channel = Arrays.stream(symbols.split(",")) + .map(String::trim) + .map(s -> String.format("%s@kline_%s", s, interval.getIntervalId())) + .collect(Collectors.joining("/")); + return createNewWebSocket(channel, new BinanceApiWebSocketListener<>(callback, CandlestickEvent.class)); + } - public Closeable onAggTradeEvent(String symbols, BinanceApiCallback callback) { - final String channel = Arrays.stream(symbols.split(",")) - .map(String::trim) - .map(s -> String.format("%s@aggTrade", s)) - .collect(Collectors.joining("/")); - return createNewWebSocket(channel, new BinanceApiWebSocketListener<>(callback, AggTradeEvent.class)); - } + public Closeable onAggTradeEvent(String symbols, BinanceApiCallback callback) { + final String channel = Arrays.stream(symbols.split(",")) + .map(String::trim) + .map(s -> String.format("%s@aggTrade", s)) + .collect(Collectors.joining("/")); + return createNewWebSocket(channel, new BinanceApiWebSocketListener<>(callback, AggTradeEvent.class)); + } - public Closeable onUserDataUpdateEvent(String listenKey, BinanceApiCallback callback) { - return createNewWebSocket(listenKey, new BinanceApiWebSocketListener<>(callback, UserDataUpdateEvent.class)); - } + public Closeable onUserDataUpdateEvent(String listenKey, BinanceApiCallback callback) { + return createNewWebSocket(listenKey, new BinanceApiWebSocketListener<>(callback, UserDataUpdateEvent.class)); + } - @Override - public Closeable onTickerEvent(String symbols, BinanceApiCallback callback) { - final String channel = Arrays.stream(symbols.split(",")) - .map(String::trim) - .map(s -> String.format("%s@ticker", s)) - .collect(Collectors.joining("/")); - return createNewWebSocket(channel, new BinanceApiWebSocketListener<>(callback, TickerEvent.class)); - } + @Override + public Closeable onTickerEvent(String symbols, BinanceApiCallback callback) { + final String channel = Arrays.stream(symbols.split(",")) + .map(String::trim) + .map(s -> String.format("%s@ticker", s)) + .collect(Collectors.joining("/")); + return createNewWebSocket(channel, new BinanceApiWebSocketListener<>(callback, TickerEvent.class)); + } - public Closeable onAllMarketTickersEvent(BinanceApiCallback> callback) { - final String channel = "!ticker@arr"; - return createNewWebSocket(channel, new BinanceApiWebSocketListener<>(callback, new TypeReference>() { - })); - } + public Closeable onAllMarketTickersEvent(BinanceApiCallback> callback) { + final String channel = "!ticker@arr"; + return createNewWebSocket(channel, new BinanceApiWebSocketListener<>(callback, new TypeReference>() { + })); + } - @Override - public Closeable onBookTickerEvent(String symbols, BinanceApiCallback callback) { - final String channel = Arrays.stream(symbols.split(",")) - .map(String::trim) - .map(s -> String.format("%s@bookTicker", s)) - .collect(Collectors.joining("/")); - return createNewWebSocket(channel, new BinanceApiWebSocketListener<>(callback, BookTickerEvent.class)); - } + @Override + public Closeable onBookTickerEvent(String symbols, BinanceApiCallback callback) { + final String channel = Arrays.stream(symbols.split(",")) + .map(String::trim) + .map(s -> String.format("%s@bookTicker", s)) + .collect(Collectors.joining("/")); + return createNewWebSocket(channel, new BinanceApiWebSocketListener<>(callback, BookTickerEvent.class)); + } - public Closeable onAllBookTickersEvent(BinanceApiCallback callback) { - final String channel = "!bookTicker"; - return createNewWebSocket(channel, new BinanceApiWebSocketListener<>(callback, BookTickerEvent.class)); - } + public Closeable onAllBookTickersEvent(BinanceApiCallback callback) { + final String channel = "!bookTicker"; + return createNewWebSocket(channel, new BinanceApiWebSocketListener<>(callback, BookTickerEvent.class)); + } - /** - * @deprecated This method is no longer functional. Please use the returned {@link Closeable} from any of the other methods to close the web socket. - */ - @Override - public void close() { - } + /** + * @deprecated This method is no longer functional. Please use the returned {@link Closeable} from any of the other methods to close the web socket. + */ + @Override + public void close() { + } - private Closeable createNewWebSocket(String channel, BinanceApiWebSocketListener listener) { - String streamingUrl = String.format("%s/%s", BinanceApiConfig.useTestnetStreaming?BinanceApiConfig.getStreamTestNetBaseUrl():BinanceApiConfig.getStreamApiBaseUrl(), channel); - Request request = new Request.Builder().url(streamingUrl).build(); - final WebSocket webSocket = client.newWebSocket(request, listener); - return () -> { - final int code = 1000; - listener.onClosing(webSocket, code, null); - webSocket.close(code, null); - listener.onClosed(webSocket, code, null); - }; - } + private Closeable createNewWebSocket(String channel, BinanceApiWebSocketListener listener) { + String streamingUrl = String.format("%s/%s", BinanceApiConfig.useTestnetStreaming ? BinanceApiConfig.getStreamTestNetBaseUrl() : BinanceApiConfig.getStreamApiBaseUrl(), channel); + Request request = new Request.Builder().url(streamingUrl).build(); + final WebSocket webSocket = client.newWebSocket(request, listener); + return () -> { + final int code = 1000; + listener.onClosing(webSocket, code, null); + webSocket.close(code, null); + listener.onClosed(webSocket, code, null); + }; + } } diff --git a/src/main/java/com/binance/api/client/security/AuthenticationInterceptor.java b/src/main/java/com/binance/api/client/security/AuthenticationInterceptor.java index 197aaabcb..9f25a5c5b 100755 --- a/src/main/java/com/binance/api/client/security/AuthenticationInterceptor.java +++ b/src/main/java/com/binance/api/client/security/AuthenticationInterceptor.java @@ -17,76 +17,76 @@ */ public class AuthenticationInterceptor implements Interceptor { - private final String apiKey; + private final String apiKey; - private final String secret; + private final String secret; - public AuthenticationInterceptor(String apiKey, String secret) { - this.apiKey = apiKey; - this.secret = secret; - } - - @Override - public Response intercept(Chain chain) throws IOException { - Request original = chain.request(); - Request.Builder newRequestBuilder = original.newBuilder(); - - boolean isApiKeyRequired = original.header(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY) != null; - boolean isSignatureRequired = original.header(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED) != null; - newRequestBuilder.removeHeader(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY) - .removeHeader(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED); + public AuthenticationInterceptor(String apiKey, String secret) { + this.apiKey = apiKey; + this.secret = secret; + } - // Endpoint requires sending a valid API-KEY - if (isApiKeyRequired || isSignatureRequired) { - newRequestBuilder.addHeader(BinanceApiConstants.API_KEY_HEADER, apiKey); - } + @Override + public Response intercept(Chain chain) throws IOException { + Request original = chain.request(); + Request.Builder newRequestBuilder = original.newBuilder(); - // Endpoint requires signing the payload - if (isSignatureRequired) { - String payload = original.url().query(); - if (!StringUtils.isEmpty(payload)) { - String signature = HmacSHA256Signer.sign(payload, secret); - HttpUrl signedUrl = original.url().newBuilder().addQueryParameter("signature", signature).build(); - newRequestBuilder.url(signedUrl); - } - } + boolean isApiKeyRequired = original.header(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY) != null; + boolean isSignatureRequired = original.header(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED) != null; + newRequestBuilder.removeHeader(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY) + .removeHeader(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED); - // Build new request after adding the necessary authentication information - Request newRequest = newRequestBuilder.build(); - return chain.proceed(newRequest); + // Endpoint requires sending a valid API-KEY + if (isApiKeyRequired || isSignatureRequired) { + newRequestBuilder.addHeader(BinanceApiConstants.API_KEY_HEADER, apiKey); } - /** - * Extracts the request body into a String. - * - * @return request body as a string - */ - @SuppressWarnings("unused") - private static String bodyToString(RequestBody request) { - try (final Buffer buffer = new Buffer()) { - final RequestBody copy = request; - if (copy != null) { - copy.writeTo(buffer); - } else { - return ""; - } - return buffer.readUtf8(); - } catch (IOException e) { - throw new RuntimeException(e); - } + // Endpoint requires signing the payload + if (isSignatureRequired) { + String payload = original.url().query(); + if (!StringUtils.isEmpty(payload)) { + String signature = HmacSHA256Signer.sign(payload, secret); + HttpUrl signedUrl = original.url().newBuilder().addQueryParameter("signature", signature).build(); + newRequestBuilder.url(signedUrl); + } } - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final AuthenticationInterceptor that = (AuthenticationInterceptor) o; - return Objects.equals(apiKey, that.apiKey) && - Objects.equals(secret, that.secret); - } + // Build new request after adding the necessary authentication information + Request newRequest = newRequestBuilder.build(); + return chain.proceed(newRequest); + } - @Override - public int hashCode() { - return Objects.hash(apiKey, secret); + /** + * Extracts the request body into a String. + * + * @return request body as a string + */ + @SuppressWarnings("unused") + private static String bodyToString(RequestBody request) { + try (final Buffer buffer = new Buffer()) { + final RequestBody copy = request; + if (copy != null) { + copy.writeTo(buffer); + } else { + return ""; + } + return buffer.readUtf8(); + } catch (IOException e) { + throw new RuntimeException(e); } + } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final AuthenticationInterceptor that = (AuthenticationInterceptor) o; + return Objects.equals(apiKey, that.apiKey) && + Objects.equals(secret, that.secret); + } + + @Override + public int hashCode() { + return Objects.hash(apiKey, secret); + } } \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/security/HmacSHA256Signer.java b/src/main/java/com/binance/api/client/security/HmacSHA256Signer.java index 17309e273..be29e2b5e 100755 --- a/src/main/java/com/binance/api/client/security/HmacSHA256Signer.java +++ b/src/main/java/com/binance/api/client/security/HmacSHA256Signer.java @@ -12,8 +12,9 @@ public class HmacSHA256Signer { /** * Sign the given message using the given secret. + * * @param message message to sign - * @param secret secret key + * @param secret secret key * @return a signed message */ public static String sign(String message, String secret) { From 98e7fded0ebff83a818eee68008b293897229d64 Mon Sep 17 00:00:00 2001 From: Girts Strazdins Date: Thu, 29 Dec 2022 09:39:00 +0100 Subject: [PATCH 04/14] Remove many things which won't be required in our use-cases (margin-trading, borrowing, sub-accounts, etc) Also: * Some simple grammar fixes. * WebSocket does not implement Closeable, as the close() method was marked as deprecated anyway --- .../BinanceApiAsyncMarginRestClient.java | 112 ------- .../api/client/BinanceApiAsyncRestClient.java | 8 +- .../api/client/BinanceApiClientFactory.java | 21 -- .../client/BinanceApiMarginRestClient.java | 134 -------- .../api/client/BinanceApiRestClient.java | 25 +- .../api/client/BinanceApiSwapRestClient.java | 94 ------ .../api/client/BinanceApiWebSocketClient.java | 8 +- .../LiquidityOperationRecordStatus.java | 16 - .../binance/api/client/domain/LoanStatus.java | 11 - .../api/client/domain/SwapRemoveType.java | 8 - .../api/client/domain/TransferType.java | 21 -- .../domain/account/CrossMarginAssets.java | 74 ----- .../account/LiquidityOperationRecord.java | 83 ----- .../api/client/domain/account/Loan.java | 48 --- .../domain/account/LoanQueryResult.java | 33 -- .../client/domain/account/MarginAccount.java | 121 -------- .../domain/account/MarginAssetBalance.java | 103 ------- .../client/domain/account/MarginNewOrder.java | 289 ------------------ .../account/MarginNewOrderResponse.java | 210 ------------- .../domain/account/MarginTransaction.java | 29 -- .../api/client/domain/account/NewOCO.java | 241 --------------- .../api/client/domain/account/Repay.java | 85 ------ .../domain/account/RepayQueryResult.java | 41 --- .../client/domain/account/SideEffectType.java | 17 -- .../domain/account/SubAccountTransfer.java | 159 ---------- .../client/domain/account/SwapHistory.java | 101 ------ .../api/client/domain/account/SwapQuote.java | 81 ----- .../api/client/domain/account/SwapRecord.java | 21 -- .../api/client/domain/account/SwapStatus.java | 18 -- .../event/AssetBalanceDeserializer.java | 5 +- .../client/domain/general/ExchangeInfo.java | 2 +- .../BinanceApiAsyncMarginRestClientImpl.java | 103 ------- .../impl/BinanceApiMarginRestClientImpl.java | 119 -------- .../client/impl/BinanceApiRestClientImpl.java | 15 +- .../api/client/impl/BinanceApiService.java | 145 --------- .../impl/BinanceApiSwapRestClientImpl.java | 115 ------- .../impl/BinanceApiWebSocketClientImpl.java | 9 +- .../MarginAccountEndpointsExample.java | 41 --- .../MarginAccountEndpointsExampleAsync.java | 36 --- ...arginAccountEndpointsLoanQueryExample.java | 28 -- .../api/examples/MarginOrdersExample.java | 49 --- .../examples/MarginOrdersExampleAsync.java | 36 --- .../examples/MarginUserDataStreamExample.java | 55 ---- .../api/examples/SwapEndpointExample.java | 32 -- 44 files changed, 16 insertions(+), 2986 deletions(-) delete mode 100755 src/main/java/com/binance/api/client/BinanceApiAsyncMarginRestClient.java delete mode 100755 src/main/java/com/binance/api/client/BinanceApiMarginRestClient.java delete mode 100755 src/main/java/com/binance/api/client/BinanceApiSwapRestClient.java delete mode 100755 src/main/java/com/binance/api/client/domain/LiquidityOperationRecordStatus.java delete mode 100755 src/main/java/com/binance/api/client/domain/LoanStatus.java delete mode 100755 src/main/java/com/binance/api/client/domain/SwapRemoveType.java delete mode 100755 src/main/java/com/binance/api/client/domain/TransferType.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/CrossMarginAssets.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/LiquidityOperationRecord.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/Loan.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/LoanQueryResult.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/MarginAccount.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/MarginAssetBalance.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/MarginNewOrder.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/MarginNewOrderResponse.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/MarginTransaction.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/NewOCO.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/Repay.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/RepayQueryResult.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/SideEffectType.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/SubAccountTransfer.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/SwapHistory.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/SwapQuote.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/SwapRecord.java delete mode 100755 src/main/java/com/binance/api/client/domain/account/SwapStatus.java delete mode 100755 src/main/java/com/binance/api/client/impl/BinanceApiAsyncMarginRestClientImpl.java delete mode 100755 src/main/java/com/binance/api/client/impl/BinanceApiMarginRestClientImpl.java delete mode 100755 src/main/java/com/binance/api/client/impl/BinanceApiSwapRestClientImpl.java delete mode 100755 src/test/java/com/binance/api/examples/MarginAccountEndpointsExample.java delete mode 100755 src/test/java/com/binance/api/examples/MarginAccountEndpointsExampleAsync.java delete mode 100755 src/test/java/com/binance/api/examples/MarginAccountEndpointsLoanQueryExample.java delete mode 100755 src/test/java/com/binance/api/examples/MarginOrdersExample.java delete mode 100755 src/test/java/com/binance/api/examples/MarginOrdersExampleAsync.java delete mode 100755 src/test/java/com/binance/api/examples/MarginUserDataStreamExample.java delete mode 100755 src/test/java/com/binance/api/examples/SwapEndpointExample.java diff --git a/src/main/java/com/binance/api/client/BinanceApiAsyncMarginRestClient.java b/src/main/java/com/binance/api/client/BinanceApiAsyncMarginRestClient.java deleted file mode 100755 index 91d7a551b..000000000 --- a/src/main/java/com/binance/api/client/BinanceApiAsyncMarginRestClient.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.binance.api.client; - -import com.binance.api.client.domain.TransferType; -import com.binance.api.client.domain.account.*; -import com.binance.api.client.domain.account.request.CancelOrderRequest; -import com.binance.api.client.domain.account.request.CancelOrderResponse; -import com.binance.api.client.domain.account.request.OrderRequest; -import com.binance.api.client.domain.account.request.OrderStatusRequest; -import com.binance.api.client.domain.event.ListenKey; - -import java.util.List; - -/** - * Binance API façade, supporting asynchronous/non-blocking access Binance's Margin REST API. - */ -public interface BinanceApiAsyncMarginRestClient { - - // Account endpoints - - /** - * Get current margin account information (async). - */ - void getAccount(Long recvWindow, Long timestamp, BinanceApiCallback callback); - - /** - * Get current margin account information using default parameters (async). - */ - void getAccount(BinanceApiCallback callback); - - /** - * Get all open orders on margin account for a symbol (async). - * - * @param orderRequest order request parameters - * @param callback the callback that handles the response - */ - void getOpenOrders(OrderRequest orderRequest, BinanceApiCallback> callback); - - /** - * Send in a new margin order (async). - * - * @param order the new order to submit. - * @return a response containing details about the newly placed order. - */ - void newOrder(MarginNewOrder order, BinanceApiCallback callback); - - /** - * Cancel an active margin order (async). - * - * @param cancelOrderRequest order status request parameters - */ - void cancelOrder(CancelOrderRequest cancelOrderRequest, BinanceApiCallback callback); - - /** - * Check margin order's status (async). - * - * @param orderStatusRequest order status request options/filters - * @return an order - */ - void getOrderStatus(OrderStatusRequest orderStatusRequest, BinanceApiCallback callback); - - /** - * Get margin trades for a specific symbol (async). - * - * @param symbol symbol to get trades from - * @return a list of trades - */ - void getMyTrades(String symbol, BinanceApiCallback> callback); - - // User stream endpoints - - /** - * Start a new user data stream (async). - * - * @return a listen key that can be used with data streams - */ - void startUserDataStream(BinanceApiCallback callback); - - /** - * PING a user data stream to prevent a time out (async). - * - * @param listenKey listen key that identifies a data stream - */ - void keepAliveUserDataStream(String listenKey, BinanceApiCallback callback); - - /** - * Execute transfer between spot account and margin account - * - * @param asset asset to repay - * @param amount amount to repay - * @return transaction id - */ - void transfer(String asset, String amount, TransferType type, BinanceApiCallback callback); - - /** - * Apply for a loan - * - * @param asset asset to repay - * @param amount amount to repay - * @return transaction id - */ - void borrow(String asset, String amount, BinanceApiCallback callback); - - /** - * Repay loan for margin account - * - * @param asset asset to repay - * @param amount amount to repay - * @return transaction id - */ - void repay(String asset, String amount, BinanceApiCallback callback); - -} \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java b/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java index 44e337a7a..38d377883 100755 --- a/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java @@ -52,7 +52,7 @@ public interface BinanceApiAsyncRestClient { void getExchangeInfo(BinanceApiCallback callback); /** - * ALL supported assets and whether or not they can be withdrawn. + * ALL supported assets and whether they can be withdrawn. */ void getAllAssets(BinanceApiCallback> callback); @@ -145,14 +145,14 @@ public interface BinanceApiAsyncRestClient { void getAll24HrPriceStatistics(BinanceApiCallback> callback); /** - * Get Latest price for all symbols (asynchronous). + * Get the latest price for all symbols (asynchronous). * * @param callback the callback that handles the response */ void getAllPrices(BinanceApiCallback> callback); /** - * Get latest price for symbol (asynchronous). + * Get the latest price for symbol (asynchronous). * * @param symbol ticker symbol (e.g. ETHBTC) * @param callback the callback that handles the response @@ -254,7 +254,7 @@ public interface BinanceApiAsyncRestClient { void getMyTrades(String symbol, BinanceApiCallback> callback); /** - * Submit a withdraw request. + * Submit a withdrawal request. *

* Enable Withdrawals option has to be active in the API settings. * diff --git a/src/main/java/com/binance/api/client/BinanceApiClientFactory.java b/src/main/java/com/binance/api/client/BinanceApiClientFactory.java index 66de5fa7c..18939de4b 100755 --- a/src/main/java/com/binance/api/client/BinanceApiClientFactory.java +++ b/src/main/java/com/binance/api/client/BinanceApiClientFactory.java @@ -106,31 +106,10 @@ public BinanceApiAsyncRestClient newAsyncRestClient() { return new BinanceApiAsyncRestClientImpl(apiKey, secret); } - /** - * Creates a new asynchronous/non-blocking Margin REST client. - */ - public BinanceApiAsyncMarginRestClient newAsyncMarginRestClient() { - return new BinanceApiAsyncMarginRestClientImpl(apiKey, secret); - } - - /** - * Creates a new synchronous/blocking Margin REST client. - */ - public BinanceApiMarginRestClient newMarginRestClient() { - return new BinanceApiMarginRestClientImpl(apiKey, secret); - } - /** * Creates a new web socket client used for handling data streams. */ public BinanceApiWebSocketClient newWebSocketClient() { return new BinanceApiWebSocketClientImpl(getSharedClient()); } - - /** - * Creates a new synchronous/blocking Swap REST client. - */ - public BinanceApiSwapRestClient newSwapRestClient() { - return new BinanceApiSwapRestClientImpl(apiKey, secret); - } } diff --git a/src/main/java/com/binance/api/client/BinanceApiMarginRestClient.java b/src/main/java/com/binance/api/client/BinanceApiMarginRestClient.java deleted file mode 100755 index f682b9039..000000000 --- a/src/main/java/com/binance/api/client/BinanceApiMarginRestClient.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.binance.api.client; - -import com.binance.api.client.domain.TransferType; -import com.binance.api.client.domain.account.*; -import com.binance.api.client.domain.account.request.CancelOrderRequest; -import com.binance.api.client.domain.account.request.CancelOrderResponse; -import com.binance.api.client.domain.account.request.OrderRequest; -import com.binance.api.client.domain.account.request.OrderStatusRequest; - -import java.util.List; - -public interface BinanceApiMarginRestClient { - /** - * Get current margin account information using default parameters. - */ - MarginAccount getAccount(); - - /** - * Get all open orders on margin account for a symbol. - * - * @param orderRequest order request parameters - */ - List getOpenOrders(OrderRequest orderRequest); - - /** - * Send in a new margin order. - * - * @param order the new order to submit. - * @return a response containing details about the newly placed order. - */ - MarginNewOrderResponse newOrder(MarginNewOrder order); - - /** - * Cancel an active margin order. - * - * @param cancelOrderRequest order status request parameters - */ - CancelOrderResponse cancelOrder(CancelOrderRequest cancelOrderRequest); - - /** - * Check margin order's status. - * - * @param orderStatusRequest order status request options/filters - * @return an order - */ - Order getOrderStatus(OrderStatusRequest orderStatusRequest); - - /** - * Get margin trades for a specific symbol. - * - * @param symbol symbol to get trades from - * @return a list of trades - */ - List getMyTrades(String symbol); - - // User stream endpoints - - /** - * Start a new user data stream. - * - * @return a listen key that can be used with data streams - */ - String startUserDataStream(); - - /** - * PING a user data stream to prevent a time out. - * - * @param listenKey listen key that identifies a data stream - */ - void keepAliveUserDataStream(String listenKey); - - /** - * Execute transfer between spot account and margin account - * - * @param asset asset to repay - * @param amount amount to repay - * @return transaction id - */ - MarginTransaction transfer(String asset, String amount, TransferType type); - - /** - * Apply for a loan - * - * @param asset asset to repay - * @param amount amount to repay - * @return transaction id - */ - MarginTransaction borrow(String asset, String amount); - - /** - * Query loan record - * - * @param asset asset to query - * @return repay records - */ - RepayQueryResult queryRepay(String asset, long startTime); - - /** - * Query max borrowable - * - * @param asset asset to query - * @return max borrowable - */ - MaxBorrowableQueryResult queryMaxBorrowable(String asset); - - /** - * Query loan record - * - * @param asset asset to query - * @param txId the tranId in POST /sapi/v1/margin/repay - * @return loan records - */ - RepayQueryResult queryRepay(String asset, String txId); - - /** - * Repay loan for margin account - * - * @param asset asset to repay - * @param amount amount to repay - * @return transaction id - */ - MarginTransaction repay(String asset, String amount); - - /** - * Query loan record - * - * @param asset asset to query - * @param txId the tranId in POST /sapi/v1/margin/loan - * @return loan records - */ - LoanQueryResult queryLoan(String asset, String txId); - - -} diff --git a/src/main/java/com/binance/api/client/BinanceApiRestClient.java b/src/main/java/com/binance/api/client/BinanceApiRestClient.java index 1aaea131b..721310474 100755 --- a/src/main/java/com/binance/api/client/BinanceApiRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiRestClient.java @@ -39,7 +39,7 @@ public interface BinanceApiRestClient { ExchangeInfo getExchangeInfo(); /** - * @return All the supported assets and whether or not they can be withdrawn. + * @return All the supported assets and whether they can be withdrawn. */ List getAllAssets(); @@ -125,12 +125,12 @@ public interface BinanceApiRestClient { List getAll24HrPriceStatistics(); /** - * Get Latest price for all symbols. + * Get the latest price for all symbols. */ List getAllPrices(); /** - * Get latest price for symbol. + * Get the latest price for symbol. * * @param symbol ticker symbol (e.g. ETHBTC) */ @@ -189,14 +189,6 @@ public interface BinanceApiRestClient { */ List getAllOrders(AllOrdersRequest orderRequest); - /** - * Send in a new OCO; - * - * @param oco the OCO to submit - * @return a response containing details about the newly placed OCO. - */ - NewOCOResponse newOCO(NewOCO oco); - /** * Cancel an entire Order List * @@ -260,7 +252,7 @@ public interface BinanceApiRestClient { List getMyTrades(String symbol, Long fromId); /** - * Submit a withdraw request. + * Submit a withdrawal request. *

* Enable Withdrawals option has to be active in the API settings. * @@ -277,7 +269,7 @@ public interface BinanceApiRestClient { * * @param asset the list of assets to convert */ - DustTransferResponse dustTranfer(List asset); + DustTransferResponse dustTransfer(List asset); /** * Fetch account deposit history. @@ -293,13 +285,6 @@ public interface BinanceApiRestClient { */ WithdrawHistory getWithdrawHistory(String asset); - /** - * Fetch sub-account transfer history. - * - * @return sub-account transfers - */ - List getSubAccountTransfers(); - /** * Fetch deposit address. * diff --git a/src/main/java/com/binance/api/client/BinanceApiSwapRestClient.java b/src/main/java/com/binance/api/client/BinanceApiSwapRestClient.java deleted file mode 100755 index 790efda5e..000000000 --- a/src/main/java/com/binance/api/client/BinanceApiSwapRestClient.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.binance.api.client; - -import com.binance.api.client.domain.SwapRemoveType; -import com.binance.api.client.domain.account.*; -import retrofit2.Call; -import retrofit2.http.Query; - -import java.util.List; - -public interface BinanceApiSwapRestClient { - - /** - * Get metadata about all swap pools. - * - * @return - */ - List listAllSwapPools(); - - /** - * Get liquidity information and user share of a pool. - * - * @param poolId - * @return - */ - Liquidity getPoolLiquidityInfo(String poolId); - - /** - * Add liquidity to a pool. - * - * @param poolId - * @param asset - * @param quantity - * @return - */ - LiquidityOperationRecord addLiquidity(String poolId, - String asset, - String quantity); - - /** - * Remove liquidity from a pool, type include SINGLE and COMBINATION, asset is mandatory for single asset removal - * - * @param poolId - * @param type - * @param asset - * @param shareAmount - * @return - */ - LiquidityOperationRecord removeLiquidity(String poolId, SwapRemoveType type, List asset, String shareAmount); - - /** - * Get liquidity operation (add/remove) records of a pool - * - * @param poolId - * @param limit - * @return - */ - List getPoolLiquidityOperationRecords( - String poolId, - Integer limit); - - /** - * Get liquidity operation (add/remove) record. - * - * @param operationId - * @return - */ - LiquidityOperationRecord getLiquidityOperationRecord(String operationId); - - /** - * Request a quote for swap quote asset (selling asset) for base asset (buying asset), essentially price/exchange rates. - * - * @param quoteAsset - * @param baseAsset - * @param quoteQty - * @return - */ - SwapQuote requestQuote(String quoteAsset, - String baseAsset, - String quoteQty); - - /** - * Swap quoteAsset for baseAsset - * - * @param quoteAsset - * @param baseAsset - * @param quoteQty - * @return - */ - SwapRecord swap(String quoteAsset, - String baseAsset, - String quoteQty); - - SwapHistory getSwapHistory(String swapId); -} diff --git a/src/main/java/com/binance/api/client/BinanceApiWebSocketClient.java b/src/main/java/com/binance/api/client/BinanceApiWebSocketClient.java index d8b2bdbd0..c57abeb81 100755 --- a/src/main/java/com/binance/api/client/BinanceApiWebSocketClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiWebSocketClient.java @@ -9,7 +9,7 @@ /** * Binance API data streaming facade, supporting streaming of events through web sockets. */ -public interface BinanceApiWebSocketClient extends Closeable { +public interface BinanceApiWebSocketClient { /** * Open a new web socket to receive {@link DepthEvent depthEvents} on a callback. @@ -81,10 +81,4 @@ public interface BinanceApiWebSocketClient extends Closeable { * @return a {@link Closeable} that allows the underlying web socket to be closed. */ Closeable onAllBookTickersEvent(BinanceApiCallback callback); - - /** - * @deprecated This method is no longer functional. Please use the returned {@link Closeable} from any of the other methods to close the web socket. - */ - @Deprecated - void close(); } diff --git a/src/main/java/com/binance/api/client/domain/LiquidityOperationRecordStatus.java b/src/main/java/com/binance/api/client/domain/LiquidityOperationRecordStatus.java deleted file mode 100755 index 8a776e83f..000000000 --- a/src/main/java/com/binance/api/client/domain/LiquidityOperationRecordStatus.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.binance.api.client.domain; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonValue; - -@JsonIgnoreProperties(ignoreUnknown = true) -public enum LiquidityOperationRecordStatus { - PENDING, - SUCCESS, - FAILED; - - @JsonValue - public int toValue() { - return ordinal(); - } -} diff --git a/src/main/java/com/binance/api/client/domain/LoanStatus.java b/src/main/java/com/binance/api/client/domain/LoanStatus.java deleted file mode 100755 index 802e9981b..000000000 --- a/src/main/java/com/binance/api/client/domain/LoanStatus.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.binance.api.client.domain; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -/** - * Status of a submitted order. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public enum LoanStatus { - PENDING, CONFIRMED, FAILED -} diff --git a/src/main/java/com/binance/api/client/domain/SwapRemoveType.java b/src/main/java/com/binance/api/client/domain/SwapRemoveType.java deleted file mode 100755 index cd96e6231..000000000 --- a/src/main/java/com/binance/api/client/domain/SwapRemoveType.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.binance.api.client.domain; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -@JsonIgnoreProperties(ignoreUnknown = true) -public enum SwapRemoveType { - SINGLE, COMBINATION -} diff --git a/src/main/java/com/binance/api/client/domain/TransferType.java b/src/main/java/com/binance/api/client/domain/TransferType.java deleted file mode 100755 index 7d39d18a7..000000000 --- a/src/main/java/com/binance/api/client/domain/TransferType.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.binance.api.client.domain; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -/** - * Status of a submitted order. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public enum TransferType { - SPOT_TO_MARGIN("1"), MARGIN_TO_SPOT("2"); - - private String value; - - TransferType(String value) { - this.value = value; - } - - public String getValue() { - return value; - } -} diff --git a/src/main/java/com/binance/api/client/domain/account/CrossMarginAssets.java b/src/main/java/com/binance/api/client/domain/account/CrossMarginAssets.java deleted file mode 100755 index ef7ab9e79..000000000 --- a/src/main/java/com/binance/api/client/domain/account/CrossMarginAssets.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.binance.api.client.domain.account; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class CrossMarginAssets { - - public String assetFullName; - public String assetName; - public boolean isBorrowable; - public boolean isMortgageable; - public String userMinBorrow; - public String userMinRepay; - - public String getAssetFullName() { - return assetFullName; - } - - public void setAssetFullName(String assetFullName) { - this.assetFullName = assetFullName; - } - - public String getAssetName() { - return assetName; - } - - public void setAssetName(String assetName) { - this.assetName = assetName; - } - - public boolean isBorrowable() { - return isBorrowable; - } - - public void setBorrowable(boolean borrowable) { - isBorrowable = borrowable; - } - - public boolean isMortgageable() { - return isMortgageable; - } - - public void setMortgageable(boolean mortgageable) { - isMortgageable = mortgageable; - } - - public String getUserMinBorrow() { - return userMinBorrow; - } - - public void setUserMinBorrow(String userMinBorrow) { - this.userMinBorrow = userMinBorrow; - } - - public String getUserMinRepay() { - return userMinRepay; - } - - public void setUserMinRepay(String userMinRepay) { - this.userMinRepay = userMinRepay; - } - - @Override - public String toString() { - return "CrossMarginAssets{" + - "assetFullName='" + assetFullName + '\'' + - ", assetName='" + assetName + '\'' + - ", isBorrowable=" + isBorrowable + - ", isMortgageable=" + isMortgageable + - ", userMinBorrow='" + userMinBorrow + '\'' + - ", userMinRepay='" + userMinRepay + '\'' + - '}'; - } -} diff --git a/src/main/java/com/binance/api/client/domain/account/LiquidityOperationRecord.java b/src/main/java/com/binance/api/client/domain/account/LiquidityOperationRecord.java deleted file mode 100755 index 2043a4390..000000000 --- a/src/main/java/com/binance/api/client/domain/account/LiquidityOperationRecord.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.binance.api.client.domain.account; - -import com.binance.api.client.domain.LiquidityOperationRecordStatus; - -public class LiquidityOperationRecord { - - private String poolId; - private String operationId; - private String updateTime; - private String operation; - private String shareAmount; - private String poolName; - private LiquidityOperationRecordStatus status; - - public String getPoolId() { - return poolId; - } - - public void setPoolId(String poolId) { - this.poolId = poolId; - } - - public String getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getOperation() { - return operation; - } - - public void setOperation(String operation) { - this.operation = operation; - } - - public String getShareAmount() { - return shareAmount; - } - - public void setShareAmount(String shareAmount) { - this.shareAmount = shareAmount; - } - - public String getPoolName() { - return poolName; - } - - public void setPoolName(String poolName) { - this.poolName = poolName; - } - - public LiquidityOperationRecordStatus getStatus() { - return status; - } - - public void setStatus(LiquidityOperationRecordStatus status) { - this.status = status; - } - - public String getOperationId() { - return operationId; - } - - public void setOperationId(String operationId) { - this.operationId = operationId; - } - - @Override - public String toString() { - return "LiquidityOperationRecord{" + - "poolId='" + poolId + '\'' + - ", operationId='" + operationId + '\'' + - ", updateTime='" + updateTime + '\'' + - ", operation='" + operation + '\'' + - ", shareAmount='" + shareAmount + '\'' + - ", poolName='" + poolName + '\'' + - ", status='" + status + '\'' + - '}'; - } -} diff --git a/src/main/java/com/binance/api/client/domain/account/Loan.java b/src/main/java/com/binance/api/client/domain/account/Loan.java deleted file mode 100755 index ef14cec75..000000000 --- a/src/main/java/com/binance/api/client/domain/account/Loan.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.binance.api.client.domain.account; - -import com.binance.api.client.domain.LoanStatus; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -/** - * Represents an executed trade history item. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class Loan { - - private String asset; - private String principal; - private long timestamp; - private LoanStatus status; - - public String getAsset() { - return asset; - } - - public void setAsset(String asset) { - this.asset = asset; - } - - public String getPrincipal() { - return principal; - } - - public void setPrincipal(String principal) { - this.principal = principal; - } - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public LoanStatus getStatus() { - return status; - } - - public void setStatus(LoanStatus status) { - this.status = status; - } -} diff --git a/src/main/java/com/binance/api/client/domain/account/LoanQueryResult.java b/src/main/java/com/binance/api/client/domain/account/LoanQueryResult.java deleted file mode 100755 index 46a696531..000000000 --- a/src/main/java/com/binance/api/client/domain/account/LoanQueryResult.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.binance.api.client.domain.account; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -import java.util.List; - -/** - * History of account withdrawals. - * - * @see Withdraw - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class LoanQueryResult { - - private int total; - private List rows; - - public int getTotal() { - return total; - } - - public void setTotal(int total) { - this.total = total; - } - - public List getRows() { - return rows; - } - - public void setRows(List rows) { - this.rows = rows; - } -} diff --git a/src/main/java/com/binance/api/client/domain/account/MarginAccount.java b/src/main/java/com/binance/api/client/domain/account/MarginAccount.java deleted file mode 100755 index 8eb278ac6..000000000 --- a/src/main/java/com/binance/api/client/domain/account/MarginAccount.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.binance.api.client.domain.account; - -import com.binance.api.client.constant.BinanceApiConstants; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import org.apache.commons.lang3.builder.ToStringBuilder; - -import java.util.List; - -/** - * Account information. - */ -@JsonIgnoreProperties -public class MarginAccount { - - private boolean borrowEnabled; - - private String marginLevel; - - private String totalAssetOfBtc; - - private String totalLiabilityOfBtc; - - private String totalNetAssetOfBtc; - - private boolean tradeEnabled; - - private boolean transferEnabled; - - private List userAssets; - - public boolean isBorrowEnabled() { - return borrowEnabled; - } - - public void setBorrowEnabled(boolean borrowEnabled) { - this.borrowEnabled = borrowEnabled; - } - - public String getMarginLevel() { - return marginLevel; - } - - public void setMarginLevel(String marginLevel) { - this.marginLevel = marginLevel; - } - - public String getTotalAssetOfBtc() { - return totalAssetOfBtc; - } - - public void setTotalAssetOfBtc(String totalAssetOfBtc) { - this.totalAssetOfBtc = totalAssetOfBtc; - } - - public String getTotalLiabilityOfBtc() { - return totalLiabilityOfBtc; - } - - public void setTotalLiabilityOfBtc(String totalLiabilityOfBtc) { - this.totalLiabilityOfBtc = totalLiabilityOfBtc; - } - - public String getTotalNetAssetOfBtc() { - return totalNetAssetOfBtc; - } - - public void setTotalNetAssetOfBtc(String totalNetAssetOfBtc) { - this.totalNetAssetOfBtc = totalNetAssetOfBtc; - } - - public boolean isTradeEnabled() { - return tradeEnabled; - } - - public void setTradeEnabled(boolean tradeEnabled) { - this.tradeEnabled = tradeEnabled; - } - - public boolean isTransferEnabled() { - return transferEnabled; - } - - public void setTransferEnabled(boolean transferEnabled) { - this.transferEnabled = transferEnabled; - } - - public List getUserAssets() { - return userAssets; - } - - public void setUserAssets(List userAssets) { - this.userAssets = userAssets; - } - - /** - * Returns the asset balance for a given symbol. - * - * @param symbol asset symbol to obtain the balances from - * @return an asset balance for the given symbol which can be 0 in case the symbol has no balance in the account - */ - public MarginAssetBalance getAssetBalance(final String symbol) { - return userAssets.stream() - .filter(marginAssetBalance -> marginAssetBalance.getAsset().equals(symbol)) - .findFirst() - .orElse(MarginAssetBalance.of(symbol)); - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("borrowEnabled", borrowEnabled) - .append("marginLevel", marginLevel) - .append("totalAssetOfBtc", totalAssetOfBtc) - .append("totalLiabilityOfBtc", totalLiabilityOfBtc) - .append("totalNetAssetOfBtc", totalNetAssetOfBtc) - .append("tradeEnabled", tradeEnabled) - .append("transferEnabled", transferEnabled) - .append("userAssets", userAssets) - .toString(); - } -} diff --git a/src/main/java/com/binance/api/client/domain/account/MarginAssetBalance.java b/src/main/java/com/binance/api/client/domain/account/MarginAssetBalance.java deleted file mode 100755 index db949e851..000000000 --- a/src/main/java/com/binance/api/client/domain/account/MarginAssetBalance.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.binance.api.client.domain.account; - -import com.binance.api.client.constant.BinanceApiConstants; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import org.apache.commons.lang3.builder.ToStringBuilder; - -/** - * An asset balance in an Account. - * - * @see Account - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class MarginAssetBalance { - - public static MarginAssetBalance of(final String asset) { - final MarginAssetBalance marginAssetBalance = new MarginAssetBalance(); - - marginAssetBalance.setAsset(asset); - - return marginAssetBalance; - } - - /** - * Asset symbol. - */ - private String asset; - - private String borrowed = "0"; - - /** - * Available balance. - */ - private String free = "0"; - - private String interest = "0"; - - /** - * Locked by open orders. - */ - private String locked = "0"; - - private String netAsset = "0"; - - public String getAsset() { - return asset; - } - - public void setAsset(String asset) { - this.asset = asset; - } - - public String getBorrowed() { - return borrowed; - } - - public void setBorrowed(String borrowed) { - this.borrowed = borrowed; - } - - public String getFree() { - return free; - } - - public void setFree(String free) { - this.free = free; - } - - public String getInterest() { - return interest; - } - - public void setInterest(String interest) { - this.interest = interest; - } - - public String getLocked() { - return locked; - } - - public void setLocked(String locked) { - this.locked = locked; - } - - public String getNetAsset() { - return netAsset; - } - - public void setNetAsset(String netAsset) { - this.netAsset = netAsset; - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("asset", asset) - .append("borrowed", borrowed) - .append("free", free) - .append("interest", interest) - .append("locked", locked) - .append("netAsset", netAsset) - .toString(); - } -} diff --git a/src/main/java/com/binance/api/client/domain/account/MarginNewOrder.java b/src/main/java/com/binance/api/client/domain/account/MarginNewOrder.java deleted file mode 100755 index 1015354c1..000000000 --- a/src/main/java/com/binance/api/client/domain/account/MarginNewOrder.java +++ /dev/null @@ -1,289 +0,0 @@ -package com.binance.api.client.domain.account; - -import com.binance.api.client.constant.BinanceApiConstants; -import com.binance.api.client.domain.OrderSide; -import com.binance.api.client.domain.OrderType; -import com.binance.api.client.domain.TimeInForce; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import org.apache.commons.lang3.builder.ToStringBuilder; - -/** - * A trade order to enter or exit a position. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class MarginNewOrder { - - /** - * Symbol to place the order on. - */ - private String symbol; - - /** - * Buy/Sell order side. - */ - private OrderSide side; - - /** - * Type of order. - */ - private OrderType type; - - /** - * Time in force to indicate how long will the order remain active. - */ - private TimeInForce timeInForce; - - /** - * Quantity. - */ - private String quantity; - - /** - * Quote quantity. - */ - private String quoteOrderQty; - - /** - * Price. - */ - private String price; - - /** - * A unique id for the order. Automatically generated if not sent. - */ - private String newClientOrderId; - - /** - * Used with stop orders. - */ - private String stopPrice; - - /** - * Used with iceberg orders. - */ - private String icebergQty; - - /** - * Set the response JSON. ACK, RESULT, or FULL; default: RESULT. - */ - private NewOrderResponseType newOrderRespType; - - /** - * Set the margin order side-effect. NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY; default: NO_SIDE_EFFECT. - */ - private SideEffectType sideEffectType; - - /** - * Receiving window. - */ - private Long recvWindow; - - /** - * Order timestamp. - */ - private long timestamp; - - /** - * Creates a new order with all required parameters. - */ - public MarginNewOrder(String symbol, OrderSide side, OrderType type, TimeInForce timeInForce, String quantity) { - this.symbol = symbol; - this.side = side; - this.type = type; - this.timeInForce = timeInForce; - this.quantity = quantity; - this.newOrderRespType = NewOrderResponseType.RESULT; - this.timestamp = System.currentTimeMillis(); - this.recvWindow = BinanceApiConstants.DEFAULT_RECEIVING_WINDOW; - } - - /** - * Creates a new order with all required parameters plus price, which is optional for MARKET orders. - */ - public MarginNewOrder(String symbol, OrderSide side, OrderType type, TimeInForce timeInForce, String quantity, String price) { - this(symbol, side, type, timeInForce, quantity); - this.price = price; - } - - public String getSymbol() { - return symbol; - } - - public MarginNewOrder symbol(String symbol) { - this.symbol = symbol; - return this; - } - - public OrderSide getSide() { - return side; - } - - public MarginNewOrder side(OrderSide side) { - this.side = side; - return this; - } - - public OrderType getType() { - return type; - } - - public MarginNewOrder type(OrderType type) { - this.type = type; - return this; - } - - public TimeInForce getTimeInForce() { - return timeInForce; - } - - public MarginNewOrder timeInForce(TimeInForce timeInForce) { - this.timeInForce = timeInForce; - return this; - } - - public String getQuantity() { - return quantity; - } - - public MarginNewOrder quantity(String quantity) { - this.quantity = quantity; - return this; - } - - public String getQuoteOrderQty() { - return quoteOrderQty; - } - - public MarginNewOrder quoteOrderQty(String quoteOrderQty) { - this.quoteOrderQty = quoteOrderQty; - return this; - } - - public String getPrice() { - return price; - } - - public MarginNewOrder price(String price) { - this.price = price; - return this; - } - - public String getNewClientOrderId() { - return newClientOrderId; - } - - public MarginNewOrder newClientOrderId(String newClientOrderId) { - this.newClientOrderId = newClientOrderId; - return this; - } - - public String getStopPrice() { - return stopPrice; - } - - public MarginNewOrder stopPrice(String stopPrice) { - this.stopPrice = stopPrice; - return this; - } - - public String getIcebergQty() { - return icebergQty; - } - - public MarginNewOrder icebergQty(String icebergQty) { - this.icebergQty = icebergQty; - return this; - } - - public NewOrderResponseType getNewOrderRespType() { - return newOrderRespType; - } - - public MarginNewOrder newOrderRespType(NewOrderResponseType newOrderRespType) { - this.newOrderRespType = newOrderRespType; - return this; - } - - public SideEffectType getSideEffectType() { - return sideEffectType; - } - - public MarginNewOrder sideEffectType(SideEffectType sideEffectType) { - this.sideEffectType = sideEffectType; - return this; - } - - public Long getRecvWindow() { - return recvWindow; - } - - public MarginNewOrder recvWindow(Long recvWindow) { - this.recvWindow = recvWindow; - return this; - } - - public long getTimestamp() { - return timestamp; - } - - public MarginNewOrder timestamp(long timestamp) { - this.timestamp = timestamp; - return this; - } - - /** - * Places a MARKET buy order for the given quantity. - * - * @return a new order which is pre-configured with MARKET as the order type and BUY as the order side. - */ - public static MarginNewOrder marketBuy(String symbol, String quantity) { - return new MarginNewOrder(symbol, OrderSide.BUY, OrderType.MARKET, null, quantity); - } - - /** - * Places a MARKET sell order for the given quantity. - * - * @return a new order which is pre-configured with MARKET as the order type and SELL as the order side. - */ - public static MarginNewOrder marketSell(String symbol, String quantity) { - return new MarginNewOrder(symbol, OrderSide.SELL, OrderType.MARKET, null, quantity); - } - - /** - * Places a LIMIT buy order for the given quantity and price. - * - * @return a new order which is pre-configured with LIMIT as the order type and BUY as the order side. - */ - public static MarginNewOrder limitBuy(String symbol, TimeInForce timeInForce, String quantity, String price) { - return new MarginNewOrder(symbol, OrderSide.BUY, OrderType.LIMIT, timeInForce, quantity, price); - } - - /** - * Places a LIMIT sell order for the given quantity and price. - * - * @return a new order which is pre-configured with LIMIT as the order type and SELL as the order side. - */ - public static MarginNewOrder limitSell(String symbol, TimeInForce timeInForce, String quantity, String price) { - return new MarginNewOrder(symbol, OrderSide.SELL, OrderType.LIMIT, timeInForce, quantity, price); - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("symbol", symbol) - .append("side", side) - .append("type", type) - .append("timeInForce", timeInForce) - .append("quantity", quantity) - .append("quoteOrderQty", quoteOrderQty) - .append("price", price) - .append("newClientOrderId", newClientOrderId) - .append("stopPrice", stopPrice) - .append("icebergQty", icebergQty) - .append("newOrderRespType", newOrderRespType) - .append("sideEffectType", sideEffectType) - .append("recvWindow", recvWindow) - .append("timestamp", timestamp) - .toString(); - } -} diff --git a/src/main/java/com/binance/api/client/domain/account/MarginNewOrderResponse.java b/src/main/java/com/binance/api/client/domain/account/MarginNewOrderResponse.java deleted file mode 100755 index 1bdb947f0..000000000 --- a/src/main/java/com/binance/api/client/domain/account/MarginNewOrderResponse.java +++ /dev/null @@ -1,210 +0,0 @@ -package com.binance.api.client.domain.account; - -import com.binance.api.client.constant.BinanceApiConstants; -import com.binance.api.client.domain.OrderSide; -import com.binance.api.client.domain.OrderStatus; -import com.binance.api.client.domain.OrderType; -import com.binance.api.client.domain.TimeInForce; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import org.apache.commons.lang3.builder.ToStringBuilder; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - * Response returned when placing a new order on the system. - * - * @see NewOrder for the request - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class MarginNewOrderResponse { - - /** - * Order symbol. - */ - private String symbol; - - /** - * Order id. - */ - private Long orderId; - - /** - * This will be either a generated one, or the newClientOrderId parameter - * which was passed when creating the new order. - */ - private String clientOrderId; - - private String price; - - private String origQty; - - private String executedQty; - - private String cummulativeQuoteQty; - - private OrderStatus status; - - private TimeInForce timeInForce; - - private OrderType type; - - private String marginBuyBorrowAmount; - - private String marginBuyBorrowAsset; - - private OrderSide side; - - // @JsonSetter(nulls = Nulls.AS_EMPTY) - private List fills; - - /** - * Transact time for this order. - */ - private Long transactTime; - - public String getSymbol() { - return symbol; - } - - public void setSymbol(String symbol) { - this.symbol = symbol; - } - - public Long getOrderId() { - return orderId; - } - - public void setOrderId(Long orderId) { - this.orderId = orderId; - } - - public String getClientOrderId() { - return clientOrderId; - } - - public void setClientOrderId(String clientOrderId) { - this.clientOrderId = clientOrderId; - } - - public Long getTransactTime() { - return transactTime; - } - - public void setTransactTime(Long transactTime) { - this.transactTime = transactTime; - } - - public String getPrice() { - return price; - } - - public void setPrice(String price) { - this.price = price; - } - - public String getOrigQty() { - return origQty; - } - - public void setOrigQty(String origQty) { - this.origQty = origQty; - } - - public String getExecutedQty() { - return executedQty; - } - - public void setExecutedQty(String executedQty) { - this.executedQty = executedQty; - } - - public String getCummulativeQuoteQty() { - return cummulativeQuoteQty; - } - - public void setCummulativeQuoteQty(String cummulativeQuoteQty) { - this.cummulativeQuoteQty = cummulativeQuoteQty; - } - - public OrderStatus getStatus() { - return status; - } - - public void setStatus(OrderStatus status) { - this.status = status; - } - - public TimeInForce getTimeInForce() { - return timeInForce; - } - - public void setTimeInForce(TimeInForce timeInForce) { - this.timeInForce = timeInForce; - } - - public OrderType getType() { - return type; - } - - public void setType(OrderType type) { - this.type = type; - } - - public String getMarginBuyBorrowAmount() { - return marginBuyBorrowAmount; - } - - public void setMarginBuyBorrowAmount(String marginBuyBorrowAmount) { - this.marginBuyBorrowAmount = marginBuyBorrowAmount; - } - - public String getMarginBuyBorrowAsset() { - return marginBuyBorrowAsset; - } - - public void setMarginBuyBorrowAsset(String marginBuyBorrowAsset) { - this.marginBuyBorrowAsset = marginBuyBorrowAsset; - } - - public OrderSide getSide() { - return side; - } - - public void setSide(OrderSide side) { - this.side = side; - } - - public List getFills() { - return fills; - } - - public void setFills(List fills) { - this.fills = fills; - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("symbol", symbol) - .append("orderId", orderId) - .append("clientOrderId", clientOrderId) - .append("transactTime", transactTime) - .append("price", price) - .append("origQty", origQty) - .append("executedQty", executedQty) - .append("status", status) - .append("timeInForce", timeInForce) - .append("type", type) - .append("marginBuyBorrowAmount", marginBuyBorrowAmount) - .append("marginBuyBorrowAsset", marginBuyBorrowAsset) - .append("side", side) - .append("fills", Optional.ofNullable(fills).orElse(Collections.emptyList()) - .stream() - .map(Object::toString) - .collect(Collectors.joining(", "))) - .toString(); - } -} diff --git a/src/main/java/com/binance/api/client/domain/account/MarginTransaction.java b/src/main/java/com/binance/api/client/domain/account/MarginTransaction.java deleted file mode 100755 index f08995f1d..000000000 --- a/src/main/java/com/binance/api/client/domain/account/MarginTransaction.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.binance.api.client.domain.account; - -import com.binance.api.client.constant.BinanceApiConstants; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import org.apache.commons.lang3.builder.ToStringBuilder; - -/** - * MarginTransaction information. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class MarginTransaction { - - private String tranId; - - public String getTranId() { - return tranId; - } - - public void setTranId(String tranId) { - this.tranId = tranId; - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("transactionId", tranId) - .toString(); - } -} diff --git a/src/main/java/com/binance/api/client/domain/account/NewOCO.java b/src/main/java/com/binance/api/client/domain/account/NewOCO.java deleted file mode 100755 index 6a68c2ebd..000000000 --- a/src/main/java/com/binance/api/client/domain/account/NewOCO.java +++ /dev/null @@ -1,241 +0,0 @@ -package com.binance.api.client.domain.account; - -import org.apache.commons.lang3.builder.ToStringBuilder; - -import com.binance.api.client.constant.BinanceApiConstants; -import com.binance.api.client.domain.OrderSide; -import com.binance.api.client.domain.TimeInForce; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class NewOCO { - - /** - * Symbol to place the order on. - */ - private String symbol; - - /** - * A unique Id for the entire orderList - */ - private String listClientOrderId; - - /** - * Buy/Sell order side. - */ - private OrderSide side; - - /** - * Quantity. - */ - private String quantity; - - /** - * A unique Id for the limit order - */ - private String limitClientOrderId; - - /** - * Price. - */ - private String price; - - /** - * Used to make the LIMIT_MAKER leg an iceberg order. - */ - private String limitIcebergQty; - - /** - * A unique Id for the stop loss/stop loss limit leg - */ - private String stopClientOrderId; - - /** - * Stop Price. - */ - private String stopPrice; - - /** - * If provided, stopLimitTimeInForce is required. - */ - private String stopLimitPrice; - - /** - * Used with STOP_LOSS_LIMIT leg to make an iceberg order. - */ - private String stopIcebergQty; - - /** - * Valid values are GTC/FOK/IOC - */ - private TimeInForce stopLimitTimeInForce; - - /** - * Set the response JSON. ACK, RESULT, or FULL; default: RESULT. - */ - private NewOrderResponseType newOrderRespType; - - /** - * Receiving window. - */ - private Long recvWindow; - - /** - * Order timestamp. - */ - private long timestamp; - - /** - * Creates a new OCO with all required parameters. - */ - public NewOCO(String symbol, OrderSide side, String quantity, String price, String stopPrice) { - this.symbol = symbol; - this.side = side; - this.quantity = quantity; - this.price = price; - this.stopPrice = stopPrice; - this.timestamp = System.currentTimeMillis(); - this.recvWindow = BinanceApiConstants.DEFAULT_RECEIVING_WINDOW; - } - - public String getSymbol() { - return symbol; - } - - public void setSymbol(String symbol) { - this.symbol = symbol; - } - - public String getListClientOrderId() { - return listClientOrderId; - } - - public void setListClientOrderId(String listClientOrderId) { - this.listClientOrderId = listClientOrderId; - } - - public OrderSide getSide() { - return side; - } - - public void setSide(OrderSide side) { - this.side = side; - } - - public String getQuantity() { - return quantity; - } - - public void setQuantity(String quantity) { - this.quantity = quantity; - } - - public String getLimitClientOrderId() { - return limitClientOrderId; - } - - public void setLimitClientOrderId(String limitClientOrderId) { - this.limitClientOrderId = limitClientOrderId; - } - - public String getPrice() { - return price; - } - - public void setPrice(String price) { - this.price = price; - } - - public String getLimitIcebergQty() { - return limitIcebergQty; - } - - public void setLimitIcebergQty(String limitIcebergQty) { - this.limitIcebergQty = limitIcebergQty; - } - - public String getStopClientOrderId() { - return stopClientOrderId; - } - - public void setStopClientOrderId(String stopClientOrderId) { - this.stopClientOrderId = stopClientOrderId; - } - - public String getStopPrice() { - return stopPrice; - } - - public void setStopPrice(String stopPrice) { - this.stopPrice = stopPrice; - } - - public String getStopLimitPrice() { - return stopLimitPrice; - } - - public void setStopLimitPrice(String stopLimitPrice) { - this.stopLimitPrice = stopLimitPrice; - } - - public String getStopIcebergQty() { - return stopIcebergQty; - } - - public void setStopIcebergQty(String stopIcebergQty) { - this.stopIcebergQty = stopIcebergQty; - } - - public TimeInForce getStopLimitTimeInForce() { - return stopLimitTimeInForce; - } - - public void setStopLimitTimeInForce(TimeInForce stopLimitTimeInForce) { - this.stopLimitTimeInForce = stopLimitTimeInForce; - } - - public NewOrderResponseType getNewOrderRespType() { - return newOrderRespType; - } - - public void setNewOrderRespType(NewOrderResponseType newOrderRespType) { - this.newOrderRespType = newOrderRespType; - } - - public Long getRecvWindow() { - return recvWindow; - } - - public void setRecvWindow(Long recvWindow) { - this.recvWindow = recvWindow; - } - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE).append("symbol", symbol) - .append("listClientOrderId", listClientOrderId) - .append("side", side) - .append("quantity", quantity) - .append("limitClientOrderId", limitClientOrderId) - .append("price", price) - .append("limitIcebergQty", limitIcebergQty) - .append("stopClientOrderId", stopClientOrderId) - .append("stopPrice", stopPrice) - .append("stopLimitPrice", stopLimitPrice) - .append("stopIcebergQty", stopIcebergQty) - .append("stopLimitTimeInForce", stopLimitTimeInForce) - .append("newOrderRespType", newOrderRespType) - .append("recvWindow", recvWindow) - .append("timestamp", timestamp) - .toString(); - } - -} \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/domain/account/Repay.java b/src/main/java/com/binance/api/client/domain/account/Repay.java deleted file mode 100755 index cb2e414de..000000000 --- a/src/main/java/com/binance/api/client/domain/account/Repay.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.binance.api.client.domain.account; - -import com.binance.api.client.domain.LoanStatus; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class Repay { - - private String amount; - private String asset; - private String interest; - private String principal; - LoanStatus status; - private long timestamp; - private String txId; - - public String getAmount() { - return amount; - } - - public void setAmount(String amount) { - this.amount = amount; - } - - public String getAsset() { - return asset; - } - - public void setAsset(String asset) { - this.asset = asset; - } - - public String getInterest() { - return interest; - } - - public void setInterest(String interest) { - this.interest = interest; - } - - public String getPrincipal() { - return principal; - } - - public void setPrincipal(String principal) { - this.principal = principal; - } - - public LoanStatus getStatus() { - return status; - } - - public void setStatus(LoanStatus status) { - this.status = status; - } - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public String getTxId() { - return txId; - } - - public void setTxId(String txId) { - this.txId = txId; - } - - @Override - public String toString() { - return "Repay{" + - "amount='" + amount + '\'' + - ", asset='" + asset + '\'' + - ", interest='" + interest + '\'' + - ", principal='" + principal + '\'' + - ", status=" + status + - ", timestamp=" + timestamp + - ", txId='" + txId + '\'' + - '}'; - } -} diff --git a/src/main/java/com/binance/api/client/domain/account/RepayQueryResult.java b/src/main/java/com/binance/api/client/domain/account/RepayQueryResult.java deleted file mode 100755 index 2f0d2514c..000000000 --- a/src/main/java/com/binance/api/client/domain/account/RepayQueryResult.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.binance.api.client.domain.account; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -import java.util.List; - -/** - * History of account withdrawals. - * - * @see Withdraw - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class RepayQueryResult { - - private int total; - private List rows; - - public int getTotal() { - return total; - } - - public void setTotal(int total) { - this.total = total; - } - - public List getRows() { - return rows; - } - - public void setRows(List rows) { - this.rows = rows; - } - - @Override - public String toString() { - return "RepayQueryResult{" + - "total=" + total + - ", rows=" + rows + - '}'; - } -} diff --git a/src/main/java/com/binance/api/client/domain/account/SideEffectType.java b/src/main/java/com/binance/api/client/domain/account/SideEffectType.java deleted file mode 100755 index 36d92da7d..000000000 --- a/src/main/java/com/binance/api/client/domain/account/SideEffectType.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.binance.api.client.domain.account; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -/** - * Desired side-effect for margin orders: - * NO_SIDE_EFFECT for normal trade order; - * MARGIN_BUY for margin trade order; - * AUTO_REPAY for making auto repayment after order filled - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public enum SideEffectType { - NO_SIDE_EFFECT, - MARGIN_BUY, - AUTO_REPAY -} - diff --git a/src/main/java/com/binance/api/client/domain/account/SubAccountTransfer.java b/src/main/java/com/binance/api/client/domain/account/SubAccountTransfer.java deleted file mode 100755 index fd76dc286..000000000 --- a/src/main/java/com/binance/api/client/domain/account/SubAccountTransfer.java +++ /dev/null @@ -1,159 +0,0 @@ -package com.binance.api.client.domain.account; - -import org.apache.commons.lang3.builder.ToStringBuilder; - -import com.binance.api.client.constant.BinanceApiConstants; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class SubAccountTransfer { - - /** - * Counter party name - */ - private String counterParty; - - /** - * Counter party email - */ - private String email; - - /** - * Transfer in or transfer out - */ - private Integer type; // 1 for transfer in, 2 for transfer out - - /** - * Transfer asset - */ - private String asset; - - /** - * Quantity of transfer asset - */ - private String qty; - - /** - * Type of from account - */ - private String fromAccountType; - - /** - * Type of to account - */ - private String toAccountType; - - /** - * Transfer status - */ - private String status; - - /** - * Transfer ID - */ - private Long tranId; - - /** - * Transfer time - */ - private Long time; - - // Setter - public void setCounterParty(String counterParty) { - this.counterParty = counterParty; - } - - public void setEmail(String email) { - this.email = email; - } - - public void setType(Integer type) { - this.type = type; - } - - public void setAsset(String asset) { - this.asset = asset; - } - - public void setQty(String qty) { - this.qty = qty; - } - - public void setFromAccountType(String fromAccountType) { - this.fromAccountType = fromAccountType; - } - - public void setToAccountType(String toAccountType) { - this.toAccountType = toAccountType; - } - - public void setStatus(String status) { - this.status = status; - } - - public void setTranId(Long tranId) { - this.tranId = tranId; - } - - public void setTime(Long time) { - this.time = time; - } - - // Getter - public String getCounterParty() { - return this.counterParty; - } - - public String getEmail() { - return this.email; - } - - public Integer getType() { - return this.type; - } - - public String getAsset() { - return this.asset; - } - - public String getQty() { - return this.qty; - } - - public String getFromAccountType() { - return this.fromAccountType; - } - - public String getToAccountType() { - return this.toAccountType; - } - - public String getStatus() { - return this.status; - } - - public Long getTranId() { - return this.tranId; - } - - public Long getTime() { - return this.time; - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("counterParty", this.counterParty) - .append("email", this.email) - .append("type", this.type) - .append("asset", this.asset) - .append("qty", this.qty) - .append("fromAccountType", this.fromAccountType) - .append("toAccountType", this.toAccountType) - .append("status", this.status) - .append("tranId", this.tranId) - .append("time", this.time) - .toString(); - } - -} \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/domain/account/SwapHistory.java b/src/main/java/com/binance/api/client/domain/account/SwapHistory.java deleted file mode 100755 index 4854fc8c4..000000000 --- a/src/main/java/com/binance/api/client/domain/account/SwapHistory.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.binance.api.client.domain.account; - -public class SwapHistory { - - private String quoteQty; - private Long swapTime; - private String swapId; - private String price; - private String fee; - private String baseQty; - private String baseAsset; - private String quoteAsset; - private SwapStatus status; - - public String getQuoteQty() { - return quoteQty; - } - - public void setQuoteQty(String quoteQty) { - this.quoteQty = quoteQty; - } - - public Long getSwapTime() { - return swapTime; - } - - public void setSwapTime(Long swapTime) { - this.swapTime = swapTime; - } - - public String getSwapId() { - return swapId; - } - - public void setSwapId(String swapId) { - this.swapId = swapId; - } - - public String getPrice() { - return price; - } - - public void setPrice(String price) { - this.price = price; - } - - public String getFee() { - return fee; - } - - public void setFee(String fee) { - this.fee = fee; - } - - public String getBaseQty() { - return baseQty; - } - - public void setBaseQty(String baseQty) { - this.baseQty = baseQty; - } - - public String getBaseAsset() { - return baseAsset; - } - - public void setBaseAsset(String baseAsset) { - this.baseAsset = baseAsset; - } - - public String getQuoteAsset() { - return quoteAsset; - } - - public void setQuoteAsset(String quoteAsset) { - this.quoteAsset = quoteAsset; - } - - public SwapStatus getStatus() { - return status; - } - - public void setStatus(SwapStatus status) { - this.status = status; - } - - @Override - public String toString() { - return "SwapHistory{" + - "quoteQty='" + quoteQty + '\'' + - ", swapTime=" + swapTime + - ", swapId='" + swapId + '\'' + - ", price='" + price + '\'' + - ", fee='" + fee + '\'' + - ", baseQty='" + baseQty + '\'' + - ", baseAsset='" + baseAsset + '\'' + - ", quoteAsset='" + quoteAsset + '\'' + - ", status='" + status + '\'' + - '}'; - } -} diff --git a/src/main/java/com/binance/api/client/domain/account/SwapQuote.java b/src/main/java/com/binance/api/client/domain/account/SwapQuote.java deleted file mode 100755 index fdce77258..000000000 --- a/src/main/java/com/binance/api/client/domain/account/SwapQuote.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.binance.api.client.domain.account; - -public class SwapQuote { - private String quoteQty; - private String price; - private String fee; - private String baseQty; - private String baseAsset; - private String slippage; - private String quoteAsset; - - public String getQuoteQty() { - return quoteQty; - } - - public void setQuoteQty(String quoteQty) { - this.quoteQty = quoteQty; - } - - public String getPrice() { - return price; - } - - public void setPrice(String price) { - this.price = price; - } - - public String getFee() { - return fee; - } - - public void setFee(String fee) { - this.fee = fee; - } - - public String getBaseQty() { - return baseQty; - } - - public void setBaseQty(String baseQty) { - this.baseQty = baseQty; - } - - public String getBaseAsset() { - return baseAsset; - } - - public void setBaseAsset(String baseAsset) { - this.baseAsset = baseAsset; - } - - public String getSlippage() { - return slippage; - } - - public void setSlippage(String slippage) { - this.slippage = slippage; - } - - public String getQuoteAsset() { - return quoteAsset; - } - - public void setQuoteAsset(String quoteAsset) { - this.quoteAsset = quoteAsset; - } - - @Override - public String toString() { - return "SwapQuote{" + - "quoteQty='" + quoteQty + '\'' + - ", price='" + price + '\'' + - ", fee='" + fee + '\'' + - ", baseQty='" + baseQty + '\'' + - ", baseAsset='" + baseAsset + '\'' + - ", slippage='" + slippage + '\'' + - ", quoteAsset='" + quoteAsset + '\'' + - '}'; - } -} - diff --git a/src/main/java/com/binance/api/client/domain/account/SwapRecord.java b/src/main/java/com/binance/api/client/domain/account/SwapRecord.java deleted file mode 100755 index d4d9198aa..000000000 --- a/src/main/java/com/binance/api/client/domain/account/SwapRecord.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.binance.api.client.domain.account; - -public class SwapRecord { - - private String swapId; - - public String getSwapId() { - return swapId; - } - - public void setSwapId(String swapId) { - this.swapId = swapId; - } - - @Override - public String toString() { - return "SwapRecord{" + - "swapId='" + swapId + '\'' + - '}'; - } -} diff --git a/src/main/java/com/binance/api/client/domain/account/SwapStatus.java b/src/main/java/com/binance/api/client/domain/account/SwapStatus.java deleted file mode 100755 index 82ab74007..000000000 --- a/src/main/java/com/binance/api/client/domain/account/SwapStatus.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.binance.api.client.domain.account; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonValue; - -@JsonIgnoreProperties(ignoreUnknown = true) -public enum SwapStatus { - PENDING, - SUCCESS, - FAILED; - - @JsonValue - public int toValue() { - return ordinal(); - } -} - - diff --git a/src/main/java/com/binance/api/client/domain/event/AssetBalanceDeserializer.java b/src/main/java/com/binance/api/client/domain/event/AssetBalanceDeserializer.java index f8953a4c6..83a95740b 100755 --- a/src/main/java/com/binance/api/client/domain/event/AssetBalanceDeserializer.java +++ b/src/main/java/com/binance/api/client/domain/event/AssetBalanceDeserializer.java @@ -10,8 +10,9 @@ import java.io.IOException; /** - * Custom deserializer for an AssetBalance, since the streaming API returns an object in the format {"a":"symbol","f":"free","l":"locked"}, - * which is different than the format used in the REST API. + * Custom deserializer for an AssetBalance, since the streaming API returns an object in + * the format {"a":"symbol","f":"free","l":"locked"}, + * which is different from the format used in the REST API. */ public class AssetBalanceDeserializer extends JsonDeserializer { diff --git a/src/main/java/com/binance/api/client/domain/general/ExchangeInfo.java b/src/main/java/com/binance/api/client/domain/general/ExchangeInfo.java index b12c1d20c..b2047032c 100755 --- a/src/main/java/com/binance/api/client/domain/general/ExchangeInfo.java +++ b/src/main/java/com/binance/api/client/domain/general/ExchangeInfo.java @@ -9,7 +9,7 @@ /** * Current exchange trading rules and symbol information. - * https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md + * https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md */ @JsonIgnoreProperties(ignoreUnknown = true) public class ExchangeInfo { diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncMarginRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncMarginRestClientImpl.java deleted file mode 100755 index a0821df80..000000000 --- a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncMarginRestClientImpl.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.binance.api.client.impl; - -import com.binance.api.client.BinanceApiAsyncMarginRestClient; -import com.binance.api.client.BinanceApiCallback; -import com.binance.api.client.constant.BinanceApiConstants; -import com.binance.api.client.domain.TransferType; -import com.binance.api.client.domain.account.*; -import com.binance.api.client.domain.account.request.CancelOrderRequest; -import com.binance.api.client.domain.account.request.CancelOrderResponse; -import com.binance.api.client.domain.account.request.OrderRequest; -import com.binance.api.client.domain.account.request.OrderStatusRequest; -import com.binance.api.client.domain.event.ListenKey; - -import java.util.List; - -import static com.binance.api.client.impl.BinanceApiServiceGenerator.createService; - -/** - * Implementation of Binance's Margin REST API using Retrofit with asynchronous/non-blocking method calls. - */ -public class BinanceApiAsyncMarginRestClientImpl implements BinanceApiAsyncMarginRestClient { - - private final BinanceApiService binanceApiService; - - public BinanceApiAsyncMarginRestClientImpl(String apiKey, String secret) { - binanceApiService = createService(BinanceApiService.class, apiKey, secret); - } - - // Margin Account endpoints - - @Override - public void getAccount(Long recvWindow, Long timestamp, BinanceApiCallback callback) { - binanceApiService.getMarginAccount(recvWindow, timestamp).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void getAccount(BinanceApiCallback callback) { - long timestamp = System.currentTimeMillis(); - binanceApiService.getMarginAccount(BinanceApiConstants.DEFAULT_MARGIN_RECEIVING_WINDOW, timestamp).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void getOpenOrders(OrderRequest orderRequest, BinanceApiCallback> callback) { - binanceApiService.getOpenMarginOrders(orderRequest.getSymbol(), orderRequest.getRecvWindow(), - orderRequest.getTimestamp()).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void newOrder(MarginNewOrder order, BinanceApiCallback callback) { - binanceApiService.newMarginOrder(order.getSymbol(), order.getSide(), order.getType(), order.getTimeInForce(), - order.getQuantity(), order.getPrice(), order.getNewClientOrderId(), order.getStopPrice(), order.getIcebergQty(), - order.getNewOrderRespType(), order.getSideEffectType(), order.getRecvWindow(), order.getTimestamp()).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void cancelOrder(CancelOrderRequest cancelOrderRequest, BinanceApiCallback callback) { - binanceApiService.cancelMarginOrder(cancelOrderRequest.getSymbol(), - cancelOrderRequest.getOrderId(), cancelOrderRequest.getOrigClientOrderId(), cancelOrderRequest.getNewClientOrderId(), - cancelOrderRequest.getRecvWindow(), cancelOrderRequest.getTimestamp()).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void getOrderStatus(OrderStatusRequest orderStatusRequest, BinanceApiCallback callback) { - binanceApiService.getMarginOrderStatus(orderStatusRequest.getSymbol(), - orderStatusRequest.getOrderId(), orderStatusRequest.getOrigClientOrderId(), - orderStatusRequest.getRecvWindow(), orderStatusRequest.getTimestamp()).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void getMyTrades(String symbol, BinanceApiCallback> callback) { - binanceApiService.getMyTrades(symbol, null, null, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - // user stream endpoints - - @Override - public void startUserDataStream(BinanceApiCallback callback) { - binanceApiService.startMarginUserDataStream().enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void keepAliveUserDataStream(String listenKey, BinanceApiCallback callback) { - binanceApiService.keepAliveMarginUserDataStream(listenKey).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void transfer(String asset, String amount, TransferType type, BinanceApiCallback callback) { - long timestamp = System.currentTimeMillis(); - binanceApiService.transfer(asset, amount, type.getValue(), BinanceApiConstants.DEFAULT_MARGIN_RECEIVING_WINDOW, timestamp).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void borrow(String asset, String amount, BinanceApiCallback callback) { - long timestamp = System.currentTimeMillis(); - binanceApiService.borrow(asset, amount, BinanceApiConstants.DEFAULT_MARGIN_RECEIVING_WINDOW, timestamp).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } - - @Override - public void repay(String asset, String amount, BinanceApiCallback callback) { - long timestamp = System.currentTimeMillis(); - binanceApiService.repay(asset, amount, BinanceApiConstants.DEFAULT_MARGIN_RECEIVING_WINDOW, timestamp).enqueue(new BinanceApiCallbackAdapter<>(callback)); - } -} diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiMarginRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiMarginRestClientImpl.java deleted file mode 100755 index fe7830559..000000000 --- a/src/main/java/com/binance/api/client/impl/BinanceApiMarginRestClientImpl.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.binance.api.client.impl; - -import com.binance.api.client.BinanceApiMarginRestClient; -import com.binance.api.client.constant.BinanceApiConstants; -import com.binance.api.client.domain.TransferType; -import com.binance.api.client.domain.account.*; -import com.binance.api.client.domain.account.request.CancelOrderRequest; -import com.binance.api.client.domain.account.request.CancelOrderResponse; -import com.binance.api.client.domain.account.request.OrderRequest; -import com.binance.api.client.domain.account.request.OrderStatusRequest; - -import java.util.List; - -import static com.binance.api.client.impl.BinanceApiServiceGenerator.createService; -import static com.binance.api.client.impl.BinanceApiServiceGenerator.executeSync; - -/** - * Implementation of Binance's Margin REST API using Retrofit with asynchronous/non-blocking method calls. - */ -public class BinanceApiMarginRestClientImpl implements BinanceApiMarginRestClient { - - private final BinanceApiService binanceApiService; - - public BinanceApiMarginRestClientImpl(String apiKey, String secret) { - binanceApiService = createService(BinanceApiService.class, apiKey, secret); - } - - @Override - public MarginAccount getAccount() { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.getMarginAccount(BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, timestamp)); - } - - @Override - public List getOpenOrders(OrderRequest orderRequest) { - return executeSync(binanceApiService.getOpenMarginOrders(orderRequest.getSymbol(), orderRequest.getRecvWindow(), - orderRequest.getTimestamp())); - } - - @Override - public MarginNewOrderResponse newOrder(MarginNewOrder order) { - return executeSync(binanceApiService.newMarginOrder(order.getSymbol(), order.getSide(), order.getType(), - order.getTimeInForce(), order.getQuantity(), order.getPrice(), order.getNewClientOrderId(), order.getStopPrice(), - order.getIcebergQty(), order.getNewOrderRespType(), order.getSideEffectType(), order.getRecvWindow(), order.getTimestamp())); - } - - @Override - public CancelOrderResponse cancelOrder(CancelOrderRequest cancelOrderRequest) { - return executeSync(binanceApiService.cancelMarginOrder(cancelOrderRequest.getSymbol(), - cancelOrderRequest.getOrderId(), cancelOrderRequest.getOrigClientOrderId(), cancelOrderRequest.getNewClientOrderId(), - cancelOrderRequest.getRecvWindow(), cancelOrderRequest.getTimestamp())); - } - - @Override - public Order getOrderStatus(OrderStatusRequest orderStatusRequest) { - return executeSync(binanceApiService.getMarginOrderStatus(orderStatusRequest.getSymbol(), - orderStatusRequest.getOrderId(), orderStatusRequest.getOrigClientOrderId(), - orderStatusRequest.getRecvWindow(), orderStatusRequest.getTimestamp())); - } - - @Override - public List getMyTrades(String symbol) { - return executeSync(binanceApiService.getMyTrades(symbol, null, null, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); - } - - // user stream endpoints - - @Override - public String startUserDataStream() { - return executeSync(binanceApiService.startMarginUserDataStream()).toString(); - } - - @Override - public void keepAliveUserDataStream(String listenKey) { - executeSync(binanceApiService.keepAliveMarginUserDataStream(listenKey)); - } - - @Override - public MarginTransaction transfer(String asset, String amount, TransferType type) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.transfer(asset, amount, type.getValue(), BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, timestamp)); - } - - @Override - public MarginTransaction borrow(String asset, String amount) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.borrow(asset, amount, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, timestamp)); - } - - @Override - public LoanQueryResult queryLoan(String asset, String txId) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.queryLoan(asset, txId, timestamp)); - } - - @Override - public RepayQueryResult queryRepay(String asset, String txId) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.queryRepay(asset, txId, timestamp)); - } - - @Override - public RepayQueryResult queryRepay(String asset, long startTime) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.queryRepay(asset, startTime, timestamp)); - } - - @Override - public MaxBorrowableQueryResult queryMaxBorrowable(String asset) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.queryMaxBorrowable(asset, timestamp)); - } - - @Override - public MarginTransaction repay(String asset, String amount) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.repay(asset, amount, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, timestamp)); - } -} \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java index 214f0fb1b..0076ffe06 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java @@ -168,14 +168,6 @@ public List getAllOrders(AllOrdersRequest orderRequest) { orderRequest.getLimit(), orderRequest.getRecvWindow(), orderRequest.getTimestamp())); } - @Override - public NewOCOResponse newOCO(NewOCO oco) { - return executeSync(binanceApiService.newOCO(oco.getSymbol(), oco.getListClientOrderId(), oco.getSide(), - oco.getQuantity(), oco.getLimitClientOrderId(), oco.getPrice(), oco.getLimitIcebergQty(), - oco.getStopClientOrderId(), oco.getStopPrice(), oco.getStopLimitPrice(), oco.getStopIcebergQty(), - oco.getStopLimitTimeInForce(), oco.getNewOrderRespType(), oco.getRecvWindow(), oco.getTimestamp())); - } - @Override public CancelOrderListResponse cancelOrderList(CancelOrderListRequest cancelOrderListRequest) { return executeSync(binanceApiService.cancelOrderList(cancelOrderListRequest.getSymbol(), cancelOrderListRequest.getOrderListId(), @@ -235,7 +227,7 @@ public WithdrawResult withdraw(String asset, String address, String amount, Stri } @Override - public DustTransferResponse dustTranfer(List asset) { + public DustTransferResponse dustTransfer(List asset) { return executeSync(binanceApiService.dustTransfer(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); } @@ -251,11 +243,6 @@ public WithdrawHistory getWithdrawHistory(String asset) { System.currentTimeMillis())); } - @Override - public List getSubAccountTransfers() { - return executeSync(binanceApiService.getSubAccountTransfers(System.currentTimeMillis())); - } - @Override public DepositAddress getDepositAddress(String asset) { return executeSync(binanceApiService.getDepositAddress(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiService.java b/src/main/java/com/binance/api/client/impl/BinanceApiService.java index b64d68bd4..a2a92e069 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiService.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiService.java @@ -3,7 +3,6 @@ import com.binance.api.client.constant.BinanceApiConstants; import com.binance.api.client.domain.OrderSide; import com.binance.api.client.domain.OrderType; -import com.binance.api.client.domain.SwapRemoveType; import com.binance.api.client.domain.TimeInForce; import com.binance.api.client.domain.account.*; import com.binance.api.client.domain.account.request.CancelOrderListResponse; @@ -119,14 +118,6 @@ Call cancelOrder(@Query("symbol") String symbol, @Query("or Call> getAllOrders(@Query("symbol") String symbol, @Query("orderId") Long orderId, @Query("limit") Integer limit, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @POST("/api/v3/order/oco") - Call newOCO(@Query("symbol") String symbol, @Query("listClientOrderId") String listClientOrderId, @Query("side") OrderSide side, - @Query("quantity") String quantity, @Query("limitClientOrderId") String limitClientOrderId, @Query("price") String price, - @Query("limitIcebergQty") String limitIcebergQty, @Query("stopClientOrderId") String stopClientOrderId, @Query("stopPrice") String stopPrice, - @Query("stopLimitPrice") String stopLimitPrice, @Query("stopIcebergQty") String stopIcebergQty, @Query("stopLimitTimeInForce") TimeInForce stopLimitTimeInForce, - @Query("newOrderRespType") NewOrderResponseType newOrderRespType, @Query("recvWindow") Long recvWindow, @Query("timestamp") long timestamp); - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) @DELETE("/api/v3/orderList") Call cancelOrderList(@Query("symbol") String symbol, @Query("orderListId") Long orderListId, @Query("listClientOrderId") String listClientOrderId, @@ -173,10 +164,6 @@ Call withdraw(@Query("asset") String asset, @Query("address") St @POST("/sapi/v1/asset/dust") Call dustTransfer(@Query("asset") List asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/sapi/v1/sub-account/transfer/subUserHistory") - Call> getSubAccountTransfers(@Query("timestamp") Long timestamp); - // User stream endpoints @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) @@ -191,68 +178,6 @@ Call withdraw(@Query("asset") String asset, @Query("address") St @DELETE("/api/v1/userDataStream") Call closeAliveUserDataStream(@Query("listenKey") String listenKey); - // Margin Account endpoints - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @POST("/sapi/v1/margin/transfer") - Call transfer(@Query("asset") String asset, @Query("amount") String amount, @Query("type") String type, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @POST("/sapi/v1/margin/loan") - Call borrow(@Query("asset") String asset, @Query("amount") String amount, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/margin/loan") - Call queryLoan(@Query("asset") String asset, @Query("txId") String txId, @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/margin/repay") - Call queryRepay(@Query("asset") String asset, @Query("txId") String txId, @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/margin/maxBorrowable") - Call queryMaxBorrowable(@Query("asset") String asset, @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/margin/repay") - Call queryRepay(@Query("asset") String asset, @Query("startTime") Long starttime, @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @POST("/sapi/v1/margin/repay") - Call repay(@Query("asset") String asset, @Query("amount") String amount, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/margin/account") - Call getMarginAccount(@Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/margin/openOrders") - Call> getOpenMarginOrders(@Query("symbol") String symbol, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @POST("/sapi/v1/margin/order") - Call newMarginOrder(@Query("symbol") String symbol, @Query("side") OrderSide side, @Query("type") OrderType type, - @Query("timeInForce") TimeInForce timeInForce, @Query("quantity") String quantity, - @Query("price") String price, @Query("newClientOrderId") String newClientOrderId, @Query("stopPrice") String stopPrice, - @Query("icebergQty") String icebergQty, @Query("newOrderRespType") NewOrderResponseType newOrderRespType, - @Query("sideEffectType") SideEffectType sideEffectType, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @DELETE("/sapi/v1/margin/order") - Call cancelMarginOrder(@Query("symbol") String symbol, @Query("orderId") Long orderId, - @Query("origClientOrderId") String origClientOrderId, @Query("newClientOrderId") String newClientOrderId, - @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/sapi/v1/margin/order") - Call getMarginOrderStatus(@Query("symbol") String symbol, @Query("orderId") Long orderId, - @Query("origClientOrderId") String origClientOrderId, @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/sapi/v1/margin/myTrades") - Call> getMyMarginTrades(@Query("symbol") String symbol, @Query("limit") Integer limit, @Query("fromId") Long fromId, - @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) @POST("/sapi/v1/userDataStream") Call startMarginUserDataStream(); @@ -261,74 +186,4 @@ Call> getMyMarginTrades(@Query("symbol") String symbol, @Query("limi @PUT("/sapi/v1/userDataStream") Call keepAliveMarginUserDataStream(@Query("listenKey") String listenKey); - // Binance Liquidity Swap Pool endpoints - - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) - @GET("/sapi/v1/bswap/pools") - Call> listAllSwapPools(); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/bswap/liquidity") - Call> getPoolLiquidityInfo(@Query("poolId") String poolId, - @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @POST("/sapi/v1/bswap/liquidityAdd") - Call addLiquidity(@Query("poolId") String poolId, - @Query("asset") String asset, - @Query("quantity") String quantity, - @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @POST("/sapi/v1/bswap/liquidityRemove") - Call removeLiquidity(@Query("poolId") String poolId, - @Query("type") SwapRemoveType type, - @Query("asset") List asset, - @Query("shareAmount") String shareAmount, - @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/bswap/liquidityOps") - Call> getPoolLiquidityOperationRecords( - @Query("poolId") String poolId, - @Query("limit") Integer limit, - @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/bswap/liquidityOps") - Call> getLiquidityOperationRecord( - @Query("operationId") String operationId, - @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/bswap/quote") - Call requestQuote( - @Query("quoteAsset") String quoteAsset, - @Query("baseAsset") String baseAsset, - @Query("quoteQty") String quoteQty, - @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @POST("/sapi/v1/bswap/swap") - Call swap( - @Query("quoteAsset") String quoteAsset, - @Query("baseAsset") String baseAsset, - @Query("quoteQty") String quoteQty, - @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - @Headers({BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER, BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER}) - @GET("/sapi/v1/bswap/swap") - Call> getSwapHistory( - @Query("swapId") String swapId, - @Query("recvWindow") Long recvWindow, - @Query("timestamp") Long timestamp); - - } diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiSwapRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiSwapRestClientImpl.java deleted file mode 100755 index 2ffdbf9c1..000000000 --- a/src/main/java/com/binance/api/client/impl/BinanceApiSwapRestClientImpl.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.binance.api.client.impl; - -import com.binance.api.client.BinanceApiSwapRestClient; -import com.binance.api.client.constant.BinanceApiConstants; -import com.binance.api.client.domain.SwapRemoveType; -import com.binance.api.client.domain.account.*; - -import java.util.List; - -import static com.binance.api.client.impl.BinanceApiServiceGenerator.createService; -import static com.binance.api.client.impl.BinanceApiServiceGenerator.executeSync; - -/** - * Implementation of Binance's SWAP REST API using Retrofit method calls. - */ -public class BinanceApiSwapRestClientImpl implements BinanceApiSwapRestClient { - - private final BinanceApiService binanceApiService; - - public BinanceApiSwapRestClientImpl(String apiKey, String secret) { - binanceApiService = createService(BinanceApiService.class, apiKey, secret); - } - - @Override - public List listAllSwapPools() { - return executeSync(binanceApiService.listAllSwapPools()); - } - - @Override - public Liquidity getPoolLiquidityInfo(String poolId) { - long timestamp = System.currentTimeMillis(); - List liquidities = executeSync(binanceApiService.getPoolLiquidityInfo(poolId, - BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - timestamp)); - if (liquidities != null && !liquidities.isEmpty()) { - return liquidities.get(0); - } - return null; - } - - @Override - public LiquidityOperationRecord addLiquidity(String poolId, String asset, String quantity) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.addLiquidity(poolId, - asset, - quantity, - BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - timestamp)); - } - - @Override - public LiquidityOperationRecord removeLiquidity(String poolId, SwapRemoveType type, List asset, String shareAmount) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.removeLiquidity(poolId, - type, - asset, - shareAmount, - BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - timestamp)); - } - - @Override - public List getPoolLiquidityOperationRecords(String poolId, Integer limit) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.getPoolLiquidityOperationRecords( - poolId, - limit, - BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - timestamp)); - - } - - @Override - public LiquidityOperationRecord getLiquidityOperationRecord(String operationId) { - long timestamp = System.currentTimeMillis(); - List records = executeSync(binanceApiService.getLiquidityOperationRecord( - operationId, - BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - timestamp)); - if (records != null && !records.isEmpty()) { - return records.get(0); - } - return null; - } - - @Override - public SwapQuote requestQuote(String quoteAsset, - String baseAsset, - String quoteQty) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.requestQuote(quoteAsset, baseAsset, quoteQty, - BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - timestamp)); - } - - @Override - public SwapRecord swap(String quoteAsset, String baseAsset, String quoteQty) { - long timestamp = System.currentTimeMillis(); - return executeSync(binanceApiService.swap(quoteAsset, baseAsset, quoteQty, - BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - timestamp)); - } - - @Override - public SwapHistory getSwapHistory(String swapId) { - long timestamp = System.currentTimeMillis(); - List history = executeSync(binanceApiService.getSwapHistory(swapId, - BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - timestamp)); - if (history != null && !history.isEmpty()) { - return history.get(0); - } - return null; - } -} \ No newline at end of file diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiWebSocketClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiWebSocketClientImpl.java index cb95bdb5a..0618820cc 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiWebSocketClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiWebSocketClientImpl.java @@ -18,7 +18,7 @@ /** * Binance API WebSocket client implementation using OkHttp. */ -public class BinanceApiWebSocketClientImpl implements BinanceApiWebSocketClient, Closeable { +public class BinanceApiWebSocketClientImpl implements BinanceApiWebSocketClient { private final OkHttpClient client; @@ -85,13 +85,6 @@ public Closeable onAllBookTickersEvent(BinanceApiCallback callb return createNewWebSocket(channel, new BinanceApiWebSocketListener<>(callback, BookTickerEvent.class)); } - /** - * @deprecated This method is no longer functional. Please use the returned {@link Closeable} from any of the other methods to close the web socket. - */ - @Override - public void close() { - } - private Closeable createNewWebSocket(String channel, BinanceApiWebSocketListener listener) { String streamingUrl = String.format("%s/%s", BinanceApiConfig.useTestnetStreaming ? BinanceApiConfig.getStreamTestNetBaseUrl() : BinanceApiConfig.getStreamApiBaseUrl(), channel); Request request = new Request.Builder().url(streamingUrl).build(); diff --git a/src/test/java/com/binance/api/examples/MarginAccountEndpointsExample.java b/src/test/java/com/binance/api/examples/MarginAccountEndpointsExample.java deleted file mode 100755 index 0d204fac1..000000000 --- a/src/test/java/com/binance/api/examples/MarginAccountEndpointsExample.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.binance.api.examples; - -import com.binance.api.client.BinanceApiClientFactory; -import com.binance.api.client.BinanceApiMarginRestClient; -import com.binance.api.client.domain.TransferType; -import com.binance.api.client.domain.account.MarginAccount; -import com.binance.api.client.domain.account.MarginTransaction; -import com.binance.api.client.domain.account.Trade; - -import java.util.List; - -/** - * Examples on how to get margin account information. - */ -public class MarginAccountEndpointsExample { - - public static void main(String[] args) { - BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_SECRET"); - BinanceApiMarginRestClient client = factory.newMarginRestClient(); - - // Get account balances - MarginAccount marginAccount = client.getAccount(); - System.out.println(marginAccount.getUserAssets()); - System.out.println(marginAccount.getAssetBalance("ETH")); - System.out.println(marginAccount.getMarginLevel()); - - // Get list of trades - List myTrades = client.getMyTrades("NEOETH"); - System.out.println(myTrades); - - // Transfer, borrow, repay - MarginTransaction spotToMargin = client.transfer("USDT", "1", TransferType.SPOT_TO_MARGIN); - System.out.println(spotToMargin.getTranId()); - MarginTransaction borrowed = client.borrow("USDT", "1"); - System.out.println(borrowed.getTranId()); - MarginTransaction repayed = client.repay("USDT", "1"); - System.out.println(repayed.getTranId()); - MarginTransaction marginToSpot = client.transfer("USDT", "1", TransferType.MARGIN_TO_SPOT); - System.out.println(marginToSpot.getTranId()); - } -} diff --git a/src/test/java/com/binance/api/examples/MarginAccountEndpointsExampleAsync.java b/src/test/java/com/binance/api/examples/MarginAccountEndpointsExampleAsync.java deleted file mode 100755 index 07c3507be..000000000 --- a/src/test/java/com/binance/api/examples/MarginAccountEndpointsExampleAsync.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.binance.api.examples; - -import com.binance.api.client.BinanceApiAsyncMarginRestClient; -import com.binance.api.client.BinanceApiCallback; -import com.binance.api.client.BinanceApiClientFactory; -import com.binance.api.client.domain.TransferType; -import com.binance.api.client.domain.account.MarginTransaction; - -/** - * Examples on how to get margin account information asynchronously. - */ -public class MarginAccountEndpointsExampleAsync { - - public static void main(String[] args) { - BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_SECRET"); - BinanceApiAsyncMarginRestClient client = factory.newAsyncMarginRestClient(); - - // Get account balances - client.getAccount(marginAccount -> { - System.out.println(marginAccount.getUserAssets()); - System.out.println(marginAccount.getAssetBalance("ETH")); - System.out.println(marginAccount.getMarginLevel()); - }); - - // Get list of trades - client.getMyTrades("NEOETH", myTrades -> { - System.out.println(myTrades); - }); - - // Transfer, borrow, repay - client.transfer("USDT", "1", TransferType.SPOT_TO_MARGIN, transaction -> System.out.println(transaction.getTranId())); - client.borrow("USDT", "1", transaction -> System.out.println(transaction.getTranId())); - client.repay("USDT", "1", transaction -> System.out.println(transaction.getTranId())); - client.transfer("USDT", "1", TransferType.MARGIN_TO_SPOT, transaction -> System.out.println(transaction.getTranId())); - } -} diff --git a/src/test/java/com/binance/api/examples/MarginAccountEndpointsLoanQueryExample.java b/src/test/java/com/binance/api/examples/MarginAccountEndpointsLoanQueryExample.java deleted file mode 100755 index 4cc4bf01f..000000000 --- a/src/test/java/com/binance/api/examples/MarginAccountEndpointsLoanQueryExample.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.binance.api.examples; - -import com.binance.api.client.BinanceApiClientFactory; -import com.binance.api.client.BinanceApiMarginRestClient; -import com.binance.api.client.domain.account.MarginTransaction; -import com.binance.api.client.domain.account.MaxBorrowableQueryResult; -import com.binance.api.client.domain.account.RepayQueryResult; - -/** - * Examples on how to get margin account information. - */ -public class MarginAccountEndpointsLoanQueryExample { - - public static void main(String[] args) { - BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_SECRET"); - BinanceApiMarginRestClient client = factory.newMarginRestClient(); - MaxBorrowableQueryResult usdt = client.queryMaxBorrowable("USDT"); - System.out.println(usdt.getAmount()); - MaxBorrowableQueryResult bnb = client.queryMaxBorrowable("BNB"); - System.out.println(bnb.getAmount()); - MarginTransaction borrowed = client.borrow("USDT", "310"); - System.out.println(borrowed.getTranId()); - MarginTransaction repaid = client.repay("USDT", "310"); - System.out.println(repaid); - RepayQueryResult repayQueryResult = client.queryRepay("BNB", System.currentTimeMillis() - 1000); - System.out.println(repayQueryResult); - } -} diff --git a/src/test/java/com/binance/api/examples/MarginOrdersExample.java b/src/test/java/com/binance/api/examples/MarginOrdersExample.java deleted file mode 100755 index 969ca784f..000000000 --- a/src/test/java/com/binance/api/examples/MarginOrdersExample.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.binance.api.examples; - -import com.binance.api.client.BinanceApiClientFactory; -import com.binance.api.client.BinanceApiMarginRestClient; -import com.binance.api.client.domain.TimeInForce; -import com.binance.api.client.domain.account.MarginNewOrderResponse; -import com.binance.api.client.domain.account.NewOrderResponseType; -import com.binance.api.client.domain.account.Order; -import com.binance.api.client.domain.account.request.CancelOrderRequest; -import com.binance.api.client.domain.account.request.CancelOrderResponse; -import com.binance.api.client.domain.account.request.OrderRequest; -import com.binance.api.client.domain.account.request.OrderStatusRequest; -import com.binance.api.client.exception.BinanceApiException; - -import java.util.List; - -import static com.binance.api.client.domain.account.MarginNewOrder.limitBuy; - -/** - * Examples on how to place orders, cancel them, and query account information. - */ -public class MarginOrdersExample { - - public static void main(String[] args) { - BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_SECRET"); - BinanceApiMarginRestClient client = factory.newMarginRestClient(); - - // Getting list of open orders - List openOrders = client.getOpenOrders(new OrderRequest("LINKETH")); - System.out.println(openOrders); - - // Get status of a particular order - Order order = client.getOrderStatus(new OrderStatusRequest("LINKETH", 751698L)); - System.out.println(order); - - // Canceling an order - try { - CancelOrderResponse cancelOrderResponse = client.cancelOrder(new CancelOrderRequest("LINKETH", 756762l)); - System.out.println(cancelOrderResponse); - } catch (BinanceApiException e) { - System.out.println(e.getError().getMsg()); - } - - // Placing a real LIMIT order - MarginNewOrderResponse newOrderResponse = client.newOrder(limitBuy("LINKETH", TimeInForce.GTC, "1000", "0.0001").newOrderRespType(NewOrderResponseType.FULL)); - System.out.println(newOrderResponse); - } - -} diff --git a/src/test/java/com/binance/api/examples/MarginOrdersExampleAsync.java b/src/test/java/com/binance/api/examples/MarginOrdersExampleAsync.java deleted file mode 100755 index b07a01792..000000000 --- a/src/test/java/com/binance/api/examples/MarginOrdersExampleAsync.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.binance.api.examples; - -import com.binance.api.client.BinanceApiAsyncMarginRestClient; -import com.binance.api.client.BinanceApiClientFactory; -import com.binance.api.client.domain.TimeInForce; -import com.binance.api.client.domain.account.request.CancelOrderRequest; -import com.binance.api.client.domain.account.request.OrderRequest; -import com.binance.api.client.domain.account.request.OrderStatusRequest; - -import static com.binance.api.client.domain.account.MarginNewOrder.limitBuy; - -/** - * Examples on how to place orders, cancel them, and query account information. - */ -public class MarginOrdersExampleAsync { - - public static void main(String[] args) { - BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_SECRET"); - BinanceApiAsyncMarginRestClient client = factory.newAsyncMarginRestClient(); - - // Getting list of open orders - client.getOpenOrders(new OrderRequest("LINKETH"), response -> System.out.println(response)); - - // Get status of a particular order - client.getOrderStatus(new OrderStatusRequest("LINKETH", 745262L), - response -> System.out.println(response)); - - // Canceling an order - client.cancelOrder(new CancelOrderRequest("LINKETH", 756703L), - response -> System.out.println(response)); - - // Placing a real LIMIT order - client.newOrder(limitBuy("LINKETH", TimeInForce.GTC, "1000", "0.0001"), - response -> System.out.println(response)); - } -} diff --git a/src/test/java/com/binance/api/examples/MarginUserDataStreamExample.java b/src/test/java/com/binance/api/examples/MarginUserDataStreamExample.java deleted file mode 100755 index 6a27a5fa4..000000000 --- a/src/test/java/com/binance/api/examples/MarginUserDataStreamExample.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.binance.api.examples; - -import com.binance.api.client.BinanceApiClientFactory; -import com.binance.api.client.BinanceApiMarginRestClient; -import com.binance.api.client.BinanceApiRestClient; -import com.binance.api.client.BinanceApiWebSocketClient; -import com.binance.api.client.domain.event.AccountUpdateEvent; -import com.binance.api.client.domain.event.OrderTradeUpdateEvent; -import com.binance.api.client.domain.event.UserDataUpdateEvent.UserDataUpdateEventType; - -/** - * User data stream endpoints examples. - * - * It illustrates how to create a stream to obtain updates on a user account, - * as well as update on trades/orders on a user account. - */ -public class MarginUserDataStreamExample { - - public static void main(String[] args) { - BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_SECRET"); - BinanceApiMarginRestClient client = factory.newMarginRestClient(); - - // First, we obtain a listenKey which is required to interact with the user data stream - String listenKey = client.startUserDataStream(); - - // Then, we open a new web socket client, and provide a callback that is called on every update - BinanceApiWebSocketClient webSocketClient = factory.newWebSocketClient(); - - // Listen for changes in the account - webSocketClient.onUserDataUpdateEvent(listenKey, response -> { - if (response.getEventType() == UserDataUpdateEventType.ACCOUNT_POSITION_UPDATE) { - AccountUpdateEvent accountUpdateEvent = response.getOutboundAccountPositionUpdateEvent(); - // Print new balances of every available asset - System.out.println(accountUpdateEvent.getBalances()); - } else { - OrderTradeUpdateEvent orderTradeUpdateEvent = response.getOrderTradeUpdateEvent(); - // Print details about an order/trade - System.out.println(orderTradeUpdateEvent); - - // Print original quantity - System.out.println(orderTradeUpdateEvent.getOriginalQuantity()); - - // Or price - System.out.println(orderTradeUpdateEvent.getPrice()); - } - }); - System.out.println("Waiting for events..."); - - // We can keep alive the user data stream - // client.keepAliveUserDataStream(listenKey); - - // Or we can invalidate it, whenever it is no longer needed - // client.closeUserDataStream(listenKey); - } -} diff --git a/src/test/java/com/binance/api/examples/SwapEndpointExample.java b/src/test/java/com/binance/api/examples/SwapEndpointExample.java deleted file mode 100755 index c4c32d98d..000000000 --- a/src/test/java/com/binance/api/examples/SwapEndpointExample.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.binance.api.examples; - -import com.binance.api.client.BinanceApiClientFactory; -import com.binance.api.client.BinanceApiSwapRestClient; -import com.binance.api.client.domain.account.*; - -import java.util.List; - -public class SwapEndpointExample { - - public static String API_KEY = "api-key"; - public static String SECRET_KEY = "secret-key"; - - public static void main(String[] args) { - - BinanceApiClientFactory binanceApiClientFactory = BinanceApiClientFactory.newInstance(API_KEY, SECRET_KEY); - BinanceApiSwapRestClient swapClient = binanceApiClientFactory.newSwapRestClient(); - List pools = swapClient.listAllSwapPools(); - for(Pool pool:pools) { - System.out.println(pool); - Liquidity poolLiquidityInfo = swapClient.getPoolLiquidityInfo(pool.getPoolId()); - System.out.println(poolLiquidityInfo); - } - SwapQuote swapQuote = swapClient.requestQuote("USDT", "USDC", "10"); - System.out.println(swapQuote); - SwapRecord swapRecord = swapClient.swap("USDT", "USDC", "10"); - SwapHistory swapHistory = swapClient.getSwapHistory(swapRecord.getSwapId()); - System.out.println(swapHistory); - } - - -} From 5fc429348cab55eefcf6f87a96bfb153cc9b65e1 Mon Sep 17 00:00:00 2001 From: Girts Strazdins Date: Thu, 29 Dec 2022 09:47:14 +0100 Subject: [PATCH 05/14] Refactor fiat checking to set (faster lookup) --- .../com/binance/api/client/constant/Util.java | 18 +++++++++--------- .../binance/api/client/constant/UtilTest.java | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 src/test/java/com/binance/api/client/constant/UtilTest.java diff --git a/src/main/java/com/binance/api/client/constant/Util.java b/src/main/java/com/binance/api/client/constant/Util.java index 0e6e786a2..7ca1330b2 100755 --- a/src/main/java/com/binance/api/client/constant/Util.java +++ b/src/main/java/com/binance/api/client/constant/Util.java @@ -2,32 +2,32 @@ import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import java.util.HashSet; +import java.util.Set; /** - * Utility class + * Utility class. */ public final class Util { /** * List of fiat currencies. */ - public static final List FIAT_CURRENCY = Collections.unmodifiableList(Arrays.asList("USDT", "BUSD", "PAX", "TUSD", "USDC", "NGN", "RUB", "USDS", "TRY")); + private static final Set FIAT_CURRENCIES = new HashSet<>( + Arrays.asList("EUR", "USDT", "BUSD", "PAX", "TUSD", "USDC", "NGN", "RUB", "USDS", "TRY") + ); public static final String BTC_TICKER = "BTC"; private Util() { - } /** * Check if the ticker is fiat currency. + * + * @return True if it is a fiat currency (USD, EUR, etc), false when it isn't */ public static boolean isFiatCurrency(String symbol) { - for (String fiat : FIAT_CURRENCY) { - if (symbol.equals(fiat)) return true; - } - return false; + return FIAT_CURRENCIES.contains(symbol); } } diff --git a/src/test/java/com/binance/api/client/constant/UtilTest.java b/src/test/java/com/binance/api/client/constant/UtilTest.java new file mode 100644 index 000000000..55d9cf0c0 --- /dev/null +++ b/src/test/java/com/binance/api/client/constant/UtilTest.java @@ -0,0 +1,19 @@ +package com.binance.api.client.constant; + +import org.junit.Test; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * @see Util + */ +public class UtilTest { + @Test + public void testFiatCheck() { + assertTrue(Util.isFiatCurrency("USDT")); + assertTrue(Util.isFiatCurrency("BUSD")); + assertTrue(Util.isFiatCurrency("EUR")); + assertFalse(Util.isFiatCurrency("BTC")); + assertFalse(Util.isFiatCurrency("ETH")); + } +} From 69a15e410dd3eb8d585041878d447ad6c9b201f3 Mon Sep 17 00:00:00 2001 From: Girts Strazdins Date: Thu, 29 Dec 2022 11:48:11 +0100 Subject: [PATCH 06/14] Introduce ApiCredentials and creating it from key/seret in env variables --- .../api/client/BinanceApiClientFactory.java | 11 ++++ .../api/client/security/ApiCredentials.java | 50 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 src/main/java/com/binance/api/client/security/ApiCredentials.java diff --git a/src/main/java/com/binance/api/client/BinanceApiClientFactory.java b/src/main/java/com/binance/api/client/BinanceApiClientFactory.java index 18939de4b..8a258caed 100755 --- a/src/main/java/com/binance/api/client/BinanceApiClientFactory.java +++ b/src/main/java/com/binance/api/client/BinanceApiClientFactory.java @@ -2,6 +2,7 @@ import com.binance.api.client.impl.*; import com.binance.api.client.config.BinanceApiConfig; +import com.binance.api.client.security.ApiCredentials; import static com.binance.api.client.impl.BinanceApiServiceGenerator.getSharedClient; /** @@ -59,6 +60,16 @@ public static BinanceApiClientFactory newInstance(String apiKey, String secret) return new BinanceApiClientFactory(apiKey, secret); } + /** + * Create a new instance. + * + * @param credentials Credentials - the API key and secret + * @return the binance api client factory + */ + public static BinanceApiClientFactory newInstance(ApiCredentials credentials) { + return new BinanceApiClientFactory(credentials.getKey(), credentials.getSecret()); + } + /** * New instance with optional Spot Test Network endpoint. * diff --git a/src/main/java/com/binance/api/client/security/ApiCredentials.java b/src/main/java/com/binance/api/client/security/ApiCredentials.java new file mode 100644 index 000000000..9395106c5 --- /dev/null +++ b/src/main/java/com/binance/api/client/security/ApiCredentials.java @@ -0,0 +1,50 @@ +package com.binance.api.client.security; + +/** + * Stores Binance API key and API secret. + */ +public class ApiCredentials { + private static final String ENV_VAR_KEY = "BINANCE_API_KEY"; + private static final String ENV_VAR_SECRET = "BINANCE_API_SECRET"; + + private final String key; + private final String secret; + + + /** + * Create a new Binance API credential pair. + * + * @param key API key + * @param secret API secret + */ + public ApiCredentials(String key, String secret) { + this.key = key; + this.secret = secret; + } + + /** + * Creates credentials from environment variables (see ENV_VAR_xxx constante). + * + * @return The credential object + * @throws IllegalArgumentException When one of the environment variables is missing + */ + public static ApiCredentials creatFromEnvironment() throws IllegalArgumentException { + String apiKey = System.getenv(ENV_VAR_KEY); + if (apiKey == null) { + throw new IllegalArgumentException(ENV_VAR_KEY + " environment variable is missing"); + } + String apiSecret = System.getenv(ENV_VAR_SECRET); + if (apiSecret == null) { + throw new IllegalArgumentException(ENV_VAR_SECRET + " environment variable is missing"); + } + return new ApiCredentials(apiKey, apiSecret); + } + + public String getKey() { + return key; + } + + public String getSecret() { + return secret; + } +} From ff3634a83bd728ae028dd3b327146d3d94e6a93f Mon Sep 17 00:00:00 2001 From: Girts Strazdins Date: Thu, 29 Dec 2022 11:54:28 +0100 Subject: [PATCH 07/14] New endpoint: getAccountInformation (User Asset) See docs: https://binance-docs.github.io/apidocs/spot/en/#user-asset-user_data --- .../api/client/BinanceApiRestClient.java | 11 ++++ .../client/domain/account/AssetBalance.java | 24 +++++++ .../domain/account/ExtendedAssetBalance.java | 62 +++++++++++++++++++ .../client/impl/BinanceApiRestClientImpl.java | 8 +++ .../api/client/impl/BinanceApiService.java | 9 +++ .../ExtendedAccountBalanceExample.java | 37 +++++++++++ 6 files changed, 151 insertions(+) create mode 100644 src/main/java/com/binance/api/client/domain/account/ExtendedAssetBalance.java create mode 100644 src/test/java/com/binance/api/examples/ExtendedAccountBalanceExample.java diff --git a/src/main/java/com/binance/api/client/BinanceApiRestClient.java b/src/main/java/com/binance/api/client/BinanceApiRestClient.java index 721310474..86bd315ed 100755 --- a/src/main/java/com/binance/api/client/BinanceApiRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiRestClient.java @@ -292,6 +292,17 @@ public interface BinanceApiRestClient { */ DepositAddress getDepositAddress(String asset); + /** + * Get User account information. + * + * @param asset When specified, include only the given asset. When null, get + * balances for all assets + * @param needBtcValuation When true, include value in BTC for each asset. + * @return A list of all user assets with non-zero balances (or only the one asset, + * when specified) + */ + List getUserAssets(String asset, boolean needBtcValuation); + // User stream endpoints /** diff --git a/src/main/java/com/binance/api/client/domain/account/AssetBalance.java b/src/main/java/com/binance/api/client/domain/account/AssetBalance.java index 1d75d6307..694cfdf4d 100755 --- a/src/main/java/com/binance/api/client/domain/account/AssetBalance.java +++ b/src/main/java/com/binance/api/client/domain/account/AssetBalance.java @@ -39,6 +39,30 @@ public String getFree() { return free; } + /** + * Get free amount as a floating point number. + * + * @return The free amount + * @throws NumberFormatException if the free amount is not a valid number + */ + public Double getFreeAsNumber() { + return Double.parseDouble(free); + } + + /** + * Get locked amount as a floating point number. + * + * @return The locked amount + * @throws NumberFormatException if the locked amount is not a valid number + */ + public Double getLockedAsNumber() { + return Double.parseDouble(locked); + } + + public Double getTotalAmount() { + return getFreeAsNumber() + getLockedAsNumber(); + } + public void setFree(String free) { this.free = free; } diff --git a/src/main/java/com/binance/api/client/domain/account/ExtendedAssetBalance.java b/src/main/java/com/binance/api/client/domain/account/ExtendedAssetBalance.java new file mode 100644 index 000000000..678145401 --- /dev/null +++ b/src/main/java/com/binance/api/client/domain/account/ExtendedAssetBalance.java @@ -0,0 +1,62 @@ +package com.binance.api.client.domain.account; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Asset balance with extra information. Used in some endpoints, for example + * User Asset: https://binance-docs.github.io/apidocs/spot/en/#user-asset-user_data + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ExtendedAssetBalance extends AssetBalance { + private String freeze; + private String withdrawing; + private String ipoable; + private String btcValuation; + + public String getFreeze() { + return freeze; + } + + public void setFreeze(String freeze) { + this.freeze = freeze; + } + + public String getWithdrawing() { + return withdrawing; + } + + public void setWithdrawing(String withdrawing) { + this.withdrawing = withdrawing; + } + + public String getIpoable() { + return ipoable; + } + + public void setIpoable(String ipoable) { + this.ipoable = ipoable; + } + + /** + * Get the asset value in BTC, according to current prices. + * + * @return BTC-value of the asset + */ + public String getBtcValuation() { + return btcValuation; + } + + public void setBtcValuation(String btcValuation) { + this.btcValuation = btcValuation; + } + + /** + * Get the BTC value, as a floating point number. + * + * @return The BTC value of the asset + * @throws NumberFormatException when the value is not a number + */ + public double getBtcValuationAsNumber() { + return Double.parseDouble(btcValuation); + } +} diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java index 0076ffe06..74206432a 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java @@ -249,6 +249,14 @@ public DepositAddress getDepositAddress(String asset) { System.currentTimeMillis())); } + @Override + public List getUserAssets(String asset, boolean needBtcValuation) { + return executeSync(binanceApiService.getUserAssets(asset, needBtcValuation, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + System.currentTimeMillis()) + ); + } + // User stream endpoints @Override diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiService.java b/src/main/java/com/binance/api/client/impl/BinanceApiService.java index a2a92e069..1556ff426 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiService.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiService.java @@ -164,6 +164,15 @@ Call withdraw(@Query("asset") String asset, @Query("address") St @POST("/sapi/v1/asset/dust") Call dustTransfer(@Query("asset") List asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @POST("/sapi/v3/asset/getUserAsset") + Call> getUserAssets( + @Query("asset") String asset, + @Query("needBtcValuation") boolean needBtcValuation, + @Query("recvWindow") Long recvWindow, + @Query("timestamp") Long timestamp + ); + // User stream endpoints @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER) diff --git a/src/test/java/com/binance/api/examples/ExtendedAccountBalanceExample.java b/src/test/java/com/binance/api/examples/ExtendedAccountBalanceExample.java new file mode 100644 index 000000000..6ee05ce0c --- /dev/null +++ b/src/test/java/com/binance/api/examples/ExtendedAccountBalanceExample.java @@ -0,0 +1,37 @@ +package com.binance.api.examples; + +import com.binance.api.client.BinanceApiClientFactory; +import com.binance.api.client.BinanceApiRestClient; +import com.binance.api.client.domain.account.ExtendedAssetBalance; +import com.binance.api.client.security.ApiCredentials; +import java.util.List; + +/** + * List the current user assets in the wallet, and their BTC value + */ +public class ExtendedAccountBalanceExample { + + private final BinanceApiRestClient client; + + public ExtendedAccountBalanceExample() { + ApiCredentials credentials = ApiCredentials.creatFromEnvironment(); + BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(credentials); + client = factory.newRestClient(); + } + + public static void main(String[] args) { + ExtendedAccountBalanceExample example = new ExtendedAccountBalanceExample(); + example.run(); + } + + private void run() { + List balances = client.getUserAssets(null, true); + double totalBtcValue = 0; + for (ExtendedAssetBalance balance : balances) { + System.out.println(balance.getAsset() + ": " + balance.getTotalAmount() + " == " + + balance.getBtcValuation() + " BTC"); + totalBtcValue += balance.getBtcValuationAsNumber(); + } + System.out.println("Total BTC value of the wallet (Spot): " + totalBtcValue); + } +} From 042f2799f49c41b9621938942358f88ad14e4d66 Mon Sep 17 00:00:00 2001 From: Girts Strazdins Date: Thu, 29 Dec 2022 12:03:46 +0100 Subject: [PATCH 08/14] Remove the recvWindow parameter Refactor/fix TotalAccountBalanceExample --- .../api/client/BinanceApiRestClient.java | 7 +- .../com/binance/api/client/constant/Util.java | 67 ++++++++++- .../client/impl/BinanceApiRestClientImpl.java | 22 ++-- .../api/examples/AccountEndpointsExample.java | 2 +- .../examples/TotalAccountBalanceExample.java | 113 +++++++++++------- 5 files changed, 143 insertions(+), 68 deletions(-) diff --git a/src/main/java/com/binance/api/client/BinanceApiRestClient.java b/src/main/java/com/binance/api/client/BinanceApiRestClient.java index 86bd315ed..f940e57f9 100755 --- a/src/main/java/com/binance/api/client/BinanceApiRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiRestClient.java @@ -215,11 +215,6 @@ public interface BinanceApiRestClient { /** * Get current account information. */ - Account getAccount(Long recvWindow, Long timestamp); - - /** - * Get current account information using default parameters. - */ Account getAccount(); /** @@ -230,7 +225,7 @@ public interface BinanceApiRestClient { * @param fromId TradeId to fetch from. Default gets most recent trades. * @return a list of trades */ - List getMyTrades(String symbol, Integer limit, Long fromId, Long recvWindow, Long timestamp); + List getMyTrades(String symbol, Integer limit, Long fromId); /** * Get trades for a specific account and symbol. diff --git a/src/main/java/com/binance/api/client/constant/Util.java b/src/main/java/com/binance/api/client/constant/Util.java index 7ca1330b2..7ac268ec3 100755 --- a/src/main/java/com/binance/api/client/constant/Util.java +++ b/src/main/java/com/binance/api/client/constant/Util.java @@ -1,7 +1,9 @@ package com.binance.api.client.constant; - +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.Arrays; +import java.util.Date; import java.util.HashSet; import java.util.Set; @@ -17,17 +19,78 @@ public final class Util { Arrays.asList("EUR", "USDT", "BUSD", "PAX", "TUSD", "USDC", "NGN", "RUB", "USDS", "TRY") ); + /** + * List of assets which are present on Binance but are not traded. + */ + private static final Set NON_TRADED_ASSETS = new HashSet<>( + Arrays.asList("DON", "NFT", "ETHW") + ); + + // All currencies placed in Earnings account are assigned this prefix + private static final String EARNINGS_CURRENCY_PREFIX = "LD"; + public static final String BTC_TICKER = "BTC"; + private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + private Util() { } /** - * Check if the ticker is fiat currency. + * Check if the asset is fiat currency. * * @return True if it is a fiat currency (USD, EUR, etc), false when it isn't */ public static boolean isFiatCurrency(String symbol) { return FIAT_CURRENCIES.contains(symbol); } + + + /** + * Check if the asset is a currency deposited in an Earnings account. + * + * @return True if it is an earnings currency, false when it isn't + */ + public static boolean isEarningsCurrency(String asset) { + return asset != null && asset.startsWith(EARNINGS_CURRENCY_PREFIX); + } + + /** + * Convert an earnings asset symbol to normal currency symbol. + * + * @param asset The earnings asset symbol + * @return The regular asset (coin) symbol + */ + public static String earningSymbolToCoin(String asset) { + if (!isEarningsCurrency(asset)) { + throw new IllegalArgumentException(asset + " is not an asset in earnings account"); + } + return asset.substring(2); + } + + /** + * Check if the given asset is traded on the exchange (some tokens are not, such as DON). + * + * @param asset The asset to check + * @return True if it is traded, false if it is not. + */ + public static boolean isTraded(String asset) { + return !NON_TRADED_ASSETS.contains(asset); + } + + /** + * Convert a timestamp string in the format "yyyy-MM-dd hh:mm:ss" (such as "2022-12-20 20:48:22") + * to a unix timestamp, with milliseconds. + * + * @param timeString The timestamp string + * @return Unix timestamp, with milliseconds + */ + public static long getTimestampFor(String timeString) { + try { + Date parsedDate = dateFormat.parse(timeString); + return parsedDate.getTime(); + } catch (ParseException e) { + throw new RuntimeException("Invalid time string: " + timeString); + } + } } diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java index 74206432a..5ea5dcc2f 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java @@ -187,37 +187,31 @@ public List getAllOrderList(AllOrderListRequest allOrderListRequest) allOrderListRequest.getEndTime(), allOrderListRequest.getLimit(), allOrderListRequest.getRecvWindow(), allOrderListRequest.getTimestamp())); } - @Override - public Account getAccount(Long recvWindow, Long timestamp) { - return executeSync(binanceApiService.getAccount(recvWindow, timestamp)); - } - @Override public Account getAccount() { - return getAccount(BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()); + return executeSync(binanceApiService.getAccount(BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + System.currentTimeMillis())); } @Override - public List getMyTrades(String symbol, Integer limit, Long fromId, Long recvWindow, Long timestamp) { - return executeSync(binanceApiService.getMyTrades(symbol, limit, fromId, recvWindow, timestamp)); + public List getMyTrades(String symbol, Integer limit, Long fromId) { + return executeSync(binanceApiService.getMyTrades(symbol, limit, fromId, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); } @Override public List getMyTrades(String symbol, Integer limit) { - return getMyTrades(symbol, limit, null, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - System.currentTimeMillis()); + return getMyTrades(symbol, limit, null); } @Override public List getMyTrades(String symbol) { - return getMyTrades(symbol, null, null, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - System.currentTimeMillis()); + return getMyTrades(symbol, null, null); } @Override public List getMyTrades(String symbol, Long fromId) { - return getMyTrades(symbol, null, fromId, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - System.currentTimeMillis()); + return getMyTrades(symbol, null, fromId); } @Override diff --git a/src/test/java/com/binance/api/examples/AccountEndpointsExample.java b/src/test/java/com/binance/api/examples/AccountEndpointsExample.java index 72fc68c3d..bde3be63b 100755 --- a/src/test/java/com/binance/api/examples/AccountEndpointsExample.java +++ b/src/test/java/com/binance/api/examples/AccountEndpointsExample.java @@ -17,7 +17,7 @@ public static void main(String[] args) { BinanceApiRestClient client = factory.newRestClient(); // Get account balances - Account account = client.getAccount(60_000L, System.currentTimeMillis()); + Account account = client.getAccount(); System.out.println(account.getBalances()); System.out.println(account.getAssetBalance("ETH")); diff --git a/src/test/java/com/binance/api/examples/TotalAccountBalanceExample.java b/src/test/java/com/binance/api/examples/TotalAccountBalanceExample.java index 5abfe04f1..e8f7271ef 100755 --- a/src/test/java/com/binance/api/examples/TotalAccountBalanceExample.java +++ b/src/test/java/com/binance/api/examples/TotalAccountBalanceExample.java @@ -5,59 +5,82 @@ import com.binance.api.client.constant.Util; import com.binance.api.client.domain.account.Account; import com.binance.api.client.domain.account.AssetBalance; +import com.binance.api.client.security.ApiCredentials; /** * Example how to get total of balances on your account */ public class TotalAccountBalanceExample { - - - public static void main(String[] args) { - BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_SECRET"); - BinanceApiRestClient client = factory.newRestClient(); - - // Get account balances - Account account = client.getAccount(60_000L, System.currentTimeMillis()); - - // Get total account balance in BTC (spot only) - TotalAccountBalanceExample accountBalance = new TotalAccountBalanceExample(); - double totalBalanceInBTC = accountBalance.getTotalAccountBalance(client,account); - System.out.println(totalBalanceInBTC); - // Get total account balance in USDT (spot only) - double totalBalanceInUSDT = totalBalanceInBTC * Double.parseDouble(client.getPrice("BTCUSDT").getPrice()); - System.out.println(totalBalanceInUSDT); - - - - - } - - // Get total account balance in BTC (spot only) - public double getTotalAccountBalance(BinanceApiRestClient client, Account account) { - double totalBalance = 0; - for (AssetBalance balance : account.getBalances()) { - double free = Double.parseDouble(balance.getFree()); - double locked = Double.parseDouble(balance.getLocked()); - String ticker = balance.getAsset() + Util.BTC_TICKER; - String tickerReverse = Util.BTC_TICKER + balance.getAsset(); - if (free + locked != 0) { - if (Util.isFiatCurrency(balance.getAsset())) { - double price = Double.parseDouble(client.getPrice(tickerReverse).getPrice()); - double amount = (free + locked) / price; - totalBalance += amount; - } else { - double price = Double.parseDouble(client.getPrice(ticker).getPrice()); - double amount = price * (free + locked); - totalBalance += amount; - } - - } + private final BinanceApiRestClient client; + + TotalAccountBalanceExample() { + ApiCredentials credentials = ApiCredentials.creatFromEnvironment(); + BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(credentials); + client = factory.newRestClient(); + } + + + public static void main(String[] args) { + TotalAccountBalanceExample example = new TotalAccountBalanceExample(); + example.run(); + } + + private void run() { + Account account = client.getAccount(); + double totalBalanceInBtc = getTotalAccountBalanceInBTC(account); + System.out.println("Total wallet value in BTC: " + totalBalanceInBtc); + double balanceInUsd = totalBalanceInBtc + * Double.parseDouble(client.getPrice("BTCUSDT").getPrice()); + System.out.println("Wallet value in USD: " + balanceInUsd); + } + + private double getTotalAccountBalanceInBTC(Account account) { + double totalBalance = 0; + for (AssetBalance balance : account.getBalances()) { + String asset = balance.getAsset(); + if (Util.isEarningsCurrency(balance.getAsset())) { + asset = Util.earningSymbolToCoin(balance.getAsset()); + } + if (Util.isTraded(asset)) { + double amount; + if (asset.equals("BTC")) { + amount = balance.getFreeAsNumber() + balance.getLockedAsNumber(); + } else { + amount = getAssetValueInBTC(balance, asset); } - - return totalBalance; - + totalBalance += amount; + } + } + return totalBalance; + } + + private double getAssetValueInBTC(AssetBalance balance, String asset) { + double free = balance.getFreeAsNumber(); + double locked = balance.getLockedAsNumber(); + double amount = 0; + + if (free + locked > 0) { + if (Util.isFiatCurrency(asset)) { + String tickerReverse = Util.BTC_TICKER + asset; + amount = getFiatBtcValue(free + locked, tickerReverse); + } else { + String ticker = asset + Util.BTC_TICKER; + amount = getCoinBtcValue(free + locked, ticker); + } } + return amount; + } + private double getCoinBtcValue(double coinAmount, String symbol) { + System.out.println("Getting price for " + symbol); + double coinPriceInBTC = Double.parseDouble(client.getPrice(symbol).getPrice()); + return coinPriceInBTC * coinAmount; + } + private double getFiatBtcValue(double fiatAmount, String symbol) { + System.out.println("Getting price for " + symbol); + double btcPriceInFiat = Double.parseDouble(client.getPrice(symbol).getPrice()); + return fiatAmount / btcPriceInFiat; + } } From 86d52f7a59bad58c16bbc96a868872ec571ab216 Mon Sep 17 00:00:00 2001 From: Girts Strazdins Date: Thu, 29 Dec 2022 12:04:01 +0100 Subject: [PATCH 09/14] Some grammas fixes --- .../java/com/binance/api/client/domain/account/Account.java | 6 +++--- .../binance/api/client/domain/account/WithdrawResult.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/binance/api/client/domain/account/Account.java b/src/main/java/com/binance/api/client/domain/account/Account.java index 4356bfccb..95835efdb 100755 --- a/src/main/java/com/binance/api/client/domain/account/Account.java +++ b/src/main/java/com/binance/api/client/domain/account/Account.java @@ -33,17 +33,17 @@ public class Account { private int sellerCommission; /** - * Whether or not this account can trade. + * Whether this account can trade. */ private boolean canTrade; /** - * Whether or not it is possible to withdraw from this account. + * Whether it is possible to withdraw from this account. */ private boolean canWithdraw; /** - * Whether or not it is possible to deposit into this account. + * Whether it is possible to deposit into this account. */ private boolean canDeposit; diff --git a/src/main/java/com/binance/api/client/domain/account/WithdrawResult.java b/src/main/java/com/binance/api/client/domain/account/WithdrawResult.java index 0544af065..7f9881a1b 100755 --- a/src/main/java/com/binance/api/client/domain/account/WithdrawResult.java +++ b/src/main/java/com/binance/api/client/domain/account/WithdrawResult.java @@ -5,7 +5,7 @@ import org.apache.commons.lang3.builder.ToStringStyle; /** - * A withdraw result that was done to a Binance account. + * A withdrawal result that was done to a Binance account. */ @JsonIgnoreProperties(ignoreUnknown = true) public class WithdrawResult { From b7e7237e9cac13c2569294adee866a7194a4b445 Mon Sep 17 00:00:00 2001 From: Girts Strazdins Date: Thu, 29 Dec 2022 12:30:31 +0100 Subject: [PATCH 10/14] Extract common base class for examples using authentication --- .../examples/AuthenticatedExampleBase.java | 22 +++++++++++++++++++ .../ExtendedAccountBalanceExample.java | 12 +--------- .../examples/TotalAccountBalanceExample.java | 13 +---------- 3 files changed, 24 insertions(+), 23 deletions(-) create mode 100644 src/test/java/com/binance/api/examples/AuthenticatedExampleBase.java diff --git a/src/test/java/com/binance/api/examples/AuthenticatedExampleBase.java b/src/test/java/com/binance/api/examples/AuthenticatedExampleBase.java new file mode 100644 index 000000000..d3ed82651 --- /dev/null +++ b/src/test/java/com/binance/api/examples/AuthenticatedExampleBase.java @@ -0,0 +1,22 @@ +package com.binance.api.examples; + +import com.binance.api.client.BinanceApiClientFactory; +import com.binance.api.client.BinanceApiRestClient; +import com.binance.api.client.security.ApiCredentials; + +/** + * An abstract base class which creates the necessary tools for an example requiring + * authenticated endpoints. + */ +public abstract class AuthenticatedExampleBase { + protected final BinanceApiRestClient client; + + /** + * Create an example, get API key and secret from the environment variables. + */ + public AuthenticatedExampleBase() { + ApiCredentials credentials = ApiCredentials.creatFromEnvironment(); + BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(credentials); + client = factory.newRestClient(); + } +} diff --git a/src/test/java/com/binance/api/examples/ExtendedAccountBalanceExample.java b/src/test/java/com/binance/api/examples/ExtendedAccountBalanceExample.java index 6ee05ce0c..579b17736 100644 --- a/src/test/java/com/binance/api/examples/ExtendedAccountBalanceExample.java +++ b/src/test/java/com/binance/api/examples/ExtendedAccountBalanceExample.java @@ -1,23 +1,13 @@ package com.binance.api.examples; -import com.binance.api.client.BinanceApiClientFactory; -import com.binance.api.client.BinanceApiRestClient; import com.binance.api.client.domain.account.ExtendedAssetBalance; -import com.binance.api.client.security.ApiCredentials; import java.util.List; /** * List the current user assets in the wallet, and their BTC value */ -public class ExtendedAccountBalanceExample { +public class ExtendedAccountBalanceExample extends AuthenticatedExampleBase { - private final BinanceApiRestClient client; - - public ExtendedAccountBalanceExample() { - ApiCredentials credentials = ApiCredentials.creatFromEnvironment(); - BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(credentials); - client = factory.newRestClient(); - } public static void main(String[] args) { ExtendedAccountBalanceExample example = new ExtendedAccountBalanceExample(); diff --git a/src/test/java/com/binance/api/examples/TotalAccountBalanceExample.java b/src/test/java/com/binance/api/examples/TotalAccountBalanceExample.java index e8f7271ef..8db9b640b 100755 --- a/src/test/java/com/binance/api/examples/TotalAccountBalanceExample.java +++ b/src/test/java/com/binance/api/examples/TotalAccountBalanceExample.java @@ -1,24 +1,13 @@ package com.binance.api.examples; -import com.binance.api.client.BinanceApiClientFactory; -import com.binance.api.client.BinanceApiRestClient; import com.binance.api.client.constant.Util; import com.binance.api.client.domain.account.Account; import com.binance.api.client.domain.account.AssetBalance; -import com.binance.api.client.security.ApiCredentials; /** * Example how to get total of balances on your account */ -public class TotalAccountBalanceExample { - private final BinanceApiRestClient client; - - TotalAccountBalanceExample() { - ApiCredentials credentials = ApiCredentials.creatFromEnvironment(); - BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(credentials); - client = factory.newRestClient(); - } - +public class TotalAccountBalanceExample extends AuthenticatedExampleBase { public static void main(String[] args) { TotalAccountBalanceExample example = new TotalAccountBalanceExample(); From c6f285d889644365c7515b808cb4c62c78ca5cee Mon Sep 17 00:00:00 2001 From: Girts Strazdins Date: Thu, 29 Dec 2022 13:34:15 +0100 Subject: [PATCH 11/14] Fix withdrawal endpoint --- .../api/client/BinanceApiAsyncRestClient.java | 50 ++++++++++++++- .../api/client/BinanceApiRestClient.java | 32 +++++++++- .../api/client/domain/account/Withdraw.java | 25 ++------ .../domain/account/WithdrawHistory.java | 44 ------------- .../impl/BinanceApiAsyncRestClientImpl.java | 32 ++++++++-- .../client/impl/BinanceApiRestClientImpl.java | 12 +++- .../api/client/impl/BinanceApiService.java | 42 +++++++++++- .../WithdrawHistoryDeserializerTest.java | 44 ------------- .../api/examples/AccountEndpointsExample.java | 64 +++++++++++++------ .../api/examples/WithdrawHistoryExample.java | 24 +++++++ 10 files changed, 230 insertions(+), 139 deletions(-) delete mode 100755 src/main/java/com/binance/api/client/domain/account/WithdrawHistory.java delete mode 100755 src/test/java/com/binance/api/domain/account/WithdrawHistoryDeserializerTest.java create mode 100644 src/test/java/com/binance/api/examples/WithdrawHistoryExample.java diff --git a/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java b/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java index 38d377883..4867cf07c 100755 --- a/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java @@ -3,12 +3,13 @@ import com.binance.api.client.domain.account.Account; import com.binance.api.client.domain.account.DepositAddress; import com.binance.api.client.domain.account.DepositHistory; +import com.binance.api.client.domain.account.ExtendedAssetBalance; import com.binance.api.client.domain.account.NewOrder; import com.binance.api.client.domain.account.NewOrderResponse; import com.binance.api.client.domain.account.Order; import com.binance.api.client.domain.account.Trade; import com.binance.api.client.domain.account.TradeHistoryItem; -import com.binance.api.client.domain.account.WithdrawHistory; +import com.binance.api.client.domain.account.Withdraw; import com.binance.api.client.domain.account.WithdrawResult; import com.binance.api.client.domain.account.request.AllOrdersRequest; import com.binance.api.client.domain.account.request.CancelOrderRequest; @@ -226,6 +227,18 @@ public interface BinanceApiAsyncRestClient { */ void getAccount(BinanceApiCallback callback); + /** + * Get User account information. + * + * @param asset When specified, include only the given asset. When null, get + * balances for all assets + * @param needBtcValuation When true, include value in BTC for each asset. + * @return A list of all user assets with non-zero balances (or only the one asset, + * when specified) + */ + void getUserAssets(String asset, boolean needBtcValuation, + BinanceApiCallback> callback); + /** * Get trades for a specific account and symbol. * @@ -273,12 +286,43 @@ public interface BinanceApiAsyncRestClient { */ void getDepositHistory(String asset, BinanceApiCallback callback); + /** + * Fetch account withdraw history. + * See https://binance-docs.github.io/apidocs/spot/en/#withdraw-history-supporting-network-user_data + * Comments from the docs: + * Please notice the default startTime and endTime to make sure that time interval is within 0-90 days. + * If both startTime and endTime are sent, time between startTime and endTime must be less than 90 days. + * If withdrawOrderId is sent, time between startTime and endTime must be less than 7 days. + * If withdrawOrderId is sent, startTime and endTime are not sent, will return last 7 days records by default. + * + * @param coin + * @param withdrawOrderId + * @param status When specified, filter by transaction status: + * - 0:Email Sent + * - 1:Cancelled + * - 2:Awaiting Approval + * - 3:Rejected + * - 4:Processing + * - 5:Failure + * - 6:Completed + * @param offset + * @param limit Default: 1000, Max: 1000 + * @param startTime Default: 90 days from current timestamp + * @param endTime Default: present timestamp + * @param callback the callback that handles the response and returns the withdrawal history + */ + void getWithdrawHistory(String coin, String withdrawOrderId, Integer status, + Integer offset, Integer limit, Long startTime, Long endTime, + BinanceApiCallback> callback); + /** * Fetch account withdraw history. * - * @param callback the callback that handles the response and returns the withdraw history + * @param coin The coin in the withdrawals + * @param callback the callback that handles the response and returns the withdrawal history */ - void getWithdrawHistory(String asset, BinanceApiCallback callback); + void getWithdrawHistory(String coin, + BinanceApiCallback> callback); /** * Fetch deposit address. diff --git a/src/main/java/com/binance/api/client/BinanceApiRestClient.java b/src/main/java/com/binance/api/client/BinanceApiRestClient.java index f940e57f9..b99e71ae0 100755 --- a/src/main/java/com/binance/api/client/BinanceApiRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiRestClient.java @@ -275,10 +275,40 @@ public interface BinanceApiRestClient { /** * Fetch account withdraw history. + * See https://binance-docs.github.io/apidocs/spot/en/#withdraw-history-supporting-network-user_data + * Comments from the docs: + * Please notice the default startTime and endTime to make sure that time interval is within 0-90 days. + * If both startTime and endTime are sent, time between startTime and endTime must be less than 90 days. + * If withdrawOrderId is sent, time between startTime and endTime must be less than 7 days. + * If withdrawOrderId is sent, startTime and endTime are not sent, will return last 7 days records by default. * + * @param coin + * @param withdrawOrderId + * @param status When specified, filter by transaction status: + * - 0:Email Sent + * - 1:Cancelled + * - 2:Awaiting Approval + * - 3:Rejected + * - 4:Processing + * - 5:Failure + * - 6:Completed + * @param offset + * @param limit Default: 1000, Max: 1000 + * @param startTime Default: 90 days from current timestamp + * @param endTime Default: present timestamp * @return withdraw history, containing a list of withdrawals */ - WithdrawHistory getWithdrawHistory(String asset); + List getWithdrawHistory(String coin, String withdrawOrderId, Integer status, + Integer offset, Integer limit, Long startTime, Long endTime); + + /** + * Fetch account withdraw history, with default values. + * See https://binance-docs.github.io/apidocs/spot/en/#withdraw-history-supporting-network-user_data + * + * @param coin The coin to look withdrawals for + * @return withdraw history, containing a list of withdrawals + */ + List getWithdrawHistory(String coin); /** * Fetch deposit address. diff --git a/src/main/java/com/binance/api/client/domain/account/Withdraw.java b/src/main/java/com/binance/api/client/domain/account/Withdraw.java index 69635ee99..53b6c2bec 100755 --- a/src/main/java/com/binance/api/client/domain/account/Withdraw.java +++ b/src/main/java/com/binance/api/client/domain/account/Withdraw.java @@ -5,7 +5,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder; /** - * A withdraw that was done to a Binance account. + * A withdrawal from a Binance account. */ @JsonIgnoreProperties(ignoreUnknown = true) public class Withdraw { @@ -23,12 +23,10 @@ public class Withdraw { /** * Symbol. */ - private String asset; + private String coin; private String applyTime; - private String successTime; - /** * Transaction id. */ @@ -60,12 +58,12 @@ public void setAddress(String address) { this.address = address; } - public String getAsset() { - return asset; + public String getCoin() { + return coin; } - public void setAsset(String asset) { - this.asset = asset; + public void setCoin(String coin) { + this.coin = coin; } public String getApplyTime() { @@ -76,14 +74,6 @@ public void setApplyTime(String applyTime) { this.applyTime = applyTime; } - public String getSuccessTime() { - return successTime; - } - - public void setSuccessTime(String successTime) { - this.successTime = successTime; - } - public String getTxId() { return txId; } @@ -113,9 +103,8 @@ public String toString() { return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) .append("amount", amount) .append("address", address) - .append("asset", asset) + .append("coin", coin) .append("applyTime", applyTime) - .append("successTime", successTime) .append("txId", txId) .append("id", id) .append("status", status) diff --git a/src/main/java/com/binance/api/client/domain/account/WithdrawHistory.java b/src/main/java/com/binance/api/client/domain/account/WithdrawHistory.java deleted file mode 100755 index df57f89a5..000000000 --- a/src/main/java/com/binance/api/client/domain/account/WithdrawHistory.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.binance.api.client.domain.account; - -import com.binance.api.client.constant.BinanceApiConstants; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import org.apache.commons.lang3.builder.ToStringBuilder; - -import java.util.List; - -/** - * History of account withdrawals. - * - * @see Withdraw - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class WithdrawHistory { - - private List withdrawList; - - private boolean success; - - public List getWithdrawList() { - return withdrawList; - } - - public void setWithdrawList(List withdrawList) { - this.withdrawList = withdrawList; - } - - public boolean isSuccess() { - return success; - } - - public void setSuccess(boolean success) { - this.success = success; - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("withdrawList", withdrawList) - .append("success", success) - .toString(); - } -} diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java index 149cc7bc2..ac74396ad 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java @@ -7,12 +7,13 @@ import com.binance.api.client.domain.account.Account; import com.binance.api.client.domain.account.DepositAddress; import com.binance.api.client.domain.account.DepositHistory; +import com.binance.api.client.domain.account.ExtendedAssetBalance; import com.binance.api.client.domain.account.NewOrder; import com.binance.api.client.domain.account.NewOrderResponse; import com.binance.api.client.domain.account.Order; import com.binance.api.client.domain.account.Trade; import com.binance.api.client.domain.account.TradeHistoryItem; -import com.binance.api.client.domain.account.WithdrawHistory; +import com.binance.api.client.domain.account.Withdraw; import com.binance.api.client.domain.account.WithdrawResult; import com.binance.api.client.domain.account.request.AllOrdersRequest; import com.binance.api.client.domain.account.request.CancelOrderRequest; @@ -30,6 +31,7 @@ import com.binance.api.client.domain.market.OrderBook; import com.binance.api.client.domain.market.TickerPrice; import com.binance.api.client.domain.market.TickerStatistics; +import retrofit2.Call; import java.util.List; @@ -193,6 +195,19 @@ public void getAccount(BinanceApiCallback callback) { binanceApiService.getAccount(BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, timestamp).enqueue(new BinanceApiCallbackAdapter<>(callback)); } + @Override + public void getUserAssets(String asset, boolean needBtcValuation, + BinanceApiCallback> callback) { + long timestamp = System.currentTimeMillis(); + Call> call = binanceApiService.getUserAssets( + asset, + needBtcValuation, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + timestamp + ); + call.enqueue(new BinanceApiCallbackAdapter<>(callback)); + } + @Override public void getMyTrades(String symbol, Integer limit, Long fromId, Long recvWindow, Long timestamp, BinanceApiCallback> callback) { binanceApiService.getMyTrades(symbol, limit, fromId, recvWindow, timestamp).enqueue(new BinanceApiCallbackAdapter<>(callback)); @@ -221,9 +236,18 @@ public void getDepositHistory(String asset, BinanceApiCallback c } @Override - public void getWithdrawHistory(String asset, BinanceApiCallback callback) { - binanceApiService.getWithdrawHistory(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()) - .enqueue(new BinanceApiCallbackAdapter<>(callback)); + public void getWithdrawHistory(String coin, String withdrawOrderId, Integer status, + Integer offset, Integer limit, Long startTime, Long endTime, + BinanceApiCallback> callback) { + Call> call = binanceApiService.getWithdrawHistory(coin, withdrawOrderId, + status, offset, limit, startTime, endTime, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + System.currentTimeMillis()); + call.enqueue(new BinanceApiCallbackAdapter<>(callback)); + } + + @Override + public void getWithdrawHistory(String coin, BinanceApiCallback> callback) { + getWithdrawHistory(coin, null, null, null, null, null, null, callback); } @Override diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java index 5ea5dcc2f..32af03dcf 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java @@ -232,11 +232,19 @@ public DepositHistory getDepositHistory(String asset) { } @Override - public WithdrawHistory getWithdrawHistory(String asset) { - return executeSync(binanceApiService.getWithdrawHistory(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + public List getWithdrawHistory(String coin, String withdrawOrderId, Integer status, + Integer offset, Integer limit, + Long startTime, Long endTime) { + return executeSync(binanceApiService.getWithdrawHistory(coin, withdrawOrderId, status, offset, + limit, startTime, endTime, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); } + @Override + public List getWithdrawHistory(String coin) { + return getWithdrawHistory(coin, null, null, null, null, null, null); + } + @Override public DepositAddress getDepositAddress(String asset) { return executeSync(binanceApiService.getDepositAddress(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiService.java b/src/main/java/com/binance/api/client/impl/BinanceApiService.java index 1556ff426..02bf681ae 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiService.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiService.java @@ -152,9 +152,45 @@ Call withdraw(@Query("asset") String asset, @Query("address") St @GET("/wapi/v3/depositHistory.html") Call getDepositHistory(@Query("asset") String asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); - @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/wapi/v3/withdrawHistory.html") - Call getWithdrawHistory(@Query("asset") String asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + /** + * Withdraw History. + * See https://binance-docs.github.io/apidocs/spot/en/#withdraw-history-supporting-network-user_data + * Comments from the docs: + * Please notice the default startTime and endTime to make sure that time interval is within 0-90 days. + * If both startTime and endTime are sent, time between startTime and endTime must be less than 90 days. + * If withdrawOrderId is sent, time between startTime and endTime must be less than 7 days. + * If withdrawOrderId is sent, startTime and endTime are not sent, will return last 7 days records by default. + * + * @param coin + * @param withdrawOrderId + * @param status When specified, filter by transaction status: + * - 0:Email Sent + * - 1:Cancelled + * - 2:Awaiting Approval + * - 3:Rejected + * - 4:Processing + * - 5:Failure + * - 6:Completed + * @param offset + * @param limit Default: 1000, Max: 1000 + * @param startTime Default: 90 days from current timestamp + * @param endTime Default: present timestamp + * @param recvWindow + * @param timestamp + * @return HTTP Call for the API endpoint + */ + @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) + @GET("/sapi/v1/capital/withdraw/history") + Call> getWithdrawHistory( + @Query("coin") String coin, + @Query("withdrawOrderId") String withdrawOrderId, + @Query("status") Integer status, + @Query("offset") Integer offset, + @Query("limit") Integer limit, + @Query("startTime") Long startTime, + @Query("endTime") Long endTime, + @Query("recvWindow") Long recvWindow, + @Query("timestamp") Long timestamp); @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) @GET("/wapi/v3/depositAddress.html") diff --git a/src/test/java/com/binance/api/domain/account/WithdrawHistoryDeserializerTest.java b/src/test/java/com/binance/api/domain/account/WithdrawHistoryDeserializerTest.java deleted file mode 100755 index d0a99bf85..000000000 --- a/src/test/java/com/binance/api/domain/account/WithdrawHistoryDeserializerTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.binance.api.domain.account; - -import com.binance.api.client.domain.account.Withdraw; -import com.binance.api.client.domain.account.WithdrawHistory; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; - -import java.io.IOException; -import java.util.List; - -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertTrue; -import static junit.framework.TestCase.fail; - -/** - * Test deserialization of a withdraw/deposit history. - */ -public class WithdrawHistoryDeserializerTest { - - @Test - public void testWithdrawHistoryDeserialziation() { - String withdrawHistoryJson = "{\"withdrawList\":\n" + - "[{\"amount\":0.1,\"address\":\"0x456\",\"successTime\":\"2017-10-13 21:20:09\",\n" + - "\"txId\":\"0x123\",\"id\":\"1\",\"asset\":\"ETH\",\"applyTime\":\"2017-10-13 20:59:38\",\"userId\":\"1\",\"status\":6}],\n" + - "\"success\":true}"; - ObjectMapper mapper = new ObjectMapper(); - try { - WithdrawHistory withdrawHistory = mapper.readValue(withdrawHistoryJson, WithdrawHistory.class); - assertTrue(withdrawHistory.isSuccess()); - List withdrawList = withdrawHistory.getWithdrawList(); - assertEquals(withdrawHistory.getWithdrawList().size(), 1); - Withdraw withdraw = withdrawList.get(0); - assertEquals(withdraw.getAmount(), "0.1"); - assertEquals(withdraw.getAddress(), "0x456"); - assertEquals(withdraw.getAsset(), "ETH"); - assertEquals(withdraw.getApplyTime(), "2017-10-13 20:59:38"); - assertEquals(withdraw.getSuccessTime(), "2017-10-13 21:20:09"); - assertEquals(withdraw.getTxId(), "0x123"); - assertEquals(withdraw.getId(), "1"); - } catch (IOException e) { - fail(e.getMessage()); - } - } -} diff --git a/src/test/java/com/binance/api/examples/AccountEndpointsExample.java b/src/test/java/com/binance/api/examples/AccountEndpointsExample.java index bde3be63b..0c39c36fb 100755 --- a/src/test/java/com/binance/api/examples/AccountEndpointsExample.java +++ b/src/test/java/com/binance/api/examples/AccountEndpointsExample.java @@ -1,7 +1,6 @@ package com.binance.api.examples; -import com.binance.api.client.BinanceApiClientFactory; -import com.binance.api.client.BinanceApiRestClient; +import com.binance.api.client.constant.Util; import com.binance.api.client.domain.account.Account; import com.binance.api.client.domain.account.Trade; @@ -10,31 +9,56 @@ /** * Examples on how to get account information. */ -public class AccountEndpointsExample { +public class AccountEndpointsExample extends AuthenticatedExampleBase { public static void main(String[] args) { - BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_SECRET"); - BinanceApiRestClient client = factory.newRestClient(); + AccountEndpointsExample example = new AccountEndpointsExample(); + example.run(); + } - // Get account balances - Account account = client.getAccount(); - System.out.println(account.getBalances()); - System.out.println(account.getAssetBalance("ETH")); + private void run() { + printAccountBalances(); + printMyTrades(); + printWithdrawalHistory(); + printDepositHistory(); + // Withdraw + // client.withdraw("ETH", "0x123", "0.1", null, null); + } - // Get list of trades - List myTrades = client.getMyTrades("NEOETH"); - System.out.println(myTrades); + private void printDepositHistory() { +// TODO System.out.println("Deposit history for LTC: "); +// System.out.println(client.getDepositHistory("LTC")); + } - // Get withdraw history - System.out.println(client.getWithdrawHistory("ETH")); + private void printWithdrawalHistory() { + System.out.println("Recent Withdrawals for LTC: "); + System.out.println(client.getWithdrawHistory("LTC")); + System.out.println(); - // Get deposit history - System.out.println(client.getDepositHistory("ETH")); + String startTimeString = "2019-11-01 00:00:00"; + String endTimeString = "2019-11-30 23:59:59"; + System.out.println("Withdrawals for LTC " + startTimeString + " - " + endTimeString); + long startTime = Util.getTimestampFor(startTimeString); + long endTime = Util.getTimestampFor(endTimeString); + System.out.println(client.getWithdrawHistory("LTC", null, null, null, null, + startTime, endTime)); + System.out.println(); + } - // Get deposit address - System.out.println(client.getDepositAddress("ETH")); + private void printMyTrades() { + // Get list of trades + List myTrades = client.getMyTrades("BTCUSDT"); + System.out.println("My trades in the BTC/USDT market: "); + System.out.println(myTrades); + System.out.println(""); + } - // Withdraw - client.withdraw("ETH", "0x123", "0.1", null, null); + private void printAccountBalances() { + Account account = client.getAccount(); + System.out.println("Balance for ETH: " + account.getAssetBalance("ETH").getTotalAmount()); + System.out.println(""); + + // This would print a lot of zeroes, unreadable: + // System.out.println("Account balances: " + account.getBalances()); } } diff --git a/src/test/java/com/binance/api/examples/WithdrawHistoryExample.java b/src/test/java/com/binance/api/examples/WithdrawHistoryExample.java new file mode 100644 index 000000000..ff9c5d2f7 --- /dev/null +++ b/src/test/java/com/binance/api/examples/WithdrawHistoryExample.java @@ -0,0 +1,24 @@ +package com.binance.api.examples; + +import com.binance.api.client.constant.Util; + +/** + * Example getting withdraw history. + */ +public class WithdrawHistoryExample extends AuthenticatedExampleBase { + public static void main(String[] args) { + WithdrawHistoryExample example = new WithdrawHistoryExample(); + example.run(); + } + + private void run() { + String startTimeString = "2019-11-01 00:00:00"; + String endTimeString = "2019-11-30 23:59:59"; + System.out.println("Withdrawals for LTC " + startTimeString + " - " + endTimeString); + long startTime = Util.getTimestampFor(startTimeString); + long endTime = Util.getTimestampFor(endTimeString); + System.out.println(client.getWithdrawHistory("LTC", null, null, null, null, + startTime, endTime)); + System.out.println(); + } +} From 98d9398d23d315d833b298b90a5528d23811dec2 Mon Sep 17 00:00:00 2001 From: Girts Strazdins Date: Thu, 29 Dec 2022 14:19:26 +0100 Subject: [PATCH 12/14] Update to version 2.0.0 - breaking changes included here. Also - set java.version variable; include reference to the original author. --- pom.xml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index c31624681..0c2403d3c 100755 --- a/pom.xml +++ b/pom.xml @@ -6,16 +6,18 @@ com.binance.api binance-api-client - 1.0.1 + 2.0.0 The MIT License https://opensource.org/licenses/MIT + A fork of the Binance API client library by João Silva 2.9.0 + 17 @@ -53,8 +55,8 @@ org.apache.maven.plugins maven-compiler-plugin - 17 - 17 + ${java.version} + ${java.version} From 4858164ef4099f621eb61813ff834cf4326986b7 Mon Sep 17 00:00:00 2001 From: Girts Strazdins Date: Thu, 29 Dec 2022 15:07:43 +0100 Subject: [PATCH 13/14] Fix deposit and withdrawal endpoints, also for the async client --- .../api/client/BinanceApiAsyncRestClient.java | 53 ++++++++++++++----- .../api/client/BinanceApiRestClient.java | 44 +++++++++++---- .../impl/BinanceApiAsyncRestClientImpl.java | 27 +++++++--- .../client/impl/BinanceApiRestClientImpl.java | 30 +++++++---- .../api/client/impl/BinanceApiService.java | 48 ++++++++++++++--- .../AccountEndpointsExampleAsync.java | 21 +++++--- .../AuthenticatedAsyncExampleBase.java | 22 ++++++++ 7 files changed, 190 insertions(+), 55 deletions(-) create mode 100644 src/test/java/com/binance/api/examples/AuthenticatedAsyncExampleBase.java diff --git a/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java b/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java index 4867cf07c..899f98612 100755 --- a/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java @@ -1,8 +1,8 @@ package com.binance.api.client; import com.binance.api.client.domain.account.Account; +import com.binance.api.client.domain.account.Deposit; import com.binance.api.client.domain.account.DepositAddress; -import com.binance.api.client.domain.account.DepositHistory; import com.binance.api.client.domain.account.ExtendedAssetBalance; import com.binance.api.client.domain.account.NewOrder; import com.binance.api.client.domain.account.NewOrderResponse; @@ -268,23 +268,50 @@ void getUserAssets(String asset, boolean needBtcValuation, /** * Submit a withdrawal request. - *

- * Enable Withdrawals option has to be active in the API settings. + * Withdrawals option has to be active in the API settings. * - * @param asset asset symbol to withdraw - * @param address address to withdraw to - * @param amount amount to withdraw - * @param name description/alias of the address - * @param addressTag Secondary address identifier for coins like XRP,XMR etc. - */ - void withdraw(String asset, String address, String amount, String name, String addressTag, BinanceApiCallback callback); + * @param coin asset symbol to withdraw + * @param withdrawOrderId client id for withdraw + * @param network the network to use for the withdrawal + * @param address address to withdraw to + * @param addressTag Secondary address identifier for coins like XRP,XMR etc. + * @param amount amount to withdraw + * @param transactionFeeFlag 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. + * @param name Description of the address. Space in name should be encoded into %20. + * @param callback the callback that handles the response with a list of trades + */ + void withdraw(String coin, String withdrawOrderId, String network, String address, + String addressTag, String amount, Boolean transactionFeeFlag, String name, + BinanceApiCallback callback); /** * Fetch account deposit history. * + * @param coin the asset to get the history for * @param callback the callback that handles the response and returns the deposit history */ - void getDepositHistory(String asset, BinanceApiCallback callback); + void getDepositHistory(String coin, BinanceApiCallback> callback); + + + /** + * Fetch account deposit history. + * + * @param coin the asset to get the history for + * @param status Status, with the following values: + * - 0: pending + * - 6: credited but cannot withdraw + * - 1: success + * @param startTime Start timestamp, including milliseconds. Default: 90 days before current + * timestamp + * @param endTime End timestamp, including milliseconds. Default: present timestamp + * @param offset Default:0 + * @param limit Default:1000, Max:1000 + * @param callback the callback that handles the response and returns the deposit history + */ + void getDepositHistory(String coin, Integer status, Long startTime, Long endTime, + Integer offset, Integer limit, BinanceApiCallback> callback); /** * Fetch account withdraw history. @@ -327,9 +354,11 @@ void getWithdrawHistory(String coin, /** * Fetch deposit address. * + * @param asset The asset for which to check the deposit address + * @param network The network to use for deposit * @param callback the callback that handles the response and returns the deposit address */ - void getDepositAddress(String asset, BinanceApiCallback callback); + void getDepositAddress(String asset, String network, BinanceApiCallback callback); // User stream endpoints diff --git a/src/main/java/com/binance/api/client/BinanceApiRestClient.java b/src/main/java/com/binance/api/client/BinanceApiRestClient.java index b99e71ae0..ba0529a98 100755 --- a/src/main/java/com/binance/api/client/BinanceApiRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiRestClient.java @@ -248,16 +248,19 @@ public interface BinanceApiRestClient { /** * Submit a withdrawal request. - *

- * Enable Withdrawals option has to be active in the API settings. + * Withdrawals option has to be active in the API settings. * - * @param asset asset symbol to withdraw - * @param address address to withdraw to - * @param amount amount to withdraw - * @param name description/alias of the address - * @param addressTag Secondary address identifier for coins like XRP,XMR etc. + * @param coin asset symbol to withdraw + * @param withdrawOrderId client id for withdraw + * @param network the network to use for the withdrawal + * @param address address to withdraw to + * @param addressTag Secondary address identifier for coins like XRP,XMR etc. + * @param amount amount to withdraw + * @param transactionFeeFlag 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. + * @param name Description of the address. Space in name should be encoded into %20. */ - WithdrawResult withdraw(String asset, String address, String amount, String name, String addressTag); + WithdrawResult withdraw(String coin, String withdrawOrderId, String network, String address, String amount, + String name, String addressTag, Boolean transactionFeeFlag); /** * Conver a list of assets to BNB @@ -271,7 +274,24 @@ public interface BinanceApiRestClient { * * @return deposit history, containing a list of deposits */ - DepositHistory getDepositHistory(String asset); + List getDepositHistory(String asset); + + /** + * Fetch account deposit history. + * + * @param coin the asset to get the history for + * @param status When specified, filter by transaction status: + * - 0: pending + * - 6: credited but cannot withdraw + * - 1: success) + * @param startTime Default: 90 days from current timestamp + * @param endTime Default: present timestamp + * @param offset Default:0 + * @param limit Default:1000, Max:1000 + * @return deposit history, containing a list of deposits + */ + List getDepositHistory(String coin, Integer status, Long startTime, Long endTime, + Integer offset, Integer limit); /** * Fetch account withdraw history. @@ -299,7 +319,7 @@ public interface BinanceApiRestClient { * @return withdraw history, containing a list of withdrawals */ List getWithdrawHistory(String coin, String withdrawOrderId, Integer status, - Integer offset, Integer limit, Long startTime, Long endTime); + Integer offset, Integer limit, Long startTime, Long endTime); /** * Fetch account withdraw history, with default values. @@ -313,9 +333,11 @@ List getWithdrawHistory(String coin, String withdrawOrderId, Integer s /** * Fetch deposit address. * + * @param coin The coin to get the address for + * @param network The network to use for deposit * @return deposit address for a given asset. */ - DepositAddress getDepositAddress(String asset); + DepositAddress getDepositAddress(String coin, String network); /** * Get User account information. diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java index ac74396ad..48e982e2d 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java @@ -5,8 +5,8 @@ import com.binance.api.client.config.BinanceApiConfig; import com.binance.api.client.constant.BinanceApiConstants; import com.binance.api.client.domain.account.Account; +import com.binance.api.client.domain.account.Deposit; import com.binance.api.client.domain.account.DepositAddress; -import com.binance.api.client.domain.account.DepositHistory; import com.binance.api.client.domain.account.ExtendedAssetBalance; import com.binance.api.client.domain.account.NewOrder; import com.binance.api.client.domain.account.NewOrderResponse; @@ -224,17 +224,27 @@ public void getMyTrades(String symbol, BinanceApiCallback> callback) } @Override - public void withdraw(String asset, String address, String amount, String name, String addressTag, BinanceApiCallback callback) { - binanceApiService.withdraw(asset, address, amount, name, addressTag, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()) + public void withdraw(String coin, String withdrawOrderId, String network, String address, String addressTag, + String amount, Boolean transactionFeeFlag, String name, BinanceApiCallback callback) { + binanceApiService.withdraw(coin, withdrawOrderId, network, address, addressTag, amount, transactionFeeFlag, name, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()) .enqueue(new BinanceApiCallbackAdapter<>(callback)); } @Override - public void getDepositHistory(String asset, BinanceApiCallback callback) { - binanceApiService.getDepositHistory(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()) + public void getDepositHistory(String coin, Integer status, Long startTime, Long endTime, + Integer offset, Integer limit, + BinanceApiCallback> callback) { + binanceApiService.getDepositHistory(coin, status, startTime, endTime, offset, limit, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()) .enqueue(new BinanceApiCallbackAdapter<>(callback)); } + @Override + public void getDepositHistory(String coin, BinanceApiCallback> callback) { + getDepositHistory(coin, null, null, null, null, null, callback); + } + @Override public void getWithdrawHistory(String coin, String withdrawOrderId, Integer status, Integer offset, Integer limit, Long startTime, Long endTime, @@ -251,11 +261,14 @@ public void getWithdrawHistory(String coin, BinanceApiCallback> c } @Override - public void getDepositAddress(String asset, BinanceApiCallback callback) { - binanceApiService.getDepositAddress(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()) + public void getDepositAddress(String asset, String network, + BinanceApiCallback callback) { + binanceApiService.getDepositAddress(asset, network, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()) .enqueue(new BinanceApiCallbackAdapter<>(callback)); } + // User stream endpoints @Override diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java index 32af03dcf..a66e1d355 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java @@ -215,8 +215,11 @@ public List getMyTrades(String symbol, Long fromId) { } @Override - public WithdrawResult withdraw(String asset, String address, String amount, String name, String addressTag) { - return executeSync(binanceApiService.withdraw(asset, address, amount, name, addressTag, + public WithdrawResult withdraw(String coin, String withdrawOrderId, String network, + String address, String amount, String name, String addressTag, + Boolean transactionFeeFlag) { + return executeSync(binanceApiService.withdraw(coin, withdrawOrderId, network, address, + addressTag, amount, transactionFeeFlag, name, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); } @@ -226,15 +229,22 @@ public DustTransferResponse dustTransfer(List asset) { } @Override - public DepositHistory getDepositHistory(String asset) { - return executeSync(binanceApiService.getDepositHistory(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - System.currentTimeMillis())); + public List getDepositHistory(String coin) { + return getDepositHistory(coin, null, null, null, null, null); + } + + @Override + public List getDepositHistory(String coin, Integer status, Long startTime, Long endTime, + Integer offset, Integer limit) { + return executeSync(binanceApiService.getDepositHistory(coin, status, startTime, endTime, + offset, limit, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); } @Override public List getWithdrawHistory(String coin, String withdrawOrderId, Integer status, - Integer offset, Integer limit, - Long startTime, Long endTime) { + Integer offset, Integer limit, + Long startTime, Long endTime) { return executeSync(binanceApiService.getWithdrawHistory(coin, withdrawOrderId, status, offset, limit, startTime, endTime, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); @@ -246,9 +256,9 @@ public List getWithdrawHistory(String coin) { } @Override - public DepositAddress getDepositAddress(String asset) { - return executeSync(binanceApiService.getDepositAddress(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - System.currentTimeMillis())); + public DepositAddress getDepositAddress(String coin, String network) { + return executeSync(binanceApiService.getDepositAddress(coin, network, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); } @Override diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiService.java b/src/main/java/com/binance/api/client/impl/BinanceApiService.java index 02bf681ae..894555d72 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiService.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiService.java @@ -143,14 +143,47 @@ Call> getMyTrades(@Query("symbol") String symbol, @Query("limit") In @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @POST("/wapi/v3/withdraw.html") - Call withdraw(@Query("asset") String asset, @Query("address") String address, @Query("amount") String amount, @Query("name") String name, @Query("addressTag") String addressTag, - @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + @POST("/sapi/v1/capital/withdraw/apply") + Call withdraw( + @Query("coin") String coin, + @Query("withdrawOrderId") String withdrawOrderId, + @Query("network") String network, + @Query("address") String address, + @Query("addressTag") String addressTag, + @Query("amount") String amount, + @Query("transactionFeeFlag") Boolean feeFlag, + @Query("name") String name, + @Query("recvWindow") Long recvWindow, + @Query("timestamp") Long timestamp + ); + /** + * Deposit history. + * + * @param coin The coin to look the history for. + * @param status When specified, filter by transaction status: + * - 0:Email Sent + * - 1:Cancelled + * - 2:Awaiting Approval + * - 3:Rejected + * - 4:Processing + * - 5:Failure + * - 6:Completed + * @param startTime Default: 90 days from current timestamp + * @param endTime Default: present timestamp + * @param offset + * @param limit Default: 1000, Max: 1000 + * @param recvWindow + * @param timestamp + * @return + */ @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/wapi/v3/depositHistory.html") - Call getDepositHistory(@Query("asset") String asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + @GET("/sapi/v1/capital/deposit/hisrec") + Call> getDepositHistory(@Query("coin") String coin, @Query("status") Integer status, + @Query("startTime") Long startTime, @Query("endTime") Long endTime, + @Query("offset") Integer offset, @Query("limit") Integer limit, + @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); /** * Withdraw History. @@ -193,8 +226,9 @@ Call> getWithdrawHistory( @Query("timestamp") Long timestamp); @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/wapi/v3/depositAddress.html") - Call getDepositAddress(@Query("asset") String asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + @GET("/sapi/v1/capital/deposit/address") + Call getDepositAddress(@Query("coin") String asset, @Query("network") + String network, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) @POST("/sapi/v1/asset/dust") diff --git a/src/test/java/com/binance/api/examples/AccountEndpointsExampleAsync.java b/src/test/java/com/binance/api/examples/AccountEndpointsExampleAsync.java index 5ede0526b..c8ab313f7 100755 --- a/src/test/java/com/binance/api/examples/AccountEndpointsExampleAsync.java +++ b/src/test/java/com/binance/api/examples/AccountEndpointsExampleAsync.java @@ -7,25 +7,30 @@ /** * Examples on how to get account information. */ -public class AccountEndpointsExampleAsync { +public class AccountEndpointsExampleAsync extends AuthenticatedAsyncExampleBase { public static void main(String[] args) { - BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_SECRET"); - BinanceApiAsyncRestClient client = factory.newAsyncRestClient(); + AccountEndpointsExampleAsync example = new AccountEndpointsExampleAsync(); + example.run(); + } + private void run() { // Get account balances (async) - client.getAccount((Account response) -> System.out.println(response.getAssetBalance("ETH"))); + client.getAccount((Account response) -> System.out.println( + "ETH balance: " + response.getAssetBalance("ETH").getTotalAmount()) + ); // Get list of trades (async) - client.getMyTrades("NEOETH", response -> System.out.println(response)); + client.getMyTrades("NEOETH", response -> System.out.println("Trades: " + response)); // Get withdraw history (async) - client.getWithdrawHistory("ETH", response -> System.out.println(response)); + client.getWithdrawHistory("ETH", response -> System.out.println( + "Withdrawal history: " + response)); // Get deposit history (async) - client.getDepositHistory("ETH", response -> System.out.println(response)); + client.getDepositHistory("ETH", response -> System.out.println("Deposit history: " + response)); // Withdraw (async) - client.withdraw("ETH", "0x123", "0.1", null, null, response -> {}); + // client.withdraw("ETH", "0x123", "0.1", null, null, null, null, null, response -> {}); } } diff --git a/src/test/java/com/binance/api/examples/AuthenticatedAsyncExampleBase.java b/src/test/java/com/binance/api/examples/AuthenticatedAsyncExampleBase.java new file mode 100644 index 000000000..9fe9dfd2e --- /dev/null +++ b/src/test/java/com/binance/api/examples/AuthenticatedAsyncExampleBase.java @@ -0,0 +1,22 @@ +package com.binance.api.examples; + +import com.binance.api.client.BinanceApiAsyncRestClient; +import com.binance.api.client.BinanceApiClientFactory; +import com.binance.api.client.security.ApiCredentials; + +/** + * An abstract base class which creates the necessary tools for an example requiring + * authenticated endpoints, using asynchronous client + */ +public abstract class AuthenticatedAsyncExampleBase { + protected final BinanceApiAsyncRestClient client; + + /** + * Create an example, get API key and secret from the environment variables. + */ + public AuthenticatedAsyncExampleBase() { + ApiCredentials credentials = ApiCredentials.creatFromEnvironment(); + BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(credentials); + client = factory.newAsyncRestClient(); + } +} From 997ea8534c518f97aeedb3833da887b6a871a39a Mon Sep 17 00:00:00 2001 From: Girts Strazdins Date: Thu, 29 Dec 2022 15:08:23 +0100 Subject: [PATCH 14/14] DepositHistory is not used anymore --- .../client/domain/account/DepositHistory.java | 57 ------------------- 1 file changed, 57 deletions(-) delete mode 100755 src/main/java/com/binance/api/client/domain/account/DepositHistory.java diff --git a/src/main/java/com/binance/api/client/domain/account/DepositHistory.java b/src/main/java/com/binance/api/client/domain/account/DepositHistory.java deleted file mode 100755 index fc8d814e8..000000000 --- a/src/main/java/com/binance/api/client/domain/account/DepositHistory.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.binance.api.client.domain.account; - -import com.binance.api.client.constant.BinanceApiConstants; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.commons.lang3.builder.ToStringBuilder; - -import java.util.List; - -/** - * History of account deposits. - * - * @see Deposit - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class DepositHistory { - - @JsonProperty("depositList") - private List depositList; - - private boolean success; - - private String msg; - - public String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } - - public List getDepositList() { - return depositList; - } - - public void setDepositList(List depositList) { - this.depositList = depositList; - } - - public boolean isSuccess() { - return success; - } - - public void setSuccess(boolean success) { - this.success = success; - } - - @Override - public String toString() { - return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE) - .append("depositList", depositList) - .append("success", success) - .append("msg", msg) - .toString(); - } -}