Giter Site home page Giter Site logo

binance-exchange / binance-java-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joaopsilva/binance-java-api

838.0 838.0 627.0 442 KB

binance-java-api is a lightweight Java library for the Binance API, supporting synchronous and asynchronous requests, as well as event streaming using WebSockets.

License: MIT License

Java 100.00%

binance-java-api's People

Contributors

2pd avatar aldov500 avatar amirulzin avatar benalexau avatar big-andy-coates avatar brintal avatar davemx avatar eugenpodaru avatar gizmochief7 avatar gtofig avatar gungoren avatar hoota avatar joaopsilva avatar jomires avatar mcourteaux avatar mdvx avatar mironbalcerzak avatar nilswx avatar nomailforme avatar oleksiilogvin avatar putraxor avatar puzatin avatar sanektnt avatar tobcar avatar tonyskulk avatar truonghatsts avatar vaultdeveloper avatar xezon avatar xnetz avatar yaniferhaoui 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

binance-java-api's Issues

How to get all pairs and then get level 1 quote

Hi,

My apologies I could't find a forum to post this question to.

I want to get a list of all trading pairs on Binance and then for each of these pairs I'd like to subscribe to get 3 min candlestick data (really just latest quote price)

Thanks, Jason

How to create new orders in a transactional fashion?

According to https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#general-api-information HTTP 504 denotes an unknown state. Requests may have succeeded or failed.

How can one safely invoke https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#new-order--trade given that it may return HTTP 504 and we never get back a clientOrderId with which to query whether the order had actually succeeded?

I see that we can send clientOrderId into a request but the specification does not explain the format of legal IDs, nor what happens if the ID we send in is already taken. Are clientOrderIds unique per client? Or are they global IDs across the entire system?

So to reiterate the question: how can we safely create an order in a transactional fashion where we are guaranteed to know whether the order was successfully in the end?

Can not change user because httpclient is in static field

I have two users with api key and secret, I couldn't change the user because of this line:

BinanceApiServiceGenerator.java

private static OkHttpClient.Builder httpClient = new OkHttpClient.Builder();

I changed this to:

    public static <S> S createService(Class<S> serviceClass, String apiKey, String secret) {
        OkHttpClient.Builder httpClient = new OkHttpClient.Builder();

And now it is working!

ClassCastException on onAllMarketTickersEvent stream

I am getting a class cast exception when using the market ticker event stream.

Caused by: java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to com.binance.api.client.domain.event.AllMarketTickersEvent

Is anyone else having this issue? Code below for reference.

mWebSocketClient.onAllMarketTickersEvent(new BinanceApiCallback<List<AllMarketTickersEvent>>() {
    @Override
    public void onResponse(List<AllMarketTickersEvent> events) throws BinanceApiException {
        Log.d(TAG, events.get(0).toString());
    }
});

account.balances not refreshing?

I made a buy on the binance web site

and I have a timer that is call

account.balances.forEach { balance ->
            if (balance.free != "0.00000000") {
            ...
            }
        }

but this is not refreshing, how can I refresh my account and balances after a buy?

Exception in thread "OkHttp Dispatcher" com.binance.api.client.exception.Binance

I run into this exception very often when using the web socket listeners. What is the correct way to deal with failing sockets? If I understand correctly there is no way to ignore the exception, but just accept the closure of the socket and ultimatively the thread.

But is there any smart way to restart the listener? I don't know which listeners closed. Do I need to resort to thread naming trickery and a thread watch dog?

Exception in thread "OkHttp Dispatcher" com.binance.api.client.exception.Binance
ApiException: java.io.EOFException
        at com.binance.api.client.impl.BinanceApiWebSocketListener.onFailure(Bin
anceApiWebSocketListener.java:39)
        at okhttp3.internal.ws.RealWebSocket.failWebSocket(RealWebSocket.java:54
3)
        at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:203
)
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:141)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.io.EOFException
        at okio.RealBufferedSource.require(RealBufferedSource.java:60)
        at okio.RealBufferedSource.readByte(RealBufferedSource.java:73)
        at okhttp3.internal.ws.WebSocketReader.readHeader(WebSocketReader.java:1
13)
        at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.
java:97)
        at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.java:262)
        at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:201
)
        ... 5 more

