Git Product home page Git Product logo

java-binance-api's Introduction

Java Binance Unofficial API Client

This library is designed to help you make your own projects that interact with the Binance API. This project seeks to have complete API coverage including User Data Streams and WebSockets for Binance Cryptocurrency Exchange

If you are seeking for a version with Android 4+ support, please take a look at https://github.com/shufps/java-binance-api

Getting Started

with Maven

Add the following Maven dependency to your project's pom.xml:

<dependency>
  <groupId>com.webcerebrium</groupId>
  <artifactId>binance-api</artifactId>
  <version>1.0.9</version>
</dependency>

with Gradle

compile group: 'com.webcerebrium', name: 'binance-api', version: '1.0.9'

with Grapes

@Grapes([ 
@Grab(group = 'com.webcerebrium', module = 'binance-api', version = '1.0.9')
])

with latest source code

After git clone, please run gradle jar, which will result in having jar under build/distribution folder. compilation you will have jar in your folder, which could be included as your dependency like this:

dependencies {
    compile files('libs/binance-api-1.0.9.jar')
}

Example of Application

import com.webcerebrium.binance.api.BinanceApi;
import com.webcerebrium.binance.api.BinanceApiException;

try {
  BinanceApi api = new BinanceApi();
  System.out.println("ETH-BTC PRICE=" + api.pricesMap().get("ETHBTC"));
} catch (BinanceApiException e) {
  System.out.println( "ERROR: " + e.getMessage());
}

Setting up API KEYS

For API keys you can set an environment variables or java Virtual Machine properties BINANCE_API_KEY, BINANCE_SECRET_KEY, as well as setting up these variables in application.properties resource file of your project

Logging

Logging configuration can be corrected in logback.xml files. To suppress requests/response logging, you might want to increase logging level for BinanceRequest component:

<logger name="com.webcerebrium.binance.api.BinanceRequest" level="WARN" />

Debugging Library from Source

If you cloned this GITHUB repository, the following tips might be useful:

Running tests

If you cloned this repository, tests with API coverage could be launched with gradle test. Before running, make sure API keys are set as described above. For successful trading tests passing, it is desired to have some BTC, ETH and BNB on your account.

Running in Eclipse

This project uses Lombok. You will need to install lombok for Eclipse to make the project compile in Eclipse. It will compile via gradle just fine without this additional installation step.

Running in Intellij IDEA

This project uses Lombok. You will need to install corresponding plugin and enable Annotation processing in your Compiler settings. It will compile via gradle just fine without this additional installation step. To start, import current directory as Gradle project.

Using API - General Endpoints

Checking Server Responsiveness

System.out.println((new BinanceApi()).ping() );
View Output
{}

Getting Server Time

System.out.println((new BinanceApi()).time().get("serverTime").getAsString());
View Output
1508364584572

Using API - Getting Account Information

Getting Account Information

JsonObject account = (new BinanceApi()).account();
System.out.println("Maker Commission: " + account.get("makerCommission").getAsBigDecimal());
System.out.println("Taker Commission: " + account.get("takerCommission").getAsBigDecimal());
System.out.println("Buyer Commission: " + account.get("buyerCommission").getAsBigDecimal());
System.out.println("Seller Commission: " + account.get("sellerCommission").getAsBigDecimal());
System.out.println("Can Trade: " +  account.get("canTrade").getAsBoolean());
System.out.println("Can Withdraw: " + account.get("canWithdraw").getAsBoolean());
System.out.println("Can Deposit: " + account.get("canDeposit").getAsBoolean());
View Output
Maker Commission: 10
Taker Commission: 10
Buyer Commission: 0
Seller Commission: 0
Can Trade: true
Can Withdraw: true
Can Deposit: true

Getting All Balances

System.out.println((new BinanceApi()).balances());
View Output
[{"asset":"BTC","free":"0.00001161","locked":"0.00000000"},{"asset":"LTC","free":"0.00000000","locked":"0.00000000"},...,{"asset":"ZEC","free":"0.00000000","locked":"0.00000000"}]

Getting Asset Balance

System.out.println((new BinanceApi()).balancesMap().get("ETH"));
View Output
BinanceWalletAsset(asset=ETH, free=0.00859005, locked=0E-8)

Getting Open Orders

System.out.println((new BinanceApi()).openOrders(BinanceSymbol.valueOf("ETHBTC")));
View Output
[BinanceOrder(symbol=ETHBTC, orderId=11111, clientOrderId=hNch6HItMQp2m9VuQZaA6L, price=0.18200000, origQty=1.00000000, executedQty=0E-8, status=NEW, timeInForce=GTC, type=LIMIT, side=SELL, stopPrice=0E-8, icebergQty=0E-8, time=1508361363677)]

Checking Order Status

BinanceApi api = new BinanceApi();
BinanceSymbol symbol = BinanceSymbol.valueOf("ETHBTC");
System.out.println(api.getOrderById(symbol, 333821L));
System.out.println(api.getOrderByOrigClientId(symbol, "2m9VuQZaA6LhNch6HItMQp"));
View Output
BinanceOrder(symbol=ETHBTC, orderId=333821, clientOrderId=2m9VuQZaA6LhNch6HItMQp, price=0.18200000, origQty=1.00000000, executedQty=0E-8, status=NEW, timeInForce=GTC, type=LIMIT, side=SELL, stopPrice=0E-8, icebergQty=0E-8, time=1508361363677)

Getting All Orders

System.out.println((new BinanceApi()).allOrders(BinanceSymbol.valueOf("BQXBTC")));
View Output
[BinanceOrder(symbol=BQXBTC, orderId=11111, clientOrderId=D0qeCsEBxKaXSRwxKUZkBZ, price=0.00018602, origQty=309.00000000, executedQty=309.00000000, status=FILLED, timeInForce=GTC, type=LIMIT, side=BUY, stopPrice=0E-8, icebergQty=0E-8, time=1506498038089), ... , BinanceOrder(symbol=BQXBTC, orderId=222222, clientOrderId=p2m9VuQZaA6LhNch6HItMQ, price=0.18200000, origQty=1.00000000, executedQty=0E-8, status=NEW, timeInForce=GTC, type=LIMIT, side=SELL, stopPrice=0E-8, icebergQty=0E-8, time=1508361363677)]

Getting My Trades

System.out.println((new BinanceApi()).myTrades(BinanceSymbol.valueOf("BQXBTC")));
View Output
[BinanceTrade(id=1321, commissionAsset=BQX, price=0.00018602, qty=38.00000000, commission=0.03800000, time=1506499148055, isBuyer=true, isMaker=true, isBestMatch=true), ... , BinanceTrade(id=6315, commissionAsset=BNB, price=0.00015216, qty=449.00000000, commission=0.10018983, time=1507144715249, isBuyer=true, isMaker=true, isBestMatch=true)]

Withdrawals

String address = "0x1234567890123456789012345678901234567890";
System.out.println((new BinanceApi()).withdraw("ETH", 0.01, address, ""));

Getting All Deposits History

Server side team still works on this endpoint. At the moment of writing that you will just receive a message in Chinese about parameters exception.

BinanceHistoryFilter historyFilter = new BinanceHistoryFilter();
System.out.println((new BinanceApi()).getDepositHistory(historyFilter));

Getting Withdrawal History

Server side team still works on this endpoint. At the moment of writing that you will just receive a message in Chinese about parameters exception.

BinanceHistoryFilter historyFilter = new BinanceHistoryFilter("ETH");
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH, -3); // only last 3 months
historyFilter.setStartTime(cal.getTime());
System.out.println((new BinanceApi()).getWithdrawHistory(historyFilter));

