Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force source encoding to UTF-8 #25

Open
wants to merge 126 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
880955a
Ignore unknown properties for Orders.
joaopsilva Dec 6, 2017
af6ab53
Fixed #2 - Update account domain object to take into account newly ad…
joaopsilva Dec 12, 2017
432a77d
Create LICENSE
joaopsilva Dec 16, 2017
824b2e4
Resolves #5 - Support /exchangeInfo endpoint
joaopsilva Dec 23, 2017
adb7699
Merge branch 'master' of github.com:binance-exchange/binance-java-api
joaopsilva Dec 23, 2017
4e87d0c
Update HmacSHA256Signer.java
VaultDeveloper Jan 2, 2018
6b9c775
Update HmacSHA256Signer.java
VaultDeveloper Jan 2, 2018
b9a8afa
Merge pull request #19 from VaultDeveloper/patch-1
joaopsilva Jan 2, 2018
f0f4380
Fix java compile warnings
xezon Jan 6, 2018
59609e0
Ignore any user project files (generally starting with dot)
xezon Jan 6, 2018
4b70eea
Merge pull request #21 from xezon/warnings
joaopsilva Jan 7, 2018
f9d65c0
Merge pull request #22 from xezon/gitignore
joaopsilva Jan 7, 2018
076dc91
Add Json Serializers for CandlestickEvent and OrderBookEntry
xezon Jan 10, 2018
dc1c4f1
Fix missing Fill or Kill in TimeInForce
amirulzin Jan 11, 2018
5f66558
Merge pull request #28 from amirulzin/patch-add-timeinforce
joaopsilva Jan 11, 2018
74289e4
Merge pull request #26 from xezon/event_serialization
joaopsilva Jan 11, 2018
a07a578
Fix ObjectMapper not being cached per response call
amirulzin Jan 13, 2018
a718416
Create ObjectMapper lazily on UserDataUpdateEvent deserialization
amirulzin Jan 13, 2018
4d76c23
Merge pull request #30 from amirulzin/fix-objectmapper
joaopsilva Jan 13, 2018
c25eb80
Expose the 'U' (first update), as well as the 'u' (final update)
Jan 22, 2018
299411f
- added javadocs
Jan 23, 2018
382a679
Merge pull request #41 from datalorax/expose_first_update
joaopsilva Jan 23, 2018
18e3b0a
Improvements to error handling and the ability to shutdown the client…
Jan 25, 2018
f2b5a83
Allow up to 100 connections to binance.
mcourteaux Jan 26, 2018
c1c7f96
Merge pull request #53 from mcourteaux/more-connections
joaopsilva Jan 27, 2018
4a47ca1
Added AllMarketTickers channel
tonyskulk Jan 27, 2018
9130566
Swicthed to use ToStringBuilder
tonyskulk Jan 27, 2018
92ae20a
Add all market tickers example.
tonyskulk Jan 27, 2018
5995165
Added ability to query 24hr ticker price change statistics for all sy…
nomailforme Jan 28, 2018
e3df9d7
Merge pull request #56 from tonyskulk/all-market-tickers
joaopsilva Jan 29, 2018
1564ffe
Fixes #59 Typo in CandlestickInterval enum.
joaopsilva Jan 29, 2018
c3cd9e1
Merge branch 'master' into error_handling_and_shutdown
big-andy-coates Jan 29, 2018
e95b670
NewOrder.newClientOrderId() is now passed through to binance when pla…
Feb 2, 2018
89d4c79
Merge pull request #63 from wiigor/master
joaopsilva Feb 2, 2018
8080c1f
Added symbol name to TickerStatistics
nomailforme Feb 3, 2018
a10dc0c
-Removed unused imports
Feb 4, 2018
8664140
Add error handling and closure of websockets to readme
Feb 5, 2018
37ef9a0
code review improvements
Feb 5, 2018
d088fe0
Pull request changes
nomailforme Feb 5, 2018
31fd444
Merge pull request #60 from nomailforme/master
joaopsilva Feb 6, 2018
8f41f61
issues-52 Fix - Added feature to override the ToStringStyle used by t…
gizmochief7 Feb 7, 2018
769d8ff
issues-52 Fix - Added feature to override the ToStringStyle used by t…
gizmochief7 Feb 7, 2018
25114c5
fixe issue #54
Feb 8, 2018
d3ef4f3
- add test
Feb 8, 2018
71556ef
Merge pull request #66 from datalorax/auth_intercept
joaopsilva Feb 8, 2018
57f67de
Merge origin/master
gizmochief7 Feb 8, 2018
577f678
issues-52 removed GSON dependancy. Removed prettyPrintJson util metho…
gizmochief7 Feb 8, 2018
ee97f99
Merge branch 'master' of https://github.com/gizmochief7/binance-java-api
gizmochief7 Feb 21, 2018
f7909b3
Merge pull request #65 from gizmochief7/master
joaopsilva Feb 21, 2018
8619c19
/api/v1/trades and /api/v1/historicalTrades calls support
hoota Feb 23, 2018
ce283c9
/api/v1/trades and /api/v1/historicalTrades calls support import styl…
hoota Feb 23, 2018
b610284
/api/v1/trades and /api/v1/historicalTrades calls support import styl…
hoota Feb 23, 2018
da76f01
/api/v1/trades and /api/v1/historicalTrades calls support import styl…
hoota Feb 23, 2018
e7d53bf
/api/v1/trades and /api/v1/historicalTrades calls support import styl…
hoota Feb 23, 2018
f7f022d
ENDPOINT_SECURITY_TYPE_APIKEY_HEADER for historicalTrades
hoota Feb 23, 2018
c64cee1
Merge pull request #49 from big-andy-coates/error_handling_and_shutdown
joaopsilva Feb 23, 2018
c74e807
/api/v1/trades and /api/v1/historicalTrades async calls support
hoota Feb 23, 2018
8046f75
Merge pull request #80 from hoota/trades_api_call
joaopsilva Feb 23, 2018
6d86212
Fix the initialization of the depth cache. Old code had a race condit…
big-andy-coates Feb 24, 2018
5029b19
Better docs / comments
big-andy-coates Feb 24, 2018
8ae3b0a
Merge pull request #82 from big-andy-coates/fix_depth_cache_init
joaopsilva Feb 25, 2018
0c9354f
Add reconnect & close logic
big-andy-coates Feb 25, 2018
6f53a88
Merge pull request #83 from big-andy-coates/reconnect
joaopsilva Feb 26, 2018
8571a99
Add support for AllAssets
TobCar Mar 14, 2018
91dd28f
Expose getAllAssets JSON call
TobCar Mar 25, 2018
00cb268
Merge pull request #98 from TobCar/master
joaopsilva Mar 25, 2018
69f56f5
Fixes #103: Add support for fetching all assets.
joaopsilva Mar 26, 2018
97a08b0
Route exceptions via onFailure callback rather than throwing them
nilswx Apr 25, 2018
1c90686
Add support for newOrderRespType (v3 API)
nilswx Apr 29, 2018
7b92e7a
Demonstrate use of newOrderRespType in OrdersExample
nilswx Apr 29, 2018
ce38cb8
Parse both 'id' and 'tradeId' into Trade#id to deal with inconsistent…
nilswx Apr 29, 2018
d7835f5
Add NewOrderResponse#origQty
nilswx Apr 29, 2018
16e94f3
Demonstrate use of newOrderRespType in README.md
nilswx Apr 29, 2018
6067b08
withdrawal status added, conflicts resolved
May 4, 2018
db200f2
Merge pull request #126 from igorustinov/master
joaopsilva May 4, 2018
bf55921
Fix #125: Avoid 301 redirect for asset info API.
joaopsilva May 4, 2018
eb1ff5c
Merge pull request #122 from nilswxa/master
joaopsilva May 4, 2018
ff7db64
Fix #127 Remove meta header.
joaopsilva May 6, 2018
a00fa6e
Merge branch 'master' of github.com:binance-exchange/binance-java-api
joaopsilva May 6, 2018
aebcf15
Cleanup the client/interceptor and errorBody converter mess in Binanc…
nilswx May 15, 2018
bed23c0
Improve web socket creation: use the process-wide shared HTTP client …
nilswx May 15, 2018
95ab6bf
Upgrade Retrofit, which upgrades OkHttp, which now properly honors pi…
nilswx May 15, 2018
a10a0e9
Cannot deserialize value of type `com.binance.api.client.domain.gener…
Jul 19, 2018
25e008e
Merge pull request #156 from jinxxik/master
joaopsilva Jul 19, 2018
84adddb
Add support for ICEBERG_PARTS and MAX_NUM_ALGO_ORDERS filter.
joaopsilva Jul 19, 2018
9dd2477
ignore properties add for avoiding new fields deserialization exception
gungoren Jul 20, 2018
fcee5de
Merge branch 'master' of https://github.com/binance-exchange/binance-…
gungoren Jul 20, 2018
137cfd4
Issue 157: Exception when getting all trades of a symbol
Jul 20, 2018
59bf8ff
Merge pull request #159 from pahgo/master
joaopsilva Jul 20, 2018
505a4a0
Merge pull request #158 from evhar002/master
joaopsilva Jul 20, 2018
bb8a3b6
binance api change 2018-07-18: added param cummulativeQuoteQty to the…
brintal Jul 20, 2018
6b4de68
binance api change 2018-07-18: updated javadoc to reflect the new lim…
brintal Jul 20, 2018
29f603e
Merge pull request #160 from brintal/master
joaopsilva Jul 20, 2018
dff4c70
Merge latest remote changes into this fork to maintain API compatility
nilswx Jul 23, 2018
9a6cd16
fixed market ticker event
Jul 23, 2018
abe4e31
Fix for ORDER_WOULD_TRIGGER_IMMEDIATELY
Aug 20, 2018
fd76377
Merge pull request #170 from Moskitek/master
joaopsilva Aug 23, 2018
f0cf925
multi-channel subscription on single websocket
mironbalcerzak Aug 26, 2018
429c704
Preventing NPE while boxing/unboxing
mironbalcerzak Sep 2, 2018
8055ac1
Preventing NPE while boxing/unboxing - JUnit fix
mironbalcerzak Sep 2, 2018
4363070
Add support for cancel order response.
joaopsilva Sep 12, 2018
8f2bff1
Merge pull request #133 from nilswxa/master
joaopsilva Sep 13, 2018
15489f0
Merge branch 'master' into master
joaopsilva Sep 13, 2018
e31ad64
Merge pull request #163 from Krasks/master
joaopsilva Sep 13, 2018
2da9453
Make fills toString null-safe.
joaopsilva Sep 13, 2018
e7995c0
Add unit tests for NewOrderResponse.
joaopsilva Sep 13, 2018
7a1fc4f
Merge pull request #178 from mironbalcerzak/master
joaopsilva Sep 13, 2018
d39139a
configure custom dispatcher for sharedClient to allow for more parall…
brintal Nov 14, 2018
d74588f
Merge pull request #190 from brintal/master
joaopsilva Dec 3, 2018
d6801c2
adds new filter type values
igorustinov Dec 4, 2018
0a5624b
Merge pull request #194 from igorustinov/pr_new_filtertypes
joaopsilva Dec 4, 2018
7c2a4f4
Add bid price and quantity to AllMarketTickersEvent
Gtofig Jan 12, 2019
1d0eef8
Merge pull request #198 from Gtofig/AllMarketTickersEventBidPricePatch
joaopsilva Jan 14, 2019
dd121ac
Cache ObjectMapper.
joaopsilva Mar 10, 2019
96bbbd1
Use ObjectReader instance for processing JSON.
joaopsilva Mar 10, 2019
5c4451c
add status and executedQty to CancelOrderResponse
mdvx Mar 31, 2019
0d47038
Merge branch 'master' of github.com:binance-exchange/binance-java-api
mdvx Mar 31, 2019
e038355
Merge pull request #207 from mdvx/master
joaopsilva May 21, 2019
22df744
Add license to POM for license-maven-plugin compatibility
benalexau Jun 14, 2019
54bc694
Add Cummulative Quote Quantity
putraxor Aug 12, 2019
25a23ce
Fixed parsing of UserDataUpdateEvents with regard to the new 'outboun…
mcourteaux Aug 16, 2019
9aabc01
Merge pull request #224 from mcourteaux/fix-outboundAccountPosition
joaopsilva Aug 17, 2019
a15902a
Adjusted recvWindow to 60000.
joaopsilva Aug 17, 2019
84752f1
Merge pull request #220 from putraxor/patch-1
joaopsilva Aug 17, 2019
9e6cfca
Merge pull request #213 from benalexau/master
joaopsilva Aug 17, 2019
93a55cd
force source encoding to UTF-8
mlaubre Aug 19, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,8 @@ hs_err_pid*
# Maven
target/
# End of https://www.gitignore.io/api/java,intellij

# Ignore files and folders starting with dot (except gitignore)
.*
!/.gitignore
/nbproject/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Binance

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
71 changes: 70 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ System.out.println(order.getExecutedQty());

#### Placing a MARKET order
```java
NewOrderResponse newOrderResponse = client.newOrder(marketBuy("LINKETH", "1000"));
NewOrderResponse newOrderResponse = client.newOrder(marketBuy("LINKETH", "1000").orderRespType(OrderResponseType.FULL));
List<Trade> fills = newOrderResponse.getFills();
System.out.println(newOrderResponse.getClientOrderId());
```
<details>
Expand Down Expand Up @@ -279,6 +280,43 @@ client.closeUserDataStream(listenKey);
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<AggTradeEvent>() {
@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) -> {
Expand Down Expand Up @@ -396,6 +434,37 @@ client.onUserDataUpdateEvent(listenKey, response -> {
});
```

