Code Monkey home page Code Monkey logo

Comments (7)

SungMinHong avatar SungMinHong commented on July 17, 2024 6

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.

JamesBarnes88 avatar JamesBarnes88 commented on July 17, 2024 1

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.

joaopsilva avatar joaopsilva commented on July 17, 2024

@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.

Ptitlaby avatar Ptitlaby commented on July 17, 2024

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.

JamesBarnes88 avatar JamesBarnes88 commented on July 17, 2024

@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.

fromjgor avatar fromjgor commented on July 17, 2024

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.

joaopsilva avatar joaopsilva commented on July 17, 2024

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)

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.