the minimal quantity interval?

The binance's trading rule only gives the min Amount of every coin, not give the min amount interval. Do someone know the min amount interval of every coin or where can I find it? Thanks a lot!

For example, the min amount for ETH/BTC is 0.001ETH, what about its min interval? still 0.001?

OkHttpClient.Builder refers to the missing type Interceptor

Getting an error when try to use this:

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method interceptors() from the type OkHttpClient.Builder refers to the missing type Interceptor
The method addInterceptor(Interceptor) from the type OkHttpClient.Builder refers to the missing type Interceptor

at com.binance.api.client.impl.BinanceApiServiceGenerator.createService(BinanceApiServiceGenerator.java:38)
at com.binance.api.client.impl.BinanceApiRestClientImpl.<init>(BinanceApiRestClientImpl.java:37)
at com.binance.api.client.BinanceApiClientFactory.newRestClient(BinanceApiClientFactory.java:58)
at binance.BinanceScapper.main(BinanceScapper.java:13)

StackOverflowError with the AuthenticationInterceptor after several hours of swing trading

Twice now I have received this StackOverflowError while doing normal trading. The Project is set up with a key and secret in live trading environment. Each time I was running a swing trading strategy on ONE_MINUTE intervals. It was executing a Buy when the error occurred. The first time it failed was after running for 128 minutes and the second time was after 162 minutes. Each of those windows contained numerous successful buy and sell trades. This was not caught and the whole program crashed. Any thoughts as to a patch the error so that the program will recover? You will notice the infinite loop being called into the following file. I have provide the full stacktrace of the StackOverflowError cutting off the part after where the pattern is oviously repeating. You will also notice the okhttp3 lib actually starts to repeat before the interceptor starts to loop with it.

Full Stacktrace:

Exception in thread "OkHttp Dispatcher" java.lang.StackOverflowError
	at java.lang.System.getProperty(System.java:714)
	at sun.security.action.GetPropertyAction.run(GetPropertyAction.java:84)
	at sun.security.action.GetPropertyAction.run(GetPropertyAction.java:49)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.security.ssl.Debug.getBooleanProperty(Debug.java:184)
	at sun.security.ssl.SSLSessionImpl.<init>(SSLSessionImpl.java:767)
	at sun.security.ssl.ClientHandshaker.serverHello(ClientHandshaker.java:664)
	at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:206)
	at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1026)
	at sun.security.ssl.Handshaker.process_record(Handshaker.java:961)
	at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
	at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
	at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:281)
	at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:251)
	at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:151)
	at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:192)
	at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:121)
	at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:100)
	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at com.binance.api.client.security.AuthenticationInterceptor.intercept(AuthenticationInterceptor.java:55)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at com.binance.api.client.security.AuthenticationInterceptor.intercept(AuthenticationInterceptor.java:55)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at com.binance.api.client.security.AuthenticationInterceptor.intercept(AuthenticationInterceptor.java:55)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at com.binance.api.client.security.AuthenticationInterceptor.intercept(AuthenticationInterceptor.java:55)
        .
        .
        .

Start of the repeating pattern:

at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
	at com.binance.api.client.security.AuthenticationInterceptor.intercept(AuthenticationInterceptor.java:55)

crash on DepositHistory

com.binance.api.client.exception.BinanceApiException: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "msg" (class com.binance.api.client.domain.account.DepositHistory), not marked as ignorable (2 known properties: "success", "depositList"])

at [Source: okhttp3.ResponseBody$BomAwareReader@327dc41; line: 1, column: 9] (through reference chain: com.binance.api.client.domain.account.DepositHistory["msg"])
at com.binance.api.client.impl.BinanceApiServiceGenerator.executeSync(BinanceApiServiceGenerator.java:64)

BinanceApiRestClient.getAllPrices() returns symbol "123456"

When I invoke BinanceApiRestClient.getAllPrices() most of the tickers I get back are okay, but I am consistently getting back:

TickerPrice[symbol=123456,price=0.00030000]

which doesn't make any sense. Is this some sort of test data that someone forgot to remove?

I also see it if I request HTTP GET https://www.binance.com/api/v1/ticker/allPrices so this is affecting all clients.

Desync, Timestamp for this request was 1000ms ahead of the server's time