Using API - Getting Market Data

Getting Bids and Asks on Symbol

BinanceSymbol symbol = BinanceSymbol.valueOf("ETHBTC");
JsonObject depth = (new BinanceApi()).depth(symbol);
System.out.println("BIDS=" + depth.get("bids").getAsJsonArray());
System.out.println("ASKS=" + depth.get("asks").getAsJsonArray());
View Output
```
BIDS=[["0.05577600","2.30000000",[]],["0.05577500","1.10000000",[]],["0.05577400","2.10000000",[]],...,["0.00000100","21000.00000000",[]]]
ASKS=[["0.05590600","10.90900000",[]],["0.05590700","9.96000000",[]],["0.05590800","9.44200000",[]],...,["0.06102400","0.50000000",[]]]
```

Getting latest prices - as list of JsonObjects

System.out.println((new BinanceApi()).prices());
View Output
[{"symbol":"ETHBTC","price":"0.05602000"},{"symbol":"LTCBTC","price":"0.01107300"},{"symbol":"BNBBTC","price":"0.00023561"},...,{"symbol":"BNTBTC","price":"0.00038649"}]

Getting latest prices - as map of decimals

System.out.println((new BinanceApi()).pricesMap());
View Output
{ZECETH=0E-8, SALTETH=0.00940300, WTCETH=0.02207900, NEOETH=0.09463500, ... , MTHETH=0.00028000, FUNETH=0.00007538}

Getting latest price of a symbol

System.out.println((new BinanceApi()).pricesMap().get("ETHBTC"));
View Output
0.05628800

Getting Aggregated Trades

BinanceSymbol symbol = new BinanceSymbol("ETHBTC");
List<BinanceAggregatedTrades> binanceAggregatedTrades = (new BinanceApi()).aggTrades(symbol, 5, null);
BinanceAggregatedTrades trade = binanceAggregatedTrades.get(0);
System.out.println("TRADE=" + trade.toString() );
View Output
TRADE=BinanceAggregatedTrades{tradeId=2084592, price=0.05476100, quantity=6.87000000, firstTradeId=2192143, lastTradeId=2192143, timestamp=1508393572350, maker=true, bestPrice=true}

Getting All Book Tickers

System.out.println((new BinanceApi()).allBookTickers());
View Output
[{"symbol":"ETHBTC","bidPrice":"0.05461000","bidQty":"29.73000000","askPrice":"0.05486300","askQty":"19.96000000"}, ... ,{"symbol":"ASTETH","bidPrice":"0.00102010","bidQty":"4030.00000000","askPrice":"0.00102920","askQty":"187.00000000"}]

Getting All Available Symbols

System.out.println((new BinanceApi()).allBookTickersMap().keySet());
View Output
[ZECETH, SALTETH, WTCETH, NEOETH, IOTABTC, CTRBTC, SNMBTC, LRCETH, ... , MTLETH, SALTBTC, SUBBTC, MTHETH, FUNETH]

Getting 24hr Tickers for Symbol

BinanceSymbol symbol = BinanceSymbol.valueOf("ETHBTC");
System.out.println((new BinanceApi()).ticker24hr(symbol));
View Output
{"priceChange":"-0.00180600","priceChangePercent":"-3.195","weightedAvgPrice":"0.05619267","prevClosePrice":"0.05652600","lastPrice":"0.05472000","lastQty":"0.26100000","bidPrice":"0.05472000","bidQty":"26.53900000","askPrice":"0.05486100","askQty":"0.53100000","openPrice":"0.05652600","highPrice":"0.05734100","lowPrice":"0.05460000","volume":"28260.45000000","quoteVolume":"1588.03005689","openTime":1508308200417,"closeTime":1508394600417,"firstId":2167326,"lastId":2192389,"count":25063}

Getting Klines / Candlesticks

BinanceSymbol symbol = new BinanceSymbol("ETHBTC");
List<BinanceCandlestick> klines = (new BinanceApi()).klines(symbol, BinanceInterval.ONE_HOUR, 5, null);
BinanceCandlestick binanceCandlestick = klines.get(0);
System.out.println("KLINE=" + binanceCandlestick.toString() );
View Output
KLINE=BinanceCandlestick(openTime=1508378400000, open=0.05598000, high=0.05622000, low=0.05569100, close=0.05570500, volume=1514.33900000, closeTime=1508381999999, quoteAssetVolume=84.65979632, numberOfTrades=1683, takerBuyBaseAssetVolume=716.56500000, takerBuyQuoteAssetVolume=40.07877823)

Getting Exchange Market Information (Lot Sizes)

BinanceExchangeInfo binanceExchangeInfo = binanceApi.exchangeInfo();
List<BinanceExchangeSymbol> symbols = binanceExchangeInfo.getSymbols();
BinanceExchangeSymbol BNB = symbols.stream().filter(a -> a.getQuoteAsset().equals("BNB")).findFirst().get();
View Output
BNB Lot Size: {"filterType":"LOT_SIZE","minQty":"0.01000000","maxQty":"10000000.00000000","stepSize":"0.01000000"}

Using API - Placing Orders

Placing a LIMIT order

BinanceApi api = new BinanceApi();
BinanceSymbol symbol = new BinanceSymbol("ETHBTC");
BinanceOrderPlacement placement = new BinanceOrderPlacement(symbol, BinanceOrderSide.BUY);
placement.setType(BinanceOrderType.LIMIT);
placement.setPrice(BigDecimal.valueOf(0.00001));
placement.setQuantity(BigDecimal.valueOf(10000)); // buy 10000 of asset for 0.00001 BTC
BinanceOrder order = api.getOrderById(symbol, api.createOrder(placement).get("orderId").getAsLong());
System.out.println(order.toString());

Placing a MARKET order

BinanceApi api = new BinanceApi();
BinanceSymbol symbol = new BinanceSymbol("ETHBTC");
BinanceOrderPlacement placement = new BinanceOrderPlacement(symbol, BinanceOrderSide.BUY);
placement.setType(BinanceOrderType.MARKET);
placement.setPrice(BigDecimal.valueOf(0.00001));
placement.setQuantity(BigDecimal.valueOf(10000)); // buy 10000 of asset for 0.00001 BTC
BinanceOrder order = api.getOrderById(symbol, api.createOrder(placement).get("orderId").getAsLong());
System.out.println(order.toString());

Placing a STOP LOSS order

BinanceApi api = new BinanceApi();
BinanceSymbol symbol = new BinanceSymbol("ETHBTC");
BinanceOrderPlacement placement = new BinanceOrderPlacement(symbol, BinanceOrderSide.SELL);
placement.setPrice(BigDecimal.valueOf(0.069));
placement.setStopPrice(BigDecimal.valueOf(0.068));
placement.setQuantity(BigDecimal.valueOf(1)); // sell 1 piece of asset
BinanceOrder order = api.getOrderById(symbol, api.createOrder(placement).get("orderId").getAsLong());
System.out.println(order.toString());

Placing an ICEBERG order

BinanceApi api = new BinanceApi();
BinanceSymbol symbol = new BinanceSymbol("ETHBTC");
BinanceOrderPlacement placement = new BinanceOrderPlacement(symbol, BinanceOrderSide.SELL);
placement.setPrice(BigDecimal.valueOf(0.069));
placement.setQuantity(BigDecimal.valueOf(1)); // sell 1 piece of asset
placement.setIcebergQty(BigDecimal.valueOf(10));
BinanceOrder order = api.getOrderById(symbol, api.createOrder(placement).get("orderId").getAsLong());
System.out.println(order.toString());

Cancel/Delete an order

