joaopsilva / binance-java-api

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

Balance data is not updated after a while #45

Closed LexProfi closed 3 years ago

LexProfi commented 3 years ago

Good day! Please help - I am using the following code in my program:

factory = BinanceApiClientFactory.newInstance(apiKey, apiSecret);
restClient = factory.newRestClient();
webSocketClient = factory.newWebSocketClient();
listenKey = restClient.startUserDataStream();
account = restClient.getAccount();

Then I run the following code at regular intervals:

assetBalances = account.getBalances();
prices = restClient.getAllPrices();

After a few passes, I no longer receive updated balance data. That is, my code is executed normally, it does not give any errors, but the data on balances is not up to date. After restarting the program, the data is updated normally for some time. With what it can be connected?

sf202020sf commented 3 years ago

What was the Solution?

LexProfi commented 3 years ago

What was the Solution?

Not sure if my problem is solved - I'm watching for now. I assume that the point is that when I initialized the object, I was executing the code: account = restClient.getAccount(); then with some frequency: assetBalances = account.getBalances(); Analyzing the code, I came to the conclusion that the account object also needs to be updated with some frequency. At the moment, I request anew in each period account from restClient.getAccount() - while everything says that the problem is solved