Java version :
C:\Program Files\Java\jdk1.8.0_152\bin>java.exe -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

Quite a common error, here is the snippet of code I am using to compare the time between my computer and binance API :

package laby.java;

import com.binance.api.client.BinanceApiClientFactory;
import com.binance.api.client.BinanceApiRestClient;

public class Main {

    private static final String APIKEY = "key";
    private static final String APISECRET = "secret";

    public static void main(String[] args) {

        BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(APIKEY, APISECRET);
        BinanceApiRestClient client = factory.newRestClient();


        while (true) {
            // Checking time between
            Long clientTime = java.lang.System.currentTimeMillis();
            Long serverTimerTime = client.getServerTime();
            System.out.println("Times : client[" + clientTime + "] server[" + serverTimerTime + "] diff[" + (serverTimerTime - clientTime) + "]");
        }
    }

}

Results:

Times : client[1514132675503] server[1514132675624] diff[121]
Times : client[1514132677246] server[1514132676946] diff[-300]
Times : client[1514132678541] server[1514132677226] diff[-1315]
Times : client[1514132678820] server[1514132677505] diff[-1315]
Times : client[1514132679098] server[1514132677788] diff[-1310]
Times : client[1514132679420] server[1514132678111] diff[-1309]
Times : client[1514132679729] server[1514132678414] diff[-1315]
Times : client[1514132680007] server[1514132678698] diff[-1309]
Times : client[1514132680293] server[1514132678983] diff[-1310]
Times : client[1514132680579] server[1514132679265] diff[-1314]
Times : client[1514132680858] server[1514132679544] diff[-1314]
Times : client[1514132681137] server[1514132679823] diff[-1314]
Times : client[1514132681417] server[1514132680107] diff[-1310]

Process finished with exit code 1

Registry setting is set to update time each ten minutes, it doesn't change anything:

image

For your information, I updated the clock time before each attempt :
image

I am loosing around 1.2 seconds somewhere, and I don't know where

BinanceApiException on getCandlestickBars

val candlestickBars = client.getCandlestickBars(symbol.toUpperCase(), interval)

https://github.com/binance-exchange/binance-java-api/blob/master/src/test/java/com/binance/api/examples/CandlesticksCacheExample.java

I just wanted to test this code on my android device. but got this exception

com.binance.api.client.exception.BinanceApiException: com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not construct instance of java.lang.Long from String value ("0.09763700"): not a valid Long value
at [Source: okhttp3.ResponseBody$BomAwareReader@ee6ad3c; line: 1, column: 17] (through reference chain: java.util.ArrayList[0]->com.binance.api.client.domain.market.Candlestick["closeTime"])

binace-java-api doesn't pass through chosen newClientOrderId from the NewOrder object when placing a new order.

@headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER)
@post("/api/v3/order")
Call newOrder(@query("symbol") String symbol, @query("side") OrderSide side, @query("type") OrderType type,
@query("timeInForce") TimeInForce timeInForce, @query("quantity") String quantity, @query("price") String price,
@query("stopPrice") String stopPrice, @query("icebergQty") String icebergQty,
@query("recvWindow") Long recvWindow, @query("timestamp") Long timestamp);

The field clientOrderIdIs not passed through from a newOrder object to the binance API. This means we cannot set our own clientOrderId as specified by the APi documentation:

binance rest api doc:

newClientOrderId STRING NO A unique id for the order. Automatically generated if not sent.

Please add @query("newClientOrderId") String newClientOrderId

Filter failure LOT_SIZE

I have 0.93 xlm. I want to sell it with xlmeth.

I tried sell market with quantity 0.9 but give me Filter failure LOT_SIZE

ETH/USD chart

I want to draw a chart from the last (24H or 1 week) lets say ethereum values
How can I do this with binance API?

Optimization: Jackson ObjectMapper instance shouldn't be constructed on each WebSocket Message

Related code:

@Override
public void onMessage(WebSocket webSocket, String text) {
ObjectMapper mapper = new ObjectMapper();
try {
T event = mapper.readValue(text, eventClass);
callback.onResponse(event);
} catch (IOException e) {
throw new BinanceApiException(e);
}
}