BinanceOrder order = api.getOrderById(symbol, 123456L);
System.out.println(api.deleteOrder(order));
View Output
{}

Using API - Using User Data Streams

Start User Data Stream

String listenKey = (new BinanceApi()).startUserDataStream();
System.out.println(listenKey);
View Output
pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1

Keep User Data Stream Alive

String listenKey = "pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1";
(new BinanceApi()).keepUserDataStream(listenKey);
View Output
{}

Close User Data Stream

String listenKey = "pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1";
(new BinanceApi()).deleteUserDataStream(listenKey);
View Output
{}

Using API - Connecting to Web Sockets

Depth Web Socket Listener

BinanceSymbol symbol = new BinanceSymbol("ETHBTC");
Session session = (new BinanceApi()).websocketDepth(symbol, new BinanceWebSocketAdapterDepth() {
    @Override
    public void onMessage(BinanceEventDepthUpdate message) {
        System.out.println(message.toString());
    }
});
try { Thread.sleep(5000); } catch (InterruptedException e) {}
session.close();
View Output
BinanceEventDepthUpdate(eventTime=1508411905630, symbol=ETHBTC, updateId=17379538, bids=[BinanceBidOrAsk(type=BID, price=0.05356100, quantity=0E-8), BinanceBidOrAsk(type=BID, price=0.05355800, quantity=0E-8)], asks=[BinanceBidOrAsk(type=ASK, price=0.05386000, quantity=0.62900000), BinanceBidOrAsk(type=ASK, price=0.05401300, quantity=0E-8), BinanceBidOrAsk(type=ASK, price=0.05401600, quantity=1.50000000)])
BinanceEventDepthUpdate(eventTime=1508411906630, symbol=ETHBTC, updateId=17379544, bids=[BinanceBidOrAsk(type=BID, price=0.05356200, quantity=0E-8), BinanceBidOrAsk(type=BID, price=0.05354900, quantity=15.00000000), BinanceBidOrAsk(type=BID, price=0.05069700, quantity=0E-8), BinanceBidOrAsk(type=BID, price=0.05066500, quantity=15.60000000)], asks=[BinanceBidOrAsk(type=ASK, price=0.05400600, quantity=1.50000000), BinanceBidOrAsk(type=ASK, price=0.05401600, quantity=0E-8)])
BinanceEventDepthUpdate(eventTime=1508411907630, symbol=ETHBTC, updateId=17379545, bids=[BinanceBidOrAsk(type=BID, price=0.05356500, quantity=10.00000000)], asks=[])

Klines Web Socket Listener

BinanceSymbol symbol = new BinanceSymbol("ETHBTC");
BinanceInterval interval = BinanceInterval.FIVE_MIN;
Session session = (new BinanceApi()).websocketKlines(symbol, interval, new BinanceWebSocketAdapterKline() {
    @Override
    public void onMessage(BinanceEventKline message) {
        System.out.println(message.toString());
    }
});
try { Thread.sleep(15000); } catch (InterruptedException e) {}
session.close();
View Output
BinanceEventKline(eventTime=1508416507504, symbol=ETHBTC, interval=1m, startTime=1508416500000, endTime=1508416559999, firstTradeId=-1, lastTradeId=-1, open=0.05393800, close=0.05393800, high=0.05393800, low=0.05393800, volume=0E-8, numberOfTrades=0, isFinal=false, quoteVolume=0E-8, volumeOfActiveBuy=0E-8, quoteVolumeOfActiveBuy=0E-8)

Trades Web Socket Listener

BinanceSymbol symbol = new BinanceSymbol("ETHBTC");
Session session = (new BinanceApi()).websocketTrades(symbol, new BinanceWebSocketAdapterAggTrades() {
    @Override
    public void onMessage(BinanceEventAggTrade message) {
        System.out.println(message.toString());
    }
});
try { Thread.sleep(8000); } catch (InterruptedException e) {}
session.close();
View Output
BinanceEventAggTrade(eventTime=1508412260766, symbol=ETHBTC, aggregatedTradeId=2089883, price=0.05369800, quantity=3.68000000, firstBreakdownTradeId=2197559, lastBreakdownTradeId=2197559, tradeTime=1508412260762, isMaker=false)
BinanceEventAggTrade(eventTime=1508412260835, symbol=ETHBTC, aggregatedTradeId=2089884, price=0.05369800, quantity=1.00000000, firstBreakdownTradeId=2197560, lastBreakdownTradeId=2197560, tradeTime=1508412260832, isMaker=false)

User Data Web Socket Listener

BinanceApi api = new BinanceApi();
String listenKey = api.startUserDataStream();
Session session = api.websocket(listenKey, new BinanceWebSocketAdapterUserData() {
    @Override
    public void onOutboundAccountInfo(BinanceEventOutboundAccountInfo message) {
        System.out.println(message.toString());
    }
    @Override
    public void onExecutionReport(BinanceEventExecutionReport message) {
        System.out.println(message.toString());
    }
});
Thread.sleep(5000);
session.close();
api.deleteUserDataStream(listenKey);

Contribution

This is an API that is not officially supported. So contributions in any form, especially pull requests are always welcome. If you like what we do, and want to support our development of distributed future, you can also send tips:

GAS: AKXysWVLmB2J5qxGPJLFBPducj5cNMYKLo
ETH: 0x95E972Ff1A4CB6112cb08FE7DE81542DF9b8a0F4

License

MIT. Anyone can copy, change, derive further work from this repository without any restrictions.

java-binance-api's People

Contributors

cutwebapps avatar elsehow avatar mirxak avatar stijnq avatar vic-awsdev5 avatar wcrbrm avatar wimpymistake avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-binance-api's Issues

Increase the speed of order request

This post is not an issue but more like a suggestion for optimization.

I am wondering if it's possible by any means to lower the time that is required to POST an order. If the price is guaranteed it takes 1 second to send the request and get the order registered. Is there a chance to lower that time ?

Websockets don't reconnect

Websocket-Lister do not reconnect after they have been disconnected (from binance or when disconnected by 24h DSL-disconnect)

It would be nice, to automatically reconnect Websocket-Listeners.

Use this library on testnet

Is there any way to use this library on binance testnet ?
and what about features ?
I can not found any documentation about that .

help!

hey,
I have this type of error and idk why can you explain pls?
the error :
binance.exceptions.BinanceAPIException: APIError(code=-1013): Filter failure: LOT_SIZE

ERROR: -1013, Filter failure: PRICE_FILTER

I'm getting this error even when i've parsed the exchangeInfo api and trimmed my price value to the appropriate asset precision. It's also above the minPrice value as well. Can't seem to find what the problem is. This is the value i am using to create my NANOBTC order with: 9.7504E-4. The base asset preicision for NANOBTC is 8. What am i missing?

Trade with PAX or TUSD

When will be trade with PAX and TUSD be supported?

com.webcerebrium.binance.api.BinanceApiException: Market Symbol should be ending with BTC, ETH, BNB or USDT. Example: BQXBTC

ERROR: -1111, Precision is over the maximum defined for this asset.

Hi, I'm trying to place sell order and I'm getting this error.
I have amount of 355.551 and price 0.00002898.
ExchangeSymbol precisions are both 8 for base and quote.
What exactly do I need to do?

I tried the same order through web interface and Binance is rounding amount to 355.

