diff --git a/pom.xml b/pom.xml
index 67e7af532..e6b62a87e 100755
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.binance.api
binance-api-client
- 1.0.1
+ 1.0.1-el
The MIT License
@@ -53,8 +53,8 @@
org.apache.maven.plugins
maven-compiler-plugin
- 1.8
- 1.8
+ 14
+ 14
diff --git a/src/main/java/com/binance/api/client/BinanceApiAsyncExecutorRestClient.java b/src/main/java/com/binance/api/client/BinanceApiAsyncExecutorRestClient.java
new file mode 100755
index 000000000..ca35f2c51
--- /dev/null
+++ b/src/main/java/com/binance/api/client/BinanceApiAsyncExecutorRestClient.java
@@ -0,0 +1,308 @@
+package com.binance.api.client;
+
+import com.binance.api.client.domain.account.*;
+import com.binance.api.client.domain.account.request.*;
+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.*;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Binance API facade, supporting asynchronous/non-blocking access Binance's REST API using ExecutorServices to
+ * handling the request and response threading.
+ */
+public interface BinanceApiAsyncExecutorRestClient {
+
+ // General endpoints
+
+ /**
+ * Test connectivity to the Rest API.
+ * @return
+ */
+ CompletableFuture ping(BinanceApiCallback callback);
+
+ /**
+ * Check server time.
+ * @return
+ */
+ CompletableFuture getServerTime(BinanceApiCallback callback);
+
+ /**
+ * Current exchange trading rules and symbol information
+ *
+ * @return
+ */
+ CompletableFuture getExchangeInfo(BinanceApiCallback callback);
+
+ /**
+ * ALL supported assets and whether or not they can be withdrawn.
+ *
+ * @return
+ */
+ CompletableFuture> getAllAssets(BinanceApiCallback> callback);
+
+ // Market Data endpoints
+
+ /**
+ * Get order book of a symbol (asynchronous)
+ *
+ * @param symbol ticker symbol (e.g. ETHBTC)
+ * @param limit depth of the order book (max 100)
+ * @param callback the callback that handles the response
+ *
+ * @return
+ */
+ CompletableFuture getOrderBook(String symbol, Integer limit, BinanceApiCallback 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
+ *
+ * @return
+ */
+ CompletableFuture> getTrades(String symbol, Integer limit, BinanceApiCallback> 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
+ *
+ * @return
+ */
+ CompletableFuture> getHistoricalTrades(String symbol, Integer limit, Long fromId, BinanceApiCallback> callback);
+
+ /**
+ * 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 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
+ * @return a list of aggregate trades for the given symbol
+ */
+ CompletableFuture> getAggTrades(String symbol, String fromId, Integer limit, Long startTime, Long endTime, BinanceApiCallback> callback);
+
+ /**
+ * Return the most recent aggregate trades for symbol
+ *
+ * @see #getAggTrades(String, String, Integer, Long, Long, BinanceApiCallback)
+ */
+ CompletableFuture> getAggTrades(String symbol, BinanceApiCallback> callback);
+
+ /**
+ * 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 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
+ */
+ CompletableFuture> getCandlestickBars(String symbol, CandlestickInterval interval, Integer limit, Long startTime, Long endTime, BinanceApiCallback> callback);
+
+ /**
+ * Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.
+ *
+ * @see #getCandlestickBars(String, CandlestickInterval, BinanceApiCallback)
+ */
+ CompletableFuture> getCandlestickBars(String symbol, CandlestickInterval interval, BinanceApiCallback> callback);
+
+ /**
+ * Get 24 hour price change statistics (asynchronous).
+ *
+ * @param symbol ticker symbol (e.g. ETHBTC)
+ * @param callback the callback that handles the response
+ */
+ CompletableFuture get24HrPriceStatistics(String symbol, BinanceApiCallback callback);
+
+ /**
+ * Get 24 hour price change statistics for all symbols (asynchronous).
+ *
+ * @param callback the callback that handles the response
+ */
+ CompletableFuture> getAll24HrPriceStatistics(BinanceApiCallback> callback);
+
+ /**
+ * Get Latest price for all symbols (asynchronous).
+ *
+ * @param callback the callback that handles the response
+ */
+ CompletableFuture> getAllPrices(BinanceApiCallback> callback);
+
+ /**
+ * Get latest price for symbol (asynchronous).
+ *
+ * @param symbol ticker symbol (e.g. ETHBTC)
+ * @param callback the callback that handles the response
+ */
+ CompletableFuture getPrice(String symbol , BinanceApiCallback callback);
+
+ /**
+ * Get best price/qty on the order book for all symbols (asynchronous).
+ *
+ * @param callback the callback that handles the response
+ */
+ CompletableFuture> getBookTickers(BinanceApiCallback> callback);
+
+ // Account endpoints
+
+ /**
+ * Send in a new order (asynchronous)
+ *
+ * @param order the new order to submit.
+ * @param callback the callback that handles the response
+ */
+ CompletableFuture newOrder(NewOrder order, BinanceApiCallback callback);
+
+ /**
+ * 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 callback the callback that handles the response
+ */
+ CompletableFuture newOrderTest(NewOrder order, BinanceApiCallback callback);
+
+ /**
+ * Check an order's status (asynchronous).
+ *
+ * @param orderStatusRequest order status request parameters
+ * @param callback the callback that handles the response
+ */
+ CompletableFuture getOrderStatus(OrderStatusRequest orderStatusRequest, BinanceApiCallback callback);
+
+ /**
+ * Cancel an active order (asynchronous).
+ *
+ * @param cancelOrderRequest order status request parameters
+ * @param callback the callback that handles the response
+ */
+ CompletableFuture cancelOrder(CancelOrderRequest cancelOrderRequest, BinanceApiCallback callback);
+
+ /**
+ * Get all open orders on a symbol (asynchronous).
+ *
+ * @param orderRequest order request parameters
+ * @param callback the callback that handles the response
+ */
+ CompletableFuture> getOpenOrders(OrderRequest orderRequest, BinanceApiCallback> callback);
+
+ /**
+ * Get all account orders; active, canceled, or filled.
+ *
+ * @param orderRequest order request parameters
+ * @param callback the callback that handles the response
+ */
+ CompletableFuture> getAllOrders(AllOrdersRequest orderRequest, BinanceApiCallback> callback);
+
+ /**
+ * Get current account information (async).
+ */
+ CompletableFuture getAccount(Long recvWindow, Long timestamp, BinanceApiCallback callback);
+
+ /**
+ * Get current account information using default parameters (async).
+ */
+ CompletableFuture getAccount(BinanceApiCallback callback);
+
+ /**
+ * 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 callback the callback that handles the response with a list of trades
+ */
+ CompletableFuture> getMyTrades(String symbol, Integer limit, Long fromId, Long recvWindow, Long timestamp, BinanceApiCallback> callback);
+
+ /**
+ * Get trades for a specific account and symbol.
+ *
+ * @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
+ */
+ CompletableFuture> getMyTrades(String symbol, Integer limit, BinanceApiCallback> callback);
+
+ /**
+ * Get trades for a specific account and symbol.
+ *
+ * @param symbol symbol to get trades from
+ * @param callback the callback that handles the response with a list of trades
+ */
+ CompletableFuture> 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 addressTag Secondary address identifier for coins like XRP,XMR etc.
+ */
+ CompletableFuture withdraw(String asset, String address, String amount, String name, String addressTag, BinanceApiCallback callback);
+
+ /**
+ * Fetch account deposit history.
+ *
+ * @param callback the callback that handles the response and returns the deposit history
+ */
+ CompletableFuture getDepositHistory(String asset, BinanceApiCallback callback);
+
+ /**
+ * Fetch account withdraw history.
+ *
+ * @param callback the callback that handles the response and returns the withdraw history
+ */
+ CompletableFuture getWithdrawHistory(String asset, BinanceApiCallback callback);
+
+ /**
+ * Fetch deposit address.
+ *
+ * @param callback the callback that handles the response and returns the deposit address
+ */
+ CompletableFuture getDepositAddress(String asset, BinanceApiCallback callback);
+
+ // User stream endpoints
+
+ /**
+ * Start a new user data stream.
+ *
+ * @param callback the callback that handles the response which contains a listenKey
+ */
+ CompletableFuture startUserDataStream(BinanceApiCallback callback);
+
+ /**
+ * 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
+ */
+ CompletableFuture keepAliveUserDataStream(String listenKey, BinanceApiCallback callback);
+
+ /**
+ * 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
+ */
+ CompletableFuture closeUserDataStream(String listenKey, BinanceApiCallback callback);
+}
\ 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..26f197370 100755
--- a/src/main/java/com/binance/api/client/BinanceApiClientFactory.java
+++ b/src/main/java/com/binance/api/client/BinanceApiClientFactory.java
@@ -2,6 +2,9 @@
import com.binance.api.client.impl.*;
import com.binance.api.client.config.BinanceApiConfig;
+
+import java.util.concurrent.ExecutorService;
+
import static com.binance.api.client.impl.BinanceApiServiceGenerator.getSharedClient;
/**
@@ -101,6 +104,19 @@ public BinanceApiRestClient newRestClient() {
return new BinanceApiRestClientImpl(apiKey, secret);
}
+ /**
+ * Creates a new asynchronous/non-blocking REST client that uses Executor Services for handling
+ * the request and response threading.
+ *
+ * @param requestService
+ * @param responseService
+ * @return
+ */
+ public BinanceApiAsyncExecutorRestClient newAsyncExecutorRestClient(ExecutorService requestService,
+ ExecutorService responseService) {
+ return new BinanceApiAsyncExecutorRestClientImpl(newRestClient(), requestService, responseService);
+ }
+
/**
* Creates a new asynchronous/non-blocking REST client.
*/
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..fd41dbad4 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
@@ -123,4 +123,5 @@ public static UserDataUpdateEventType fromEventTypeId(String eventTypeId) {
throw new UnsupportedEventException("Unrecognized user data update event type id: " + eventTypeId);
}
}
+
}
diff --git a/src/main/java/com/binance/api/client/domain/general/FilterType.java b/src/main/java/com/binance/api/client/domain/general/FilterType.java
index 57c2931db..8e960f5c5 100755
--- a/src/main/java/com/binance/api/client/domain/general/FilterType.java
+++ b/src/main/java/com/binance/api/client/domain/general/FilterType.java
@@ -19,8 +19,12 @@ public enum FilterType {
MARKET_LOT_SIZE,
MAX_NUM_ICEBERG_ORDERS,
MAX_POSITION,
+ TRAILING_DELTA,
+ PERCENT_PRICE_BY_SIDE,
// Exchange
EXCHANGE_MAX_NUM_ORDERS,
- EXCHANGE_MAX_ALGO_ORDERS
+ EXCHANGE_MAX_ALGO_ORDERS,
+
+ NOTIONAL
}
\ No newline at end of file
diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncExecutorRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncExecutorRestClientImpl.java
new file mode 100644
index 000000000..0fbe95d56
--- /dev/null
+++ b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncExecutorRestClientImpl.java
@@ -0,0 +1,237 @@
+package com.binance.api.client.impl;
+
+import com.binance.api.client.BinanceApiAsyncExecutorRestClient;
+import com.binance.api.client.BinanceApiCallback;
+import com.binance.api.client.BinanceApiRestClient;
+import com.binance.api.client.domain.account.*;
+import com.binance.api.client.domain.account.request.*;
+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.*;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutorService;
+import java.util.function.Supplier;
+
+/**
+ * Implementation of BinanceApiAsyncExecutorRestClient using ExecutorServices for handling request and responses.
+ */
+public class BinanceApiAsyncExecutorRestClientImpl implements BinanceApiAsyncExecutorRestClient {
+
+ private final BinanceApiRestClient client;
+ private final ExecutorService requestService;
+ private final ExecutorService responseService;
+
+ public BinanceApiAsyncExecutorRestClientImpl(BinanceApiRestClient client, ExecutorService requestService, ExecutorService responseService) {
+ this.client = client;
+ this.requestService = requestService;
+ this.responseService = responseService;
+ }
+
+ private CompletableFuture invoke(BinanceApiCallback callback, Supplier t){
+ CompletableFuture f = CompletableFuture.supplyAsync(t, requestService);
+ if(callback != null){
+ f = f.thenApplyAsync(v -> {
+ callback.onResponse(v);
+ return v;
+ }, responseService);
+
+ f.exceptionally(throwable -> {
+ responseService.submit(()->callback.onFailure(throwable));
+ return null;
+ });
+ }
+ return f;
+ }
+
+ @Override
+ public CompletableFuture ping(BinanceApiCallback callback) {
+ return invoke(callback,() -> {
+ client.ping();
+ return null;
+ });
+ }
+
+ @Override
+ public CompletableFuture getServerTime(BinanceApiCallback callback) {
+ return invoke(callback, () -> {
+ ServerTime t = new ServerTime();
+ t.setServerTime(client.getServerTime());
+ return t;
+ });
+ }
+
+ @Override
+ public CompletableFuture getExchangeInfo(BinanceApiCallback callback) {
+ return invoke(callback, () -> client.getExchangeInfo());
+ }
+
+ @Override
+ public CompletableFuture> getAllAssets(BinanceApiCallback> callback) {
+ return invoke(callback, () -> client.getAllAssets());
+ }
+
+ @Override
+ public CompletableFuture getOrderBook(String symbol, Integer limit, BinanceApiCallback callback) {
+ return invoke(callback, () -> client.getOrderBook(symbol,limit));
+ }
+
+ @Override
+ public CompletableFuture> getTrades(String symbol, Integer limit, BinanceApiCallback> callback) {
+ return invoke(callback, () -> client.getTrades(symbol, limit));
+ }
+
+ @Override
+ public CompletableFuture> getHistoricalTrades(String symbol, Integer limit, Long fromId, BinanceApiCallback> callback) {
+ return invoke(callback, () -> client.getHistoricalTrades(symbol, limit, fromId));
+ }
+
+ @Override
+ public CompletableFuture> getAggTrades(String symbol, String fromId, Integer limit, Long startTime, Long endTime, BinanceApiCallback> callback) {
+ return invoke(callback, () -> client.getAggTrades(symbol,fromId,limit,startTime,endTime));
+ }
+
+ @Override
+ public CompletableFuture> getAggTrades(String symbol, BinanceApiCallback> callback) {
+ return invoke(callback, () -> client.getAggTrades(symbol));
+ }
+
+ @Override
+ public CompletableFuture> getCandlestickBars(String symbol, CandlestickInterval interval, Integer limit, Long startTime, Long endTime, BinanceApiCallback> callback) {
+ return invoke(callback, () -> client.getCandlestickBars(symbol,interval,limit,startTime, endTime));
+ }
+
+ @Override
+ public CompletableFuture> getCandlestickBars(String symbol, CandlestickInterval interval, BinanceApiCallback> callback) {
+ return invoke(callback, () -> client.getCandlestickBars(symbol, interval));
+ }
+
+ @Override
+ public CompletableFuture get24HrPriceStatistics(String symbol, BinanceApiCallback callback) {
+ return invoke(callback, () -> client.get24HrPriceStatistics(symbol));
+ }
+
+ @Override
+ public CompletableFuture> getAll24HrPriceStatistics(BinanceApiCallback> callback) {
+ return invoke(callback, () -> client.getAll24HrPriceStatistics());
+ }
+
+ @Override
+ public CompletableFuture> getAllPrices(BinanceApiCallback> callback) {
+ return invoke(callback, () -> client.getAllPrices());
+ }
+
+ @Override
+ public CompletableFuture getPrice(String symbol, BinanceApiCallback callback) {
+ return invoke(callback, () -> client.getPrice(symbol));
+ }
+
+ @Override
+ public CompletableFuture> getBookTickers(BinanceApiCallback> callback) {
+ return invoke(callback, () -> client.getBookTickers());
+ }
+
+ @Override
+ public CompletableFuture newOrder(NewOrder order, BinanceApiCallback callback) {
+ return invoke(callback, () -> client.newOrder(order));
+ }
+
+ @Override
+ public CompletableFuture newOrderTest(NewOrder order, BinanceApiCallback callback) {
+ return invoke(callback, () -> {
+ client.newOrderTest(order);
+ return null;
+ });
+ }
+
+ @Override
+ public CompletableFuture getOrderStatus(OrderStatusRequest orderStatusRequest, BinanceApiCallback callback) {
+ return invoke(callback, () -> client.getOrderStatus(orderStatusRequest));
+ }
+
+ @Override
+ public CompletableFuture cancelOrder(CancelOrderRequest cancelOrderRequest, BinanceApiCallback callback) {
+ return invoke(callback, () -> client.cancelOrder(cancelOrderRequest));
+ }
+
+ @Override
+ public CompletableFuture> getOpenOrders(OrderRequest orderRequest, BinanceApiCallback> callback) {
+ return invoke(callback, () -> client.getOpenOrders(orderRequest));
+ }
+
+ @Override
+ public CompletableFuture> getAllOrders(AllOrdersRequest orderRequest, BinanceApiCallback> callback) {
+ return invoke(callback, () -> client.getAllOrders(orderRequest));
+ }
+
+ @Override
+ public CompletableFuture getAccount(Long recvWindow, Long timestamp, BinanceApiCallback callback) {
+ return invoke(callback, () -> client.getAccount(recvWindow, timestamp));
+ }
+
+ @Override
+ public CompletableFuture getAccount(BinanceApiCallback callback) {
+ return invoke(callback, () -> client.getAccount());
+ }
+
+ @Override
+ public CompletableFuture> getMyTrades(String symbol, Integer limit, Long fromId, Long recvWindow, Long timestamp, BinanceApiCallback> callback) {
+ return invoke(callback, () -> client.getMyTrades(symbol, limit, fromId, recvWindow, timestamp));
+ }
+
+ @Override
+ public CompletableFuture> getMyTrades(String symbol, Integer limit, BinanceApiCallback> callback) {
+ return invoke(callback, () -> client.getMyTrades(symbol, limit));
+ }
+
+ @Override
+ public CompletableFuture> getMyTrades(String symbol, BinanceApiCallback> callback) {
+ return invoke(callback, () -> client.getMyTrades(symbol));
+ }
+
+ @Override
+ public CompletableFuture withdraw(String asset, String address, String amount, String name, String addressTag, BinanceApiCallback callback) {
+ return invoke(callback, () -> client.withdraw(asset, address, amount, name, addressTag));
+ }
+
+ @Override
+ public CompletableFuture getDepositHistory(String asset, BinanceApiCallback callback) {
+ return invoke(callback, () -> client.getDepositHistory(asset));
+ }
+
+ @Override
+ public CompletableFuture getWithdrawHistory(String asset, BinanceApiCallback callback) {
+ return invoke(callback, () -> client.getWithdrawHistory(asset));
+ }
+
+ @Override
+ public CompletableFuture getDepositAddress(String asset, BinanceApiCallback callback) {
+ return invoke(callback, () -> client.getDepositAddress(asset));
+ }
+
+ @Override
+ public CompletableFuture startUserDataStream(BinanceApiCallback callback) {
+ return invoke(callback, () -> {
+ client.startUserDataStream();
+ return null;
+ });
+ }
+
+ @Override
+ public CompletableFuture keepAliveUserDataStream(String listenKey, BinanceApiCallback callback) {
+ return invoke(callback, () -> {
+ client.keepAliveUserDataStream(listenKey);
+ return null;
+ });
+ }
+
+ @Override
+ public CompletableFuture closeUserDataStream(String listenKey, BinanceApiCallback callback) {
+ return invoke(callback, () -> {
+ client.closeUserDataStream(listenKey);
+ return null;
+ });
+ }
+}
diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientAdapter.java b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientAdapter.java
new file mode 100644
index 000000000..e37dcec9a
--- /dev/null
+++ b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientAdapter.java
@@ -0,0 +1,198 @@
+package com.binance.api.client.impl;
+
+import com.binance.api.client.BinanceApiAsyncExecutorRestClient;
+import com.binance.api.client.BinanceApiAsyncRestClient;
+import com.binance.api.client.BinanceApiCallback;
+import com.binance.api.client.domain.account.*;
+import com.binance.api.client.domain.account.request.*;
+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.*;
+
+import java.util.List;
+
+/**
+ * Adapter to make calls to a BinanceApiAsyncExecutorRestClient using the BinanceApiAsyncRestClient
+ * interface. This allows existing code to migrate to use BinanceApiAsyncExecutorRestClient with dedicated
+ * ExecutorServices without a major lift.
+ * If you are writing new code, consider to use BinanceApiAsyncExecutorRestClient directly.
+ */
+public class BinanceApiAsyncRestClientAdapter implements BinanceApiAsyncRestClient {
+ private BinanceApiAsyncExecutorRestClient delegate;
+
+ public BinanceApiAsyncRestClientAdapter(BinanceApiAsyncExecutorRestClient delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public void ping(BinanceApiCallback callback) {
+ delegate.ping(callback);
+ }
+
+ @Override
+ public void getServerTime(BinanceApiCallback callback) {
+ delegate.getServerTime(callback);
+ }
+
+ @Override
+ public void getExchangeInfo(BinanceApiCallback callback) {
+ delegate.getExchangeInfo(callback);
+ }
+
+ @Override
+ public void getAllAssets(BinanceApiCallback> callback) {
+ delegate.getAllAssets(callback);
+ }
+
+ @Override
+ public void getOrderBook(String symbol, Integer limit, BinanceApiCallback callback) {
+ delegate.getOrderBook(symbol, limit,callback);
+ }
+
+ @Override
+ public void getTrades(String symbol, Integer limit, BinanceApiCallback> callback) {
+ delegate.getTrades(symbol, limit,callback);
+ }
+
+ @Override
+ public void getHistoricalTrades(String symbol, Integer limit, Long fromId, BinanceApiCallback> callback) {
+ delegate.getHistoricalTrades(symbol, limit, fromId,callback);
+ }
+
+ @Override
+ public void getAggTrades(String symbol, String fromId, Integer limit, Long startTime, Long endTime, BinanceApiCallback> callback) {
+ delegate.getAggTrades(symbol, fromId,limit, startTime, endTime, callback);
+ }
+
+ @Override
+ public void getAggTrades(String symbol, BinanceApiCallback> callback) {
+ delegate.getAggTrades(symbol, callback);
+ }
+
+ @Override
+ public void getCandlestickBars(String symbol, CandlestickInterval interval, Integer limit, Long startTime, Long endTime, BinanceApiCallback> callback) {
+ delegate.getCandlestickBars(symbol, interval, limit, startTime, endTime,callback);
+ }
+
+ @Override
+ public void getCandlestickBars(String symbol, CandlestickInterval interval, BinanceApiCallback> callback) {
+ delegate.getCandlestickBars(symbol, interval,callback);
+ }
+
+ @Override
+ public void get24HrPriceStatistics(String symbol, BinanceApiCallback callback) {
+ delegate.get24HrPriceStatistics(symbol,callback);
+ }
+
+ @Override
+ public void getAll24HrPriceStatistics(BinanceApiCallback> callback) {
+ delegate.getAll24HrPriceStatistics(callback);
+ }
+
+ @Override
+ public void getAllPrices(BinanceApiCallback> callback) {
+ delegate.getAllPrices(callback);
+ }
+
+ @Override
+ public void getPrice(String symbol, BinanceApiCallback callback) {
+ delegate.getPrice(symbol,callback);
+ }
+
+ @Override
+ public void getBookTickers(BinanceApiCallback> callback) {
+ delegate.getBookTickers(callback);
+ }
+
+ @Override
+ public void newOrder(NewOrder order, BinanceApiCallback callback) {
+ delegate.newOrder(order,callback);
+ }
+
+ @Override
+ public void newOrderTest(NewOrder order, BinanceApiCallback callback) {
+ delegate.newOrderTest(order,callback);
+ }
+
+ @Override
+ public void getOrderStatus(OrderStatusRequest orderStatusRequest, BinanceApiCallback callback) {
+ delegate.getOrderStatus(orderStatusRequest,callback);
+ }
+
+ @Override
+ public void cancelOrder(CancelOrderRequest cancelOrderRequest, BinanceApiCallback callback) {
+ delegate.cancelOrder(cancelOrderRequest,callback);
+ }
+
+ @Override
+ public void getOpenOrders(OrderRequest orderRequest, BinanceApiCallback> callback) {
+ delegate.getOpenOrders(orderRequest,callback);
+ }
+
+ @Override
+ public void getAllOrders(AllOrdersRequest orderRequest, BinanceApiCallback> callback) {
+ delegate.getAllOrders(orderRequest,callback);
+ }
+
+ @Override
+ public void getAccount(Long recvWindow, Long timestamp, BinanceApiCallback callback) {
+ delegate.getAccount(recvWindow,timestamp,callback);
+ }
+
+ @Override
+ public void getAccount(BinanceApiCallback callback) {
+ delegate.getAccount(callback);
+ }
+
+ @Override
+ public void getMyTrades(String symbol, Integer limit, Long fromId, Long recvWindow, Long timestamp, BinanceApiCallback> callback) {
+ delegate.getMyTrades(symbol, limit,fromId, recvWindow, timestamp,callback);
+ }
+
+ @Override
+ public void getMyTrades(String symbol, Integer limit, BinanceApiCallback> callback) {
+ delegate.getMyTrades(symbol, limit,callback);
+ }
+
+ @Override
+ public void getMyTrades(String symbol, BinanceApiCallback> callback) {
+ delegate.getMyTrades(symbol, callback);
+ }
+
+ @Override
+ public void withdraw(String asset, String address, String amount, String name, String addressTag, BinanceApiCallback callback) {
+ delegate.withdraw(asset, address,amount, name, addressTag,callback);
+ }
+
+ @Override
+ public void getDepositHistory(String asset, BinanceApiCallback callback) {
+ delegate.getDepositHistory(asset, callback);
+ }
+
+ @Override
+ public void getWithdrawHistory(String asset, BinanceApiCallback callback) {
+ delegate.getWithdrawHistory(asset, callback);
+ }
+
+ @Override
+ public void getDepositAddress(String asset, BinanceApiCallback callback) {
+ delegate.getDepositAddress(asset, callback);
+ }
+
+ @Override
+ public void startUserDataStream(BinanceApiCallback callback) {
+ delegate.startUserDataStream(callback);
+ }
+
+ @Override
+ public void keepAliveUserDataStream(String listenKey, BinanceApiCallback callback) {
+ delegate.keepAliveUserDataStream(listenKey, callback);
+ }
+
+ @Override
+ public void closeUserDataStream(String listenKey, BinanceApiCallback callback) {
+ delegate.closeUserDataStream(listenKey, callback);
+ }
+}
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..c7509d5da 100755
--- a/src/main/java/com/binance/api/client/impl/BinanceApiWebSocketClientImpl.java
+++ b/src/main/java/com/binance/api/client/impl/BinanceApiWebSocketClientImpl.java
@@ -30,7 +30,8 @@ public BinanceApiWebSocketClientImpl(OkHttpClient client) {
public Closeable onDepthEvent(String symbols, BinanceApiCallback callback) {
final String channel = Arrays.stream(symbols.split(","))
.map(String::trim)
- .map(s -> String.format("%s@depth", s))
+ .map(s -> String.format("%s@depth@100ms", s))
+ //.map(s -> String.format("%s@depth", s))
.collect(Collectors.joining("/"));
return createNewWebSocket(channel, new BinanceApiWebSocketListener<>(callback, DepthEvent.class));
}
@@ -75,7 +76,8 @@ public Closeable onAllMarketTickersEvent(BinanceApiCallback> c
public Closeable onBookTickerEvent(String symbols, BinanceApiCallback callback) {
final String channel = Arrays.stream(symbols.split(","))
.map(String::trim)
- .map(s -> String.format("%s@bookTicker", s))
+ .map(s -> String.format("%s@bookTicker@100ms", s))
+ // .map(s -> String.format("%s@bookTicker", s))
.collect(Collectors.joining("/"));
return createNewWebSocket(channel, new BinanceApiWebSocketListener<>(callback, BookTickerEvent.class));
}