ObjectMapper is fairly expensive to create, and especially for Android, this can create quite the heavy pressure on the GC and memory usage, considering it is created on every socket message.

Therefore I kindly suggest to either:

  1. Delegate the instance construction to the BinanceApiWebSocketListener class constructor so we can allow more flexibility in creating ObjectMapper.
  2. And maybe create the ObjectMapper instance if it wasn't given and hold it locally as a private reference in a secondary constructor. This can maintain the current library compatibility.

The same issue also present in UserDataUpdateEventDeserializer

public <T> T getUserDataUpdateEventDetail(String json, Class<T> clazz) {
ObjectMapper mapper = new ObjectMapper();
try {
return mapper.readValue(json, clazz);
} catch (IOException e) {
throw new BinanceApiException(e);
}
}

I can help creating a pull request later to fix this, but if you guys have any other idea or other implementations in mind, then please feel free to share.

Documentation

Excuse me but where can be found documentation about methods / interfaces and so on... :?

BinanceApiException

Hi,
thank you very much for sharing this good and usefull code.

I'have just started with java some months ago and i'm trying run some of the examples, everything goes well except for the classes where apikey and secret is needed. I'm filling the arguments apikey and secret with my numbers and after running I get this error:

Exception in thread "main" com.binance.api.client.exception.BinanceApiException: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "updateTime" (class com.binance.api.client.domain.account.Account), not marked as ignorable (8 known properties: "canTrade", "takerCommission", "balances", "sellerCommission", "buyerCommission", "makerCommission", "canWithdraw", "canDeposit"])
at [Source: okhttp3.ResponseBody$BomAwareReader@a9cd3b1; line: 1, column: 164] (through reference chain: com.binance.api.client.domain.account.Account["updateTime"])
at com.binance.api.client.impl.BinanceApiServiceGenerator.executeSync(BinanceApiServiceGenerator.java:60)
at com.binance.api.client.impl.BinanceApiRestClientImpl.getAccount(BinanceApiRestClientImpl.java:139)
at com.binance.api.client.impl.BinanceApiRestClientImpl.getAccount(BinanceApiRestClientImpl.java:144)
at com.binance.api.examples.AccountBalanceCacheExample.main(AccountBalanceCacheExample.java:84)
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "updateTime" (class com.binance.api.client.domain.account.Account), not marked as ignorable (8 known properties: "canTrade", "takerCommission", "balances", "sellerCommission", "buyerCommission", "makerCommission", "canWithdraw", "canDeposit"])
at [Source: okhttp3.ResponseBody$BomAwareReader@a9cd3b1; line: 1, column: 164] (through reference chain: com.binance.api.client.domain.account.Account["updateTime"])
at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:62)
at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:855)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1083)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1389)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1367)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:266)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:125)
at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1575)
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1183)
at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:32)
at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:23)
at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:119)
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:218)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:180)
at com.binance.api.client.impl.BinanceApiServiceGenerator.executeSync(BinanceApiServiceGenerator.java:52)
... 3 more

Can you help me to find the reason?

Thank you!

BinanceApiCallback must have an onFailure() method

The BinanceApiAsyncRestClient is useless if the caller of the async method isn't notified in case of error.

The BinanceApiCallback interface must have an onFailure() method so that the caller can be notified of errors.

Weird candlestick events

val candlesticks = client.getCandlestickBars("NEOETH", CandlestickInterval.WEEKLY)

this is just gave me a crash, an Exception.. (maybe some json parse error /float to long?/)

client.onCandlestickEvent("ethbtc", CandlestickInterval.ONE_MINUTE) { response -> Logger.E(response) }

this is working like a charm, but when uses this

client.onCandlestickEvent("xvgeth", CandlestickInterval.ONE_MINUTE) { response -> Logger.E(response) }