MARKET_LOT_SIZE error (code = -1013

Hello everyone,
When I try to place an order with the instruction create_test_order I have this error "APIError(code=-1013): Filter failure: MARKET_LOT_SIZE.

However, I read the documentation about this and I am sure that I respect the conditions (minQty, maxQty, filterType). It happens only when I try to sell 75000 TRX in BUSD, while it's fine with BTCBUSD and ETHBUSD. More precisely, the line I wrote is : order = client.create_test_order(symbol='TRXBUSD', side='SELL', type='MARKET', quantity=0.15*500000))

Do you have any ideas please?

Get price market into websocket

Good, I have a problem, I am making Market type orders, what I do is first check the prices of the getAllPrices library and then proceed to place the order, but at that moment when I generate the order the price changes; I imagine that it happens because a call is made to RestApi and that takes a while that when generating the order the price change. I am now using webSocket, do you know where I can get the market price in the methods that are associated with the websocket?

What is MIN_NOTIONAL Error

my buy XRPUSDT with Price 10.04286 quntity 9.6

com.webcerebrium.binance.api.BinanceApiException: ERROR: -1013, Filter failure: MIN_NOTIONAL at com.webcerebrium.binance.api.BinanceRequest.read(BinanceRequest.java:260) at com.webcerebrium.binance.api.BinanceApi.createOrder(BinanceApi.java:523) at com.mahdi.btcorders.OrderService.openOrder(OrderService.java:144) at com.mahdi.btcorders.OrderService.getBalanceBinance(OrderService.java:123) at com.mahdi.btcorders.OrderService$1.run(OrderService.java:40) at java.base/java.lang.Thread.run(Thread.java:834)

Logback

Hello,

I have been using this api for a little while now, and I like it. However I can not seem to disable the logback. I have never used logback myself, so I just tried creating logback.xml files at the root of the project and some other places. However it still keeps on logging. Can somebody tell me what I have to put where to disable it. I imported the project using maven.

Android support?

I'm trying to run this on Android, but can't seem to get this compile.

try {
    BinanceSymbol symbol = new BinanceSymbol("ETHXLM");
    new BinanceApi().websocketTrades(symbol, new BinanceWebSocketAdapterAggTrades() {
        @Override
        public void onMessage(BinanceEventAggTrade event) throws BinanceApiException {
            Log.i(TAG, "onMessage: "+event.getPrice()+"/"+event.getQuantity());
        }
    });
} catch (BinanceApiException e) {
    e.printStackTrace();
}

Error message:

Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing org/eclipse/jetty/util/statistic/SampleStatistic.class
Error:com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
...and more

It seems that this will only work on Android 8.0 since the jetty library is not support for earlier versions

ThreadSafe implementation of balances

Hi,

The current implementation of BinanceApi.balancesMap() is not thread safe as you are using a HashMap. Is it possible to change it to ConcurrentHashMap? Even though my call to getting the balances is single-threaded, the resulting map is used in a multithreaded application.

Using version 1.0.3.

Great job with the client, very intuitive and easy to use.

getting connection refused Exception using web socket

When I run websocketDepth example, I'm getting ConnectionRefusedException.
This is the log:
starting
20:02:56.576 [main] DEBUG org.eclipse.jetty.util.log - Logging to Logger[org.eclipse.jetty.util.log] via org.eclipse.jetty.util.log.Slf4jLog
20:02:56.592 [main] INFO org.eclipse.jetty.util.log - Logging initialized @420MS to org.eclipse.jetty.util.log.Slf4jLog
20:02:56.809 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - WebSocketClient@d44e68e3[httpClient=org.eclipse.jetty.client.HttpClient@574caa3f,openSessions.size=0] added {org.eclipse.jetty.client.HttpClient@574caa3f,AUTO}
20:02:56.866 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope@6aceb1a5 added {org.eclipse.jetty.util.thread.QueuedThreadPool@WebSocketContainer@1791930789{STOPPED,8<=0<=200,i=0,q=0},AUTO}
20:02:56.984 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - starting WebSocketClient@d44e68e3[httpClient=org.eclipse.jetty.client.HttpClient@574caa3f,openSessions.size=0]
20:02:56.987 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - starting org.eclipse.jetty.client.HttpClient@574caa3f
20:02:56.988 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.client.HttpClient@574caa3f added {SslContextFactory@63d4e2ba(null,null),AUTO}
20:02:57.000 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.client.HttpClient@574caa3f added {org.eclipse.jetty.util.thread.QueuedThreadPool@HttpClient@1464642111{STOPPED,8<=0<=200,i=0,q=0},AUTO}
20:02:57.002 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.client.HttpClient@574caa3f added {org.eclipse.jetty.io.MappedByteBufferPool@33a10788,POJO}
20:02:57.004 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.client.HttpClient@574caa3f added {org.eclipse.jetty.util.thread.ScheduledExecutorScheduler@3aa9e816,AUTO}
20:02:57.004 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.client.HttpClient@574caa3f added {org.eclipse.jetty.client.http.HttpClientTransportOverHTTP@17d99928,AUTO}
20:02:57.006 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.client.HttpClient@574caa3f added {org.eclipse.jetty.util.SocketAddressResolver$Async@6fffcba5,POJO}
20:02:57.050 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - starting SslContextFactory@63d4e2ba(null,null)
20:02:57.050 [main] DEBUG org.eclipse.jetty.util.ssl.SslContextFactory - No keystore or trust store configured. ACCEPTING UNTRUSTED CERTIFICATES!!!!!
20:02:57.859 [main] DEBUG org.eclipse.jetty.util.ssl.SslContextFactory - Selected Protocols [TLSv1, TLSv1.1, TLSv1.2] of [SSLv2Hello, SSLv3, TLSv1, TLSv1.1, TLSv1.2]
20:02:57.860 [main] DEBUG org.eclipse.jetty.util.ssl.SslContextFactory - Selected Ciphers [TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256] of [TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256]
20:02:57.860 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - STARTED @1690ms SslContextFactory@63d4e2ba(null,null)
20:02:57.860 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - starting org.eclipse.jetty.util.thread.QueuedThreadPool@HttpClient@1464642111{STOPPED,8<=0<=200,i=0,q=0}
20:02:57.862 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - STARTED @1692ms org.eclipse.jetty.util.thread.QueuedThreadPool@HttpClient@1464642111{STARTED,8<=8<=200,i=2,q=0}
20:02:57.862 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - starting org.eclipse.jetty.util.thread.ScheduledExecutorScheduler@3aa9e816
20:02:57.865 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - STARTED @1695ms org.eclipse.jetty.util.thread.ScheduledExecutorScheduler@3aa9e816
20:02:57.865 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - starting org.eclipse.jetty.client.http.HttpClientTransportOverHTTP@17d99928
20:02:57.867 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.client.http.HttpClientTransportOverHTTP@17d99928 added {org.eclipse.jetty.client.AbstractConnectorHttpClientTransport$ClientSelectorManager@23ceabc1,AUTO}
20:02:57.867 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - starting org.eclipse.jetty.client.AbstractConnectorHttpClientTransport$ClientSelectorManager@23ceabc1
20:02:57.868 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.client.AbstractConnectorHttpClientTransport$ClientSelectorManager@23ceabc1 added {org.eclipse.jetty.util.thread.ReservedThreadExecutor@100fc185{s=0,p=0},MANAGED}
20:02:57.876 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - EatWhatYouKill@735b5592/SelectorProducer@724af044/IDLE/org.eclipse.jetty.util.thread.ReservedThreadExecutor@100fc185{s=0,p=0} added {SelectorProducer@724af044,POJO}
20:02:57.876 [main] DEBUG org.eclipse.jetty.util.thread.strategy.EatWhatYouKill - EatWhatYouKill@735b5592/SelectorProducer@724af044/IDLE/org.eclipse.jetty.util.thread.ReservedThreadExecutor@100fc185{s=0,p=0} created
20:02:57.877 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.io.ManagedSelector@4678c730 id=0 keys=-1 selected=-1 added {EatWhatYouKill@735b5592/SelectorProducer@724af044/IDLE/org.eclipse.jetty.util.thread.ReservedThreadExecutor@100fc185{s=0,p=0},MANAGED}
20:02:57.877 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.client.AbstractConnectorHttpClientTransport$ClientSelectorManager@23ceabc1 added {org.eclipse.jetty.io.ManagedSelector@4678c730 id=0 keys=-1 selected=-1,AUTO}
20:02:57.877 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - EatWhatYouKill@6767c1fc/SelectorProducer@29ee9faa/IDLE/org.eclipse.jetty.util.thread.ReservedThreadExecutor@100fc185{s=0,p=0} added {SelectorProducer@29ee9faa,POJO}
20:02:57.878 [main] DEBUG org.eclipse.jetty.util.thread.strategy.EatWhatYouKill - EatWhatYouKill@6767c1fc/SelectorProducer@29ee9faa/IDLE/org.eclipse.jetty.util.thread.ReservedThreadExecutor@100fc185{s=0,p=0} created
20:02:57.878 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.io.ManagedSelector@c038203 id=1 keys=-1 selected=-1 added {EatWhatYouKill@6767c1fc/SelectorProducer@29ee9faa/IDLE/org.eclipse.jetty.util.thread.ReservedThreadExecutor@100fc185{s=0,p=0},MANAGED}
20:02:57.878 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.client.AbstractConnectorHttpClientTransport$ClientSelectorManager@23ceabc1 added {org.eclipse.jetty.io.ManagedSelector@c038203 id=1 keys=-1 selected=-1,AUTO}
20:02:57.878 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - starting org.eclipse.jetty.util.thread.ReservedThreadExecutor@100fc185{s=0,p=0}
20:02:57.879 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - STARTED @1709ms org.eclipse.jetty.util.thread.ReservedThreadExecutor@100fc185{s=0,p=0}
20:02:57.879 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - starting org.eclipse.jetty.io.ManagedSelector@4678c730 id=0 keys=-1 selected=-1
20:02:57.879 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - starting EatWhatYouKill@735b5592/SelectorProducer@724af044/IDLE/org.eclipse.jetty.util.thread.ReservedThreadExecutor@100fc185{s=0,p=0}
20:02:57.879 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - STARTED @1710ms EatWhatYouKill@735b5592/SelectorProducer@724af044/IDLE/org.eclipse.jetty.util.thread.ReservedThreadExecutor@100fc185{s=0,p=0}
20:02:57.890 [main] DEBUG org.eclipse.jetty.util.thread.QueuedThreadPool - queue org.eclipse.jetty.io.ManagedSelector$$Lambda$5/892529689@68c4039c
20:02:57.891 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - STARTED @1721ms org.eclipse.jetty.io.ManagedSelector@4678c730 id=0 keys=0 selected=0
20:02:57.891 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.util.thread.QueuedThreadPool - run org.eclipse.jetty.io.ManagedSelector$$Lambda$5/892529689@68c4039c
20:02:57.891 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - starting org.eclipse.jetty.io.ManagedSelector@c038203 id=1 keys=-1 selected=-1
20:02:57.891 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.util.thread.strategy.EatWhatYouKill - EatWhatYouKill@735b5592/SelectorProducer@724af044/IDLE/org.eclipse.jetty.util.thread.ReservedThreadExecutor@100fc185{s=0,p=0} produce
20:02:57.891 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - starting EatWhatYouKill@6767c1fc/SelectorProducer@29ee9faa/IDLE/org.eclipse.jetty.util.thread.ReservedThreadExecutor@100fc185{s=0,p=0}
20:02:57.891 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - STARTED @1722ms EatWhatYouKill@6767c1fc/SelectorProducer@29ee9faa/IDLE/org.eclipse.jetty.util.thread.ReservedThreadExecutor@100fc185{s=0,p=0}
20:02:57.892 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.io.ManagedSelector - Selector loop waiting on select
20:02:57.892 [main] DEBUG org.eclipse.jetty.util.thread.QueuedThreadPool - queue org.eclipse.jetty.io.ManagedSelector$$Lambda$5/892529689@ae45eb6
20:02:57.893 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - STARTED @1723ms org.eclipse.jetty.io.ManagedSelector@c038203 id=1 keys=0 selected=0
20:02:57.893 [HttpClient@1464642111-12] DEBUG org.eclipse.jetty.util.thread.QueuedThreadPool - run org.eclipse.jetty.io.ManagedSelector$$Lambda$5/892529689@ae45eb6
20:02:57.893 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - STARTED @1723ms org.eclipse.jetty.client.AbstractConnectorHttpClientTransport$ClientSelectorManager@23ceabc1
20:02:57.893 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - STARTED @1723ms org.eclipse.jetty.client.http.HttpClientTransportOverHTTP@17d99928
20:02:57.893 [HttpClient@1464642111-12] DEBUG org.eclipse.jetty.util.thread.strategy.EatWhatYouKill - EatWhatYouKill@6767c1fc/SelectorProducer@29ee9faa/IDLE/org.eclipse.jetty.util.thread.ReservedThreadExecutor@100fc185{s=0,p=0} produce
20:02:57.893 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - STARTED @1723ms org.eclipse.jetty.client.HttpClient@574caa3f
20:02:57.893 [HttpClient@1464642111-12] DEBUG org.eclipse.jetty.io.ManagedSelector - Selector loop waiting on select
20:02:57.893 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - STARTED @1723ms WebSocketClient@d44e68e3[httpClient=org.eclipse.jetty.client.HttpClient@574caa3f,openSessions.size=0]
20:02:57.896 [main] DEBUG org.eclipse.jetty.websocket.client.WebSocketClient - connect websocket com.smartsoft.binanceTerminal.Test$1@42d80b78 to wss://stream.binance.com:9443/ws/ethbtc@depth
20:02:57.945 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - org.eclipse.jetty.client.HttpClient@574caa3f added {HttpDestination[wss://stream.binance.com:9443]@5649fd9b,queue=0,pool=null,MANAGED}
20:02:57.945 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - starting HttpDestination[wss://stream.binance.com:9443]@5649fd9b,queue=0,pool=null
20:02:57.947 [main] DEBUG org.eclipse.jetty.util.component.ContainerLifeCycle - HttpDestination[wss://stream.binance.com:9443]@5649fd9b,queue=0,pool=DuplexConnectionPool@64bfbc86[c=0/64,a=0,i=0] added {DuplexConnectionPool@64bfbc86[c=0/64,a=0,i=0],POJO}
20:02:57.948 [main] DEBUG org.eclipse.jetty.util.component.AbstractLifeCycle - STARTED @1779ms HttpDestination[wss://stream.binance.com:9443]@5649fd9b,queue=0,pool=DuplexConnectionPool@64bfbc86[c=0/64,a=0,i=0]
20:02:57.949 [main] DEBUG org.eclipse.jetty.client.HttpClient - Created HttpDestination[wss://stream.binance.com:9443]@5649fd9b,queue=0,pool=DuplexConnectionPool@64bfbc86[c=0/64,a=0,i=0]
20:02:57.952 [main] DEBUG org.eclipse.jetty.client.HttpDestination - Queued HttpRequest[GET /ws/ethbtc@depth HTTP/1.1]@1e127982 for HttpDestination[wss://stream.binance.com:9443]@5649fd9b,queue=1,pool=DuplexConnectionPool@64bfbc86[c=0/64,a=0,i=0]
20:02:57.952 [main] DEBUG org.eclipse.jetty.client.AbstractConnectionPool - Connection 1/64 creation
20:02:57.955 [main] DEBUG org.eclipse.jetty.util.thread.QueuedThreadPool - queue org.eclipse.jetty.util.SocketAddressResolver$Async$$Lambda$7/555826066@66480dd7
20:02:57.955 [HttpClient@1464642111-10] DEBUG org.eclipse.jetty.util.thread.QueuedThreadPool - run org.eclipse.jetty.util.SocketAddressResolver$Async$$Lambda$7/555826066@66480dd7
20:02:57.992 [HttpClient@1464642111-10] DEBUG org.eclipse.jetty.util.SocketAddressResolver - Resolved stream.binance.com in 34 ms
20:02:57.995 [HttpClient@1464642111-10] DEBUG org.eclipse.jetty.io.ManagedSelector - Queued change org.eclipse.jetty.io.ManagedSelector$Connect@398a1721 on org.eclipse.jetty.io.ManagedSelector@4678c730 id=0 keys=0 selected=0
20:02:57.995 [HttpClient@1464642111-10] DEBUG org.eclipse.jetty.util.thread.QueuedThreadPool - ran org.eclipse.jetty.util.SocketAddressResolver$Async$$Lambda$7/555826066@66480dd7
20:02:57.995 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.io.ManagedSelector - Selector loop woken up from select, 0/0 selected
20:02:57.996 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.io.ManagedSelector - Running action org.eclipse.jetty.io.ManagedSelector$Connect@398a1721
20:02:57.997 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.io.ManagedSelector - Selector loop waiting on select
20:03:00.577 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.io.ManagedSelector - Selector loop woken up from select, 1/1 selected
20:03:00.579 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.io.ManagedSelector - selected sun.nio.ch.SelectionKeyImpl@7d5df3d9 org.eclipse.jetty.io.ManagedSelector$Connect@398a1721
20:03:00.583 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.client.HttpClientTransport - Could not connect to HttpDestination[wss://stream.binance.com:9443]@5649fd9b,queue=1,pool=DuplexConnectionPool@64bfbc86[c=1/64,a=0,i=0]
20:03:00.586 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.io.ManagedSelector - Queued change org.eclipse.jetty.io.ManagedSelector$Connect@3c673310 on org.eclipse.jetty.io.ManagedSelector@c038203 id=1 keys=0 selected=0
20:03:00.587 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.io.ManagedSelector - Selector loop waiting on select
20:03:00.587 [HttpClient@1464642111-12] DEBUG org.eclipse.jetty.io.ManagedSelector - Selector loop woken up from select, 0/0 selected
20:03:00.588 [HttpClient@1464642111-12] DEBUG org.eclipse.jetty.io.ManagedSelector - Running action org.eclipse.jetty.io.ManagedSelector$Connect@3c673310
20:03:00.589 [HttpClient@1464642111-12] DEBUG org.eclipse.jetty.io.ManagedSelector - Selector loop waiting on select
20:03:03.205 [HttpClient@1464642111-12] DEBUG org.eclipse.jetty.io.ManagedSelector - Selector loop woken up from select, 1/1 selected
20:03:03.205 [HttpClient@1464642111-12] DEBUG org.eclipse.jetty.io.ManagedSelector - selected sun.nio.ch.SelectionKeyImpl@eb82d48 org.eclipse.jetty.io.ManagedSelector$Connect@3c673310
20:03:03.209 [HttpClient@1464642111-12] DEBUG org.eclipse.jetty.client.HttpClientTransport - Could not connect to HttpDestination[wss://stream.binance.com:9443]@5649fd9b,queue=1,pool=DuplexConnectionPool@64bfbc86[c=1/64,a=0,i=0]
20:03:03.211 [HttpClient@1464642111-12] DEBUG org.eclipse.jetty.io.ManagedSelector - Queued change org.eclipse.jetty.io.ManagedSelector$Connect@7fc2ef on org.eclipse.jetty.io.ManagedSelector@4678c730 id=0 keys=0 selected=0
20:03:03.212 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.io.ManagedSelector - Selector loop woken up from select, 0/0 selected
20:03:03.212 [HttpClient@1464642111-12] DEBUG org.eclipse.jetty.io.ManagedSelector - Selector loop waiting on select
20:03:03.213 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.io.ManagedSelector - Running action org.eclipse.jetty.io.ManagedSelector$Connect@7fc2ef
20:03:03.214 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.io.ManagedSelector - Selector loop waiting on select
20:03:05.770 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.io.ManagedSelector - Selector loop woken up from select, 1/1 selected
20:03:05.770 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.io.ManagedSelector - selected sun.nio.ch.SelectionKeyImpl@2c746446 org.eclipse.jetty.io.ManagedSelector$Connect@7fc2ef
20:03:05.772 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.client.HttpClientTransport - Could not connect to HttpDestination[wss://stream.binance.com:9443]@5649fd9b,queue=1,pool=DuplexConnectionPool@64bfbc86[c=1/64,a=0,i=0]
20:03:05.777 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.client.AbstractConnectionPool - Connection 1/64 creation failed
java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.eclipse.jetty.io.SelectorManager.doFinishConnect(SelectorManager.java:385)
at org.eclipse.jetty.io.ManagedSelector.processConnect(ManagedSelector.java:154)
at org.eclipse.jetty.io.ManagedSelector.access$1300(ManagedSelector.java:59)
at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.processSelected(ManagedSelector.java:394)
at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:289)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:179)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:679)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:597)
at java.lang.Thread.run(Thread.java:748)
20:03:05.779 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.client.HttpExchange - Failed HttpExchange@256aa851 req=COMPLETED/java.net.ConnectException: Connection refused: no further information@19c1e16b res=COMPLETED/java.net.ConnectException: Connection refused: no further information@19c1e16b: req=true/rsp=true java.net.ConnectException: Connection refused: no further information
20:03:05.780 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.client.HttpExchange - Aborting while queued HttpExchange@256aa851 req=COMPLETED/java.net.ConnectException: Connection refused: no further information@19c1e16b res=COMPLETED/java.net.ConnectException: Connection refused: no further information@19c1e16b: java.net.ConnectException: Connection refused: no further information
20:03:05.781 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest - onComplete() - Result[HttpRequest[GET /ws/ethbtc@depth HTTP/1.1]@1e127982 > HttpResponse[null 0 null]@d02d819] java.net.ConnectException: Connection refused: no further information
20:03:05.782 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest - General Failure
java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.eclipse.jetty.io.SelectorManager.doFinishConnect(SelectorManager.java:385)
at org.eclipse.jetty.io.ManagedSelector.processConnect(ManagedSelector.java:154)
at org.eclipse.jetty.io.ManagedSelector.access$1300(ManagedSelector.java:59)
at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.processSelected(ManagedSelector.java:394)
at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:289)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:179)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:679)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:597)
at java.lang.Thread.run(Thread.java:748)
20:03:05.782 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest - Request Failure
java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.eclipse.jetty.io.SelectorManager.doFinishConnect(SelectorManager.java:385)
at org.eclipse.jetty.io.ManagedSelector.processConnect(ManagedSelector.java:154)
at org.eclipse.jetty.io.ManagedSelector.access$1300(ManagedSelector.java:59)
at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.processSelected(ManagedSelector.java:394)
at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:289)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:179)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:679)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:597)
at java.lang.Thread.run(Thread.java:748)
20:03:05.783 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest - Response Failure
java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.eclipse.jetty.io.SelectorManager.doFinishConnect(SelectorManager.java:385)
at org.eclipse.jetty.io.ManagedSelector.processConnect(ManagedSelector.java:154)
at org.eclipse.jetty.io.ManagedSelector.access$1300(ManagedSelector.java:59)
at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.processSelected(ManagedSelector.java:394)
at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:289)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:179)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:679)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:597)
at java.lang.Thread.run(Thread.java:748)
20:03:05.783 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.websocket.common.events.AbstractEventDriver - incomingError(java.net.ConnectException)
java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.eclipse.jetty.io.SelectorManager.doFinishConnect(SelectorManager.java:385)
at org.eclipse.jetty.io.ManagedSelector.processConnect(ManagedSelector.java:154)
at org.eclipse.jetty.io.ManagedSelector.access$1300(ManagedSelector.java:59)
at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.processSelected(ManagedSelector.java:394)
at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:289)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:179)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:679)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:597)
at java.lang.Thread.run(Thread.java:748)
20:03:05.783 [HttpClient@1464642111-13] ERROR com.webcerebrium.binance.websocket.BinanceWebSocketAdapterDepth - onWebSocketError: {}
java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.eclipse.jetty.io.SelectorManager.doFinishConnect(SelectorManager.java:385)
at org.eclipse.jetty.io.ManagedSelector.processConnect(ManagedSelector.java:154)
at org.eclipse.jetty.io.ManagedSelector.access$1300(ManagedSelector.java:59)
at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.processSelected(ManagedSelector.java:394)
at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:289)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:179)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:679)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:597)
at java.lang.Thread.run(Thread.java:748)
20:03:05.784 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.websocket.common.events.AbstractEventDriver - incomingError(org.eclipse.jetty.websocket.api.UpgradeException)
org.eclipse.jetty.websocket.api.UpgradeException: 0 null
at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.onComplete(WebSocketUpgradeRequest.java:520)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:193)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:185)
at org.eclipse.jetty.client.HttpExchange.notifyFailureComplete(HttpExchange.java:269)
at org.eclipse.jetty.client.HttpExchange.abort(HttpExchange.java:240)
at org.eclipse.jetty.client.HttpConversation.abort(HttpConversation.java:141)
at org.eclipse.jetty.client.HttpRequest.abort(HttpRequest.java:748)
at org.eclipse.jetty.client.HttpDestination.abort(HttpDestination.java:447)
at org.eclipse.jetty.client.HttpDestination.failed(HttpDestination.java:227)
at org.eclipse.jetty.client.AbstractConnectionPool$1.failed(AbstractConnectionPool.java:122)
at org.eclipse.jetty.util.Promise$Wrapper.failed(Promise.java:136)
at org.eclipse.jetty.client.HttpClient$1$1.failed(HttpClient.java:589)
at org.eclipse.jetty.client.AbstractConnectorHttpClientTransport.connectFailed(AbstractConnectorHttpClientTransport.java:135)
at org.eclipse.jetty.client.AbstractConnectorHttpClientTransport$ClientSelectorManager.connectionFailed(AbstractConnectorHttpClientTransport.java:180)
at org.eclipse.jetty.io.ManagedSelector$Connect.failed(ManagedSelector.java:679)
at org.eclipse.jetty.io.ManagedSelector$Connect.access$500(ManagedSelector.java:646)
at org.eclipse.jetty.io.ManagedSelector.processConnect(ManagedSelector.java:184)
at org.eclipse.jetty.io.ManagedSelector.access$1300(ManagedSelector.java:59)
at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.processSelected(ManagedSelector.java:394)
at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:289)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:179)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:679)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:597)
at java.lang.Thread.run(Thread.java:748)
20:03:05.784 [HttpClient@1464642111-13] ERROR com.webcerebrium.binance.websocket.BinanceWebSocketAdapterDepth - onWebSocketError: {}
org.eclipse.jetty.websocket.api.UpgradeException: 0 null
at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.onComplete(WebSocketUpgradeRequest.java:520)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:193)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:185)
at org.eclipse.jetty.client.HttpExchange.notifyFailureComplete(HttpExchange.java:269)
at org.eclipse.jetty.client.HttpExchange.abort(HttpExchange.java:240)
at org.eclipse.jetty.client.HttpConversation.abort(HttpConversation.java:141)
at org.eclipse.jetty.client.HttpRequest.abort(HttpRequest.java:748)
at org.eclipse.jetty.client.HttpDestination.abort(HttpDestination.java:447)
at org.eclipse.jetty.client.HttpDestination.failed(HttpDestination.java:227)
at org.eclipse.jetty.client.AbstractConnectionPool$1.failed(AbstractConnectionPool.java:122)
at org.eclipse.jetty.util.Promise$Wrapper.failed(Promise.java:136)
at org.eclipse.jetty.client.HttpClient$1$1.failed(HttpClient.java:589)
at org.eclipse.jetty.client.AbstractConnectorHttpClientTransport.connectFailed(AbstractConnectorHttpClientTransport.java:135)
at org.eclipse.jetty.client.AbstractConnectorHttpClientTransport$ClientSelectorManager.connectionFailed(AbstractConnectorHttpClientTransport.java:180)
at org.eclipse.jetty.io.ManagedSelector$Connect.failed(ManagedSelector.java:679)
at org.eclipse.jetty.io.ManagedSelector$Connect.access$500(ManagedSelector.java:646)
at org.eclipse.jetty.io.ManagedSelector.processConnect(ManagedSelector.java:184)
at org.eclipse.jetty.io.ManagedSelector.access$1300(ManagedSelector.java:59)
at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.processSelected(ManagedSelector.java:394)
at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:289)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:179)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:679)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:597)
at java.lang.Thread.run(Thread.java:748)
20:03:05.785 [HttpClient@1464642111-13] DEBUG org.eclipse.jetty.io.ManagedSelector - Selector loop waiting on select
com.webcerebrium.binance.api.BinanceApiException: Websocket error: java.net.ConnectException: Connection refused: no further informationfinished