#### 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.
Expand Down
10 changes: 9 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@
<groupId>com.binance.api</groupId>
<artifactId>binance-api-client</artifactId>
<version>1.0.0</version>
<licenses>
<license>
<name>The MIT License</name>
<url>https://opensource.org/licenses/MIT</url>
</license>
</licenses>

<properties>
<com.squareup.retrofit2.version>2.3.0</com.squareup.retrofit2.version>
<com.squareup.retrofit2.version>2.4.0</com.squareup.retrofit2.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
Expand Down Expand Up @@ -49,6 +56,7 @@
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
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.WithdrawResult;
import com.binance.api.client.domain.account.request.AllOrdersRequest;
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 com.binance.api.client.domain.general.Asset;
import com.binance.api.client.domain.general.ExchangeInfo;
import com.binance.api.client.domain.general.ServerTime;
import com.binance.api.client.domain.market.AggTrade;
import com.binance.api.client.domain.market.BookTicker;
Expand Down Expand Up @@ -41,6 +46,16 @@ public interface BinanceApiAsyncRestClient {
*/
void getServerTime(BinanceApiCallback<ServerTime> callback);

/**
* Current exchange trading rules and symbol information
*/
void getExchangeInfo(BinanceApiCallback<ExchangeInfo> callback);

/**
* ALL supported assets and whether or not they can be withdrawn.
*/
void getAllAssets(BinanceApiCallback<List<Asset>> callback);

// Market Data endpoints

/**
Expand All @@ -52,6 +67,25 @@ public interface BinanceApiAsyncRestClient {
*/
void getOrderBook(String symbol, Integer limit, BinanceApiCallback<OrderBook> callback);

/**
* 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 callback the callback that handles the response
*/
void getTrades(String symbol, Integer limit, BinanceApiCallback<List<TradeHistoryItem>> callback);

/**
* 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 callback the callback that handles the response
*/
void getHistoricalTrades(String symbol, Integer limit, Long fromId, BinanceApiCallback<List<TradeHistoryItem>> callback);

/**
* Get compressed, aggregate trades. Trades that fill at the time, from the same order, with
* the same price will have the quantity aggregated.
Expand All @@ -61,7 +95,7 @@ public interface BinanceApiAsyncRestClient {
*
* @param symbol symbol to aggregate (mandatory)
* @param fromId ID to get aggregate trades from INCLUSIVE (optional)
* @param limit Default 500; max 500 (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
Expand All @@ -81,7 +115,7 @@ public interface BinanceApiAsyncRestClient {
*
* @param symbol symbol to aggregate (mandatory)
* @param interval candlestick interval (mandatory)
* @param limit Default 500; max 500 (optional)
* @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
Expand All @@ -102,13 +136,28 @@ public interface BinanceApiAsyncRestClient {
* @param callback the callback that handles the response
*/
void get24HrPriceStatistics(String symbol, BinanceApiCallback<TickerStatistics> callback);

/**
* Get 24 hour price change statistics for all symbols (asynchronous).
*
* @param callback the callback that handles the response
*/
void getAll24HrPriceStatistics(BinanceApiCallback<List<TickerStatistics>> callback);

/**
* Get Latest price for all symbols (asynchronous).
*
* @param callback the callback that handles the response
*/
void getAllPrices(BinanceApiCallback<List<TickerPrice>> callback);

/**
* Get latest price for <code>symbol</code> (asynchronous).
*
* @param symbol ticker symbol (e.g. ETHBTC)
* @param callback the callback that handles the response
*/
void getPrice(String symbol , BinanceApiCallback<TickerPrice> callback);

/**
* Get best price/qty on the order book for all symbols (asynchronous).
Expand Down Expand Up @@ -149,7 +198,7 @@ public interface BinanceApiAsyncRestClient {
* @param cancelOrderRequest order status request parameters
* @param callback the callback that handles the response
*/
void cancelOrder(CancelOrderRequest cancelOrderRequest, BinanceApiCallback<Void> callback);
void cancelOrder(CancelOrderRequest cancelOrderRequest, BinanceApiCallback<CancelOrderResponse> callback);

/**
* Get all open orders on a symbol (asynchronous).
Expand Down Expand Up @@ -181,7 +230,7 @@ public interface BinanceApiAsyncRestClient {
* Get trades for a specific account and symbol.
*
* @param symbol symbol to get trades from
* @param limit default 500; max 500
* @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
*/
Expand All @@ -191,7 +240,7 @@ public interface BinanceApiAsyncRestClient {
* Get trades for a specific account and symbol.
*
* @param symbol symbol to get trades from
* @param limit default 500; max 500
* @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<List<Trade>> callback);
Expand All @@ -213,8 +262,9 @@ public interface BinanceApiAsyncRestClient {
* @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, BinanceApiCallback<Void> callback);
void withdraw(String asset, String address, String amount, String name, String addressTag, BinanceApiCallback<WithdrawResult> callback);

/**
* Fetch account deposit history.
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/com/binance/api/client/BinanceApiCallback.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
package com.binance.api.client;

import com.binance.api.client.exception.BinanceApiException;

/**
* BinanceApiCallback is a functional interface used together with the BinanceApiAsyncClient to provide a non-blocking REST client.
*
* @param <T> the return type from the callback
*/
@FunctionalInterface
public interface BinanceApiCallback<T> {

/**
* Called whenever a response comes back from the Binance API.
*
* @param response the expected response object
* @throws BinanceApiException if it is not possible to obtain the expected response object (e.g. incorrect API-KEY).
*/
void onResponse(T response) throws BinanceApiException;
void onResponse(T response);

/**
* Called whenever an error occurs.
*
* @param cause the cause of the failure
*/
default void onFailure(Throwable cause) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.binance.api.client.impl.BinanceApiRestClientImpl;
import com.binance.api.client.impl.BinanceApiWebSocketClientImpl;

import static com.binance.api.client.impl.BinanceApiServiceGenerator.getSharedClient;

/**
* A factory for creating BinanceApi client objects.
*/
Expand Down Expand Up @@ -68,6 +70,6 @@ public BinanceApiRestClient newRestClient() {
* Creates a new web socket client used for handling data streams.
*/
public BinanceApiWebSocketClient newWebSocketClient() {
return new BinanceApiWebSocketClientImpl();
return new BinanceApiWebSocketClientImpl(getSharedClient());
}
}
4 changes: 2 additions & 2 deletions src/main/java/com/binance/api/client/BinanceApiError.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.binance.api.client;

import com.binance.api.client.constant.BinanceApiConstants;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
* Binance API error object.
Expand Down Expand Up @@ -36,7 +36,7 @@ public void setMsg(String msg) {

@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE)
.append("code", code)
.append("msg", msg)
.toString();
Expand Down
Loading