the responses is not in 1 minutes, it is random minutes :( (from 1 minutes to 40 minutes, weird)

+1: how to stop the events?

API Broken after Binance system upgrade?

I tried to run the example code provided in this library. When I run the AllMarketTickersExample.java class I get a bunch of exceptions and everything worked just fine before the Binance system upgrade. seems like it is something on their end, cause the same error pops up when trying to runt he other examples?

`public class AllMarketTickersExample {

public static void main(String[] args) {
BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance();
BinanceApiWebSocketClient client = factory.newWebSocketClient();

client.onAllMarketTickersEvent(event -> {
  System.out.println(event);
});

}
}`

Exception in thread "OkHttp Dispatcher" com.binance.api.client.exception.BinanceApiException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at com.binance.api.client.impl.BinanceApiWebSocketListener.onFailure(BinanceApiWebSocketListener.java:51) at okhttp3.internal.ws.RealWebSocket.failWebSocket(RealWebSocket.java:543) at okhttp3.internal.ws.RealWebSocket$2.onFailure(RealWebSocket.java:208) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:148) at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.ssl.Alerts.getSSLException(Unknown Source) at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source) at sun.security.ssl.Handshaker.fatalSE(Unknown Source) at sun.security.ssl.Handshaker.fatalSE(Unknown Source) at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source) at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source) at sun.security.ssl.Handshaker.processLoop(Unknown Source) at sun.security.ssl.Handshaker.process_record(Unknown Source) at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source) at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:281) at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:251) at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:151) at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:192) at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:121) at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:100) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135) ... 4 more Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.validator.PKIXValidator.doBuild(Unknown Source) at sun.security.validator.PKIXValidator.engineValidate(Unknown Source) at sun.security.validator.Validator.validate(Unknown Source) at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source) at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source) at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source) ... 31 more Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source) at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source) at java.security.cert.CertPathBuilder.build(Unknown Source) ... 37 more

Feature Change Request: Be able to override the ToStringStyle used by the overloaded toString() methods

I see roughly 30'ish instances currently of the use ToStringStyle.SHORT_PREFIX_STYLE used int the various toString() override implementations I'd like to override with ToStringStyle.JSON_STYLE.
example from CandlestickEvent.java

  @Override
  public String toString() {
    return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
        .append("eventType", eventType)
        .append("eventTime", eventTime)
        .append("symbol", symbol)
        ...
        .append("isBarFinal", isBarFinal)
        .toString();
  }

I like to use various JSON parsers such as google's GSON library to read and write the toString() outputs to file for logging or to be picked up by the database filereader. I might want to pass the JSON string via REST call to a web viewer as a JSON String. Also there are times when i want to pretty print them to console. i.e.

{
  "symbol": "ETHUSDT",
  "orderId": 12345678,
  "clientOrderId": "smoD6joHgLUGlowNcZQcSf",
  "transactTime": 1511234502823
}

If I currently pass the output in, its not in a standard JSON format and a malformed parser exception happens. I could create a data adapter to put it in a good JSON format but that fairly cumbersome for every object. I can just locally change the ToStringStyle.SHORT_PREFIX_STYLE to ToStringStyle.JSON_STYLE in every file that currently uses it but that would be difficult to maintain local dependency builds with updates upstream.

What I propose would be to have a non final, override-able constant in a Constants class. i.e.
public static ToStringStyle TO_STRING_BUILDER_STYLE = ToStringStyle.SHORT_PREFIX_STYLE; where the previous toString() example would refer to that constant. i.e.

  @Override
  public String toString() {
    return new ToStringBuilder(this, TO_STRING_BUILDER_STYLE)
        .append("eventType", eventType)
        .append("eventTime", eventTime)
        .append("symbol", symbol)
        ...
        .append("isBarFinal", isBarFinal)
        .toString();
  }

where I could set it to ToStringStyle.JSON_STYLE if needed and this would not break backward compatibility if someone is expecting the toString() to be in SHORT_PREFIX_STYLE. Another option might be to start a user configuration file that sets this value or an initial programmatic binance-java-api configuration call where i could override the default setting for this value.

All in all i'd much rather use this library as a jar dependency without having to custom change and build it my self. Thought?

