Comments (7)
I just solve this problem using getServerTime() and gap time
for example
before
@Override
public Account getAccount() {
return getAccount(BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis());
}
after
@Override
public Account getAccount() {
long start = System.currentTimeMillis();
long serverTime = this.getServerTime();
long end = System.currentTimeMillis();
long gap = end - start;
return getAccount(BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, serverTime + gap);
}
But It is need 1 weight more When call the method.
If weight is important I will make static time variable and just call only one getServerTime().
I hope this way help you. : )
from binance-java-api.
I put a PR up for this #11. Its been working for a couple days so I think its safe. Not sure if its the best implementation though. Check it out if you want.
from binance-java-api.
@JamesBarnes88 many thanks for your PR, I'll review it in the upcoming days. The idea looks good, and it does solve the "problem", although I'm afraid it also hides away the fact that the client time is not ntp synchronised, as it should. This can have some consequences when reading out times returned by the API.
from binance-java-api.
The thing is, even after manually synchronizing with a NTP server, the error is still there. And it's always around 1200 ms :<
from binance-java-api.
@joaopsilva Hey thanks for some clarification around the problem. Didn't know about NTP and SNTP before this. My question is if we use an NTPClient or SNTPClient implementation should this set my system time to sync with binance's server? Reading their api document it doesn't say that they use a specific ntp server. So the time may be managed by them.
So what if I also needed to sync with a different exchange's server while running both apps simultaneously? Maybe I misunderstood how that part of NTP works. Sorry for all the questions.
from binance-java-api.
Thanks @Ptitlaby for useful example. I have tested it on my client and my results were different.
Even if I got similar issue with 1sec delay while using candlesticks streaming:
Times : client[1516051832127] server[1516051833724] diff[1597]
Times : client[1516051833886] server[1516051834042] diff[156]
Times : client[1516051834189] server[1516051834349] diff[160]
Times : client[1516051834499] server[1516051834664] diff[165]
Times : client[1516051834812] server[1516051834973] diff[161]
Times : client[1516051835121] server[1516051835280] diff[159]
Times : client[1516051835428] server[1516051835583] diff[155]
Times : client[1516051835729] server[1516051835884] diff[155]
Times : client[1516051839406] server[1516051839572] diff[166]
...
from binance-java-api.
Closing as this issue is only related to local machines with an unsynchronized clock. In any case, there's a workaround, as mentioned by @SungMinHong .
from binance-java-api.
Related Issues (20)
- Using multi thread to stream OneSymbol in each thread or using one thread to stream many symbols
- No trading fees when on tesent
- InvalidFormatException when using getQuotePrecision
- Deprecated API Endpoints HOT 2
- Binance API suddenly stops working HOT 2
- Can I use Ipv6 for my API key ?
- Average price absent
- Timestamp for this request was 1000ms ahead of the server's time. HOT 1
- issue getting mixed candlestick
- NewOCO execution failed HOT 2
- 🚨 Looking for maintainers HOT 7
- TRAILING_DELTA missing in FilterType HOT 9
- Not a margin account HOT 1
- Gradle: Could not find com.github.binance-exchange:binance-java-api:master-SNAPSHOT. HOT 2
- Question: how to close the websocket connection? HOT 1
- Be able to change the base url
- onCandlestickEvent timeout after 3-4 days
- getAllAssets() not working
- I don't receive any response bei webSocketClient onUserDataUpdateEvent!!
- Is this library not beeing updated anymore?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from binance-java-api.