at com.webcerebrium.binance.api.BinanceApi.getWebsocketSession(BinanceApi.java:644)
at com.webcerebrium.binance.api.BinanceApi.websocketDepth(BinanceApi.java:656)
at com.smartsoft.binanceTerminal.Test.test(Test.java:19)
at com.smartsoft.binanceTerminal.App.main(App.java:17)

UserDataStream disconnecting?

Even a couple of seconds after starting up the user web socket listener i found out that it does not processes order data sometimes. I am not receiving any errors. Infact, i am not even receiving any message at all.

Web Socket - No Output

I am trying to run:

		BinanceSymbol symbol = new BinanceSymbol("ETHBTC");
		Session session = (new BinanceApi()).websocketTrades(symbol, new BinanceWebSocketAdapterAggTrades() {
		    @Override
		    public void onMessage(BinanceEventAggTrade message) { 
		        System.out.println(message.toString());
		    }
		});
		try { Thread.sleep(5000); } catch (InterruptedException e) {}
		session.close();

But I don't get any output. There are no errors and the program never stop. Is this somehow my fault?

Get all prices return empty

Hi,

Today below problem occurred. Could you please help me investigate this?

System.out.println((new BinanceApi()).allPrices());

->
12:51:16.964 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - GET https://www.binance.com/api/v1/ticker/allPrices
12:51:18.974 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - Response: []
[]