Just for fun, I'll provide my JSON pretty console print methods I have in a Utils class.

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
  /**
   * Convert a JSON string to pretty print version
   * @param jsonString
   * @return
   */
  public static String toPrettyJsonFormat(String jsonString) {
      String prettyJson = jsonString;
      JsonParser parser = new JsonParser();
      JsonElement jsonElement = parser.parse(jsonString);
      if(jsonElement != null) {
        JsonObject json = jsonElement.getAsJsonObject();
        Gson gson = new GsonBuilder().setPrettyPrinting().create();
        prettyJson = gson.toJson(json);
      }
      return prettyJson;
  }
  
  /**
   * Convert a JSON string to pretty print version.
   * This assumes you expect the provided object to output a json
   * string when the toString method is called
   * @param obj
   * @return
   */
  public static String toPrettyJsonFormat(Object obj) {
      return toPrettyJsonFormat(String.valueOf(obj));
  }
  
  /**
   * Convert a JSON string to pretty print version and print to console.
   * This assumes you expect the provided object to output a json
   * string when the toString method is called
   * @param obj
   */
  public static void printPrettyJsonFormat(Object obj) {
      System.out.println(toPrettyJsonFormat(obj));
  }

Error : "Trust anchor for certification path not found."

Hello,

I have try on several Android devices and it seems I have the same problem. I got the exception "Trust anchor for certification path not found".

Stacktrace : com.binance.api.client.exception.BinanceApiException: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
at com.binance.api.client.impl.BinanceApiCallbackAdapter.onFailure(BinanceApiCallbackAdapter.java:45)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$2.run(ExecutorCallAdapterFactory.java:79)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
at dalvik.system.NativeStart.main(Native Method)
Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:410)
at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:281)
at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:251)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:151)
at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:192)
at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:121)
at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:100)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at com.binance.api.client.security.AuthenticationInterceptor.intercept(AuthenticationInterceptor.java:55)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:848)
Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:282)
at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:202)
at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:612)
at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:406)
at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:281)
at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:251)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:151)
at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:192)
at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:121)
at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:100)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at com.binance.api.client.security.AuthenticationInterceptor.intercept(AuthenticationInterceptor.java:55)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:848)
Caused by: java.security.cert.CertPathValidatorException: Trust anchor for

My code :
BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(APIKEY_, APISECRET_); BinanceApiAsyncRestClient binance = factory.newAsyncRestClient(); binance.ping((BinanceApiCallback) -> { Show(BinanceApiCallback.toString()); });

Same problem with the not Async client.

The same problem was found here : ccxt/ccxt#882
And seems to be revolved here : ccxt/ccxt#882 (comment)

I also found this problem in common issues : https://developer.android.com/training/articles/security-ssl.html#CommonProblems

Hope I can be fixed easily and fastly 🥇

PS : This error was in the master : joaopsilva#3

PKIX path building failed

Hello. I'm trying to listen websocket notifications from binance by this simple code:

public class WebSocketReader implements Runnable {
    private final String[] tickers;
    private final BinanceApiWebSocketClient client = BinanceApiClientFactory
            .newInstance().newWebSocketClient();

    private BlockingQueue<DepthEvent> queue;

    public WebSocketReader(String[] tickers, BlockingQueue<DepthEvent> queue) {
        this.tickers = tickers;
        this.queue = queue;
    }

    @Override
    public void run() {
        Arrays.stream(tickers).forEach(t -> client.onDepthEvent(t,
                response -> {
                    queue.add(response);
                }));
    }
}

ExecutorService executor = Executors.newCachedThreadPool();
BlockingQueue<DepthEvent> queue = new ArrayBlockingQueue<DepthEvent>(10000, true);
executor.submit(new WebSocketReader(new String[]{"ethbtc"}, queue));

and this code throws exception on my mac and works nice on linux:

Exception in thread "OkHttp Dispatcher" com.binance.api.client.exception.BinanceApiException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at com.binance.api.client.impl.BinanceApiWebSocketListener.onFailure(BinanceApiWebSocketListener.java:51)
at okhttp3.internal.ws.RealWebSocket.failWebSocket(RealWebSocket.java:543)
at okhttp3.internal.ws.RealWebSocket$2.onFailure(RealWebSocket.java:208)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:148)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1917)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:301)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:295)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1471)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:212)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:936)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:871)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1043)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1343)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1371)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1355)
at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:281)
at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:251)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:151)
at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:192)
at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:121)
at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:100)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)
... 4 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
at sun.security.validator.Validator.validate(Validator.java:260)
at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1453)
... 30 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:145)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:131)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382)
... 36 more

Unrecognized field "updateTime"

Exception in thread "main" com.binance.api.client.exception.BinanceApiException: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "updateTime" (class com.binance.api.client.domain.account.Account), not marked as ignorable (8 known properties: "canTrade", "takerCommission", "balances", "sellerCommission", "buyerCommission", "makerCommission", "canWithdraw", "canDeposit"])
at [Source: okhttp3.ResponseBody$BomAwareReader@7722c3c3; line: 1, column: 164] (through reference chain: com.binance.api.client.domain.account.Account["updateTime"])
at com.binance.api.client.impl.BinanceApiServiceGenerator.executeSync(BinanceApiServiceGenerator.java:60)
at com.binance.api.client.impl.BinanceApiRestClientImpl.getAccount(BinanceApiRestClientImpl.java:139)
at com.binance.api.client.impl.BinanceApiRestClientImpl.getAccount(BinanceApiRestClientImpl.java:144)

How to shut down non-daemon threads?

If I run:

BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(API_KEY, API_SECRET);
BinanceApiRestClient client = factory.newRestClient();
TickerStatistics price = client.get24HrPriceStatistics("BTCUSDT");
System.out.println("Price: " + price.getLastPrice());

The JVM never shuts down. How do I shut down the non-daemon threads?

exception when to get orderbook

Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: okhttp3.ResponseBody$BomAwareReader@4cb23097; line: 1, column: 2]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1586)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:521)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:450)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddValue(ReaderBasedJsonParser.java:1823)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:708)
at com.fasterxml.jackson.databind.ObjectReader._initForReading(ObjectReader.java:358)
at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1558)
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1183)
at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:32)
at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:23)
at com.binance.api.client.impl.BinanceApiServiceGenerator.getBinanceApiError(BinanceApiServiceGenerator.java:69)
at com.binance.api.client.impl.BinanceApiServiceGenerator.executeSync(BinanceApiServiceGenerator.java:56)
... 5 more

User data stream premature closing

Hi, I am using the provided example (UserDtaStremExample) to listen to order statuses for a specific user. But when I open a user data stream I can only get order statuses for a few minutes, then it stops reporting orders. According to binance documentation the user data stream should remain open for 60 minutes unless a keep alive message is sent. I experimented sending keep alive requests every 2 minutes but I still get the same problem.

Questions about Stream API

Looking at https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md which your API mirrors,

  1. What is the meaning of "Is the buyer the market maker?" I understand the concept of a maker vs taker, but what is the meaning of "the market maker" and what does this change for us if the value is true?

  2. How can an aggregated trade event contain a single price/quantity value when it spans multiple trades? Are the trades guaranteed to be at the same price? Similarly, how can you only have a single trade-time across multiple trades?

getExchangeInfo causes GenericSignatureFormatError