Best Regards,

Cannot deserialize value of type `java.lang.Long` from String "9534.95000000"

Hi !

I got this error when I call BinanceApiRestClient.getCandlestickBars :
com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type java.lang.Long from String "9534.95000000": not a valid Long value
at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 17] (through reference chain: java.util.ArrayList[0]->com.binance.api.client.domain.market.Candlestick["closeTime"])

It seems that price value is going to closeTime

market buy price necessary?[question]

I am looking at the market buy method. If I use type = market, is it necessary to set both price and quantity? I mean like when we use the binance pc client, we have the option to press 25,50% etc and just click buy, and it will give is the markets current best price, without having to thinking about what the price is (i just notice the rise). Can you follow me, or is it too unclear? All the code for limit/market buy is the same, only the type differ, but maybe i misunderstood their works.

Basically, can I make the the buy say 50% of my funds, without pinging the price first. Thanks

ORDER_WOULD_TRIGGER_IMMEDIATELY not present in OrderRejectReason

We have exception in parsing WebSocket message using BinanceApi:

com.binance.api.client.exception.BinanceApiException: com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not deserialize value of type com.binance.api.client.domain.OrderRejectReason from String "ORDER_WOULD_TRIGGER_IMMEDIATELY": value not one of declared Enum instance names: [INSUFFICIENT_BALANCE, ACCOUNT_CANNOT_SETTLE, UNKNOWN_ACCOUNT, UNKNOWN_ORDER, DUPLICATE_ORDER, UNKNOWN_INSTRUMENT, ACCOUNT_INACTIVE, MARKET_CLOSED, PRICE_QTY_EXCEED_HARD_LIMITS, NONE] at [Source: {"e":"executionReport","E":NUMBER,"s":"BTCUSDT","c":"bnc17","S":"BUY","o":"STOP_LOSS_LIMIT","f":"GTC","q":"0.00237200","p":"6240.00000000","P":"6320.00000000","F":"0.00000000","g":-1,"C":"null","x":"REJECTED","X":"REJECTED","r":"ORDER_WOULD_TRIGGER_IMMEDIATELY","i":-1,"l":"0.00000000","z":"0.00000000","L":"0.00000000","n":"0","N":null,"T":1533755889379,"t":-1,"I":-1,"w":false,"m":false,"M":false,"O":-1,"Z":"0.00000000"}; line: 1, column: 236] (through reference chain: com.binance.api.client.domain.event.OrderTradeUpdateEvent["r"]) at com.binance.api.client.domain.event.UserDataUpdateEventDeserializer.getUserDataUpdateEventDetail(UserDataUpdateEventDeserializer.java:56) ~[binance-api-client-1.0.2-SNAPSHOT.jar:?] at com.binance.api.client.domain.event.UserDataUpdateEventDeserializer.deserialize(UserDataUpdateEventDeserializer.java:45) ~[binance-api-client-1.0.2-SNAPSHOT.jar:?] at com.binance.api.client.domain.event.UserDataUpdateEventDeserializer.deserialize(UserDataUpdateEventDeserializer.java:18) ~[binance-api-client-1.0.2-SNAPSHOT.jar:?] at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3798) ~[jackson-databind-2.8.8.jar:2.8.8] at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2842) ~[jackson-databind-2.8.8.jar:2.8.8] at com.binance.api.client.impl.BinanceApiWebSocketListener.onMessage(BinanceApiWebSocketListener.java:43) [binance-api-client-1.0.2-SNAPSHOT.jar:?] at okhttp3.internal.ws.RealWebSocket.onReadMessage(RealWebSocket.java:307) ~[okhttp-3.8.1.jar:?] at okhttp3.internal.ws.WebSocketReader.readMessageFrame(WebSocketReader.java:222) ~[okhttp-3.8.1.jar:?] at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.java:101) ~[okhttp-3.8.1.jar:?] at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.java:262) [okhttp-3.8.1.jar:?] at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:201) [okhttp-3.8.1.jar:?] at okhttp3.RealCall$AsyncCall.execute(RealCall.java:141) [okhttp-3.8.1.jar:?] at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) [okhttp-3.8.1.jar:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_131] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_131] at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]