Exception in thread "main" java.lang.reflect.GenericSignatureFormatError: Signature Parse error: Expected Field Type Signature Remaining input: +Lcom/binance/api/client/exception/BinanceApiException; at sun.reflect.generics.parser.SignatureParser.error(SignatureParser.java:124) at sun.reflect.generics.parser.SignatureParser.parseFieldTypeSignature(SignatureParser.java:297) at sun.reflect.generics.parser.SignatureParser.parseFieldTypeSignature(SignatureParser.java:283) at sun.reflect.generics.parser.SignatureParser.parseTypeSignature(SignatureParser.java:485) at sun.reflect.generics.parser.SignatureParser.parseReturnType(SignatureParser.java:627) at sun.reflect.generics.parser.SignatureParser.parseMethodTypeSignature(SignatureParser.java:577) at sun.reflect.generics.parser.SignatureParser.parseMethodSig(SignatureParser.java:171) at sun.reflect.generics.repository.ConstructorRepository.parse(ConstructorRepository.java:55) at sun.reflect.generics.repository.ConstructorRepository.parse(ConstructorRepository.java:43) at sun.reflect.generics.repository.AbstractRepository.<init>(AbstractRepository.java:74) at sun.reflect.generics.repository.GenericDeclRepository.<init>(GenericDeclRepository.java:48) at sun.reflect.generics.repository.ConstructorRepository.<init>(ConstructorRepository.java:51) at sun.reflect.generics.repository.MethodRepository.<init>(MethodRepository.java:46) at sun.reflect.generics.repository.MethodRepository.make(MethodRepository.java:59) at java.lang.reflect.Method.getGenericInfo(Method.java:102) at java.lang.reflect.Method.getGenericInfo(Method.java:61) at java.lang.reflect.Executable.getGenericParameterTypes(Executable.java:284) at java.lang.reflect.Method.getGenericParameterTypes(Method.java:282) at com.fasterxml.jackson.databind.introspect.AnnotatedMethod.getParameterType(AnnotatedMethod.java:145) at com.fasterxml.jackson.databind.introspect.AnnotatedWithParams.getParameter(AnnotatedWithParams.java:86) at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector._addCreators(POJOPropertiesCollector.java:473) at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.collectAll(POJOPropertiesCollector.java:313) at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.getPropertyMap(POJOPropertiesCollector.java:287) at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.getProperties(POJOPropertiesCollector.java:170) at com.fasterxml.jackson.databind.introspect.BasicBeanDescription._properties(BasicBeanDescription.java:164) at com.fasterxml.jackson.databind.introspect.BasicBeanDescription.findProperties(BasicBeanDescription.java:239) at com.fasterxml.jackson.databind.deser.BasicDeserializerFactory._findCreatorsFromProperties(BasicDeserializerFactory.java:346) at com.fasterxml.jackson.databind.deser.BasicDeserializerFactory._constructDefaultValueInstantiator(BasicDeserializerFactory.java:330) at com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.findValueInstantiator(BasicDeserializerFactory.java:255) at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:214) at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:137) at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:411) at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:349) at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:264) at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244) at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142) at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:477) at com.fasterxml.jackson.databind.ObjectReader._prefetchRootDeserializer(ObjectReader.java:1938) at com.fasterxml.jackson.databind.ObjectReader.<init>(ObjectReader.java:189) at com.fasterxml.jackson.databind.ObjectMapper._newReader(ObjectMapper.java:658) at com.fasterxml.jackson.databind.ObjectMapper.readerFor(ObjectMapper.java:3506) at retrofit2.converter.jackson.JacksonConverterFactory.responseBodyConverter(JacksonConverterFactory.java:60) at retrofit2.Retrofit.nextResponseBodyConverter(Retrofit.java:330) at retrofit2.Retrofit.responseBodyConverter(Retrofit.java:313) at retrofit2.ServiceMethod$Builder.createResponseConverter(ServiceMethod.java:736) at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:169) at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170) at retrofit2.Retrofit$1.invoke(Retrofit.java:147) at com.sun.proxy.$Proxy0.getExchangeInfo(Unknown Source) at com.binance.api.client.impl.BinanceApiRestClientImpl.getExchangeInfo(BinanceApiRestClientImpl.java:56)

Correct way to split trading symbols?

Hello,

in my App I want to calculate a Dollar-price for every coin by getting all trading pairs and matching them up.
Let's say I want to get the worth of IOTA in dollar. I get IOTA/ETH and continue to get ETH/USD. Now I can calculate IOTA/USD and display it.

The problem is this:
Calling getAllPrices() results in symbols like ETHBTC, WAVESBTC or NEBLBTC.

There is no indicator where to split the two coins. Since symbols can be different length, I can't just split them in the center.

How can I split them correctly?

getDepositAddress

When using the getDepositAddress function, I get "api not exist". Does Binance support this function?

Maven version numbering not following standards

The version number used for this project is set for a release version, but a number of code changes have been made under the same released version number.

Ideally a single commit should be considered the "released" version whenever you feel is apt, and all in between development versions should be labeled snapshot. The way it is now, it would not play nice with a Maven Repo.

The change I would suggest it to make the version 1.0.1-SNAPSHOT, where the snapshot qualifier is used to indicate it is a development build. This version scheme works properly with the various Maven Repositories I have used.

If you want to read up a bit more on Maven's number scheme, you can see it here:
https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm#MAVEN8855

Request: test endpoint feature

Place a test order
Creates and validates a new order but does not send it into the exchange at "/api/v3/order/test" endpoint

Timestamp for this request was 1000ms ahead of the server's time.

Hi everyone,

I am trying make an android app that uses this library. I compiled .jar file and successfully added to my android studio project.

My problem is that on some devices, when I try to make an API call, an exception like above had been throwed. Same code working on some emulator, not working on physical devices.

Any ideas? 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.