ERROR: -1106, Parameter 'timeInForce' sent when not required.

When I try to place an order using the BinanceOrderType.MARKET I get the following error:

com.webcerebrium.binance.api.BinanceApiException: ERROR: -1106, Parameter 'timeInForce' sent when not required.
at com.webcerebrium.binance.api.BinanceRequest.read(BinanceRequest.java:260)
at com.webcerebrium.binance.api.BinanceApi.createOrder(BinanceApi.java:498)

If I place an order through BinanceOrderType.LIMIT there is no problem.

Websocket error: org.slf4j.helpers.MessageFormatter.arrayFormat

I am trying to run:

BinanceSymbol symbol = new BinanceSymbol("ETHBTC");
Session session = (new BinanceApi()).websocketDepth(symbol, new BinanceWebSocketAdapterDepth() {
    @Override
    public void onMessage(BinanceEventDepthUpdate message) {
        System.out.println(message.toString());
    }
});
try { Thread.sleep(5000); } catch (InterruptedException e) {}
session.close();

But I get this error:

com.webcerebrium.binance.api.BinanceApiException: Websocket error: org.slf4j.helpers.MessageFormatter.arrayFormat(Ljava/lang/String;[Ljava/lang/Object;)Lorg/slf4j/helpers/FormattingTuple;
at com.webcerebrium.binance.api.BinanceApi.getWebsocketSession(BinanceApi.java:631)
at com.webcerebrium.binance.api.BinanceApi.websocketDepth(BinanceApi.java:643)

I guess there is something wrong with the dependencies.

Any ideas ?

getMinNotional wrong

In BinanceExchangeSymbol.java:

public JsonObject getPriceFilter() {
    return filters.get("PRICE_FILTER");
}

public JsonObject getLotSize() {
    return filters.get("LOT_SIZE");
}

public JsonObject getMinNotional() {
    return filters.get("LOT_SIZE");
}

The last is wrong - it should be MIN_NOTIONAL.

The method cancelOrder(BinanceOrder) is undefined for the type BinanceOrder

I am trying to cancel an order using the example code:

BinanceSymbol symbol = new BinanceSymbol("ETHBTC");
BinanceOrder order = api.getOrder(symbol, 123456L);
System.out.println(order.cancelOrder(order));

But I get the error:

The method cancelOrder(BinanceOrder) is undefined for the type BinanceOrder

How to get all historical data from a specific asset?

i am wondering how to get all historical data from a specific asset from the start until the end. i am trying something like this with no success

   Exchange bitstamp = ExchangeFactory.INSTANCE.createExchange(BinanceExchange.class);
        MarketDataService marketDataService = bitstamp.getMarketDataService();
        List<CurrencyPair> list=bitstamp.getExchangeSymbols();
        list.stream().forEach(val-> System.out.println(val.toString()));
        List<Ticker> ticker = marketDataService.getTickers((Params) list.get(2));
        System.out.println(ticker.toString());

ERROR: -1013, Filter failure: LOT_SIZE

When I try to place an order I get this error:

com.webcerebrium.binance.api.BinanceApiException: ERROR: -1013, Filter failure: LOT_SIZE

How can I resolve this?

Websocket API depth with level doesn't work

Hi! binance-api version 1.0.9
I found an error with BinanceWebSocketAdapterDepth which you're using in BinanceApi.websocketDepth{level} methods. BinanceWebSocketAdapterDepth uses BinanceEventDepthUpdate which parses the event message from socket but response for @Depth{levels} is another than for @Depth and NullPointerExceptions are occured. I think you can make an another BinanceEventDepthUpdate and BinanceWebSocketAdapterDepth for using in websocketDepth methods.

withdraw is not working

Is the withdraw function working? Why would the amount is long instead of double? Besides long issue on the amount parameter, I tried to run and also got following errors

"msg":"{"code":-1105,"msg":"Parameter 'recvWindow' was was empty.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.