daroczig / binancer

An R client to the Public Rest API for Binance.
https://daroczig.github.io/binancer
53 stars 57 forks source link

Timestamp error #6

Closed YsoSirius closed 6 years ago

YsoSirius commented 6 years ago

I would like to add some functionality to the package, but somehow I'm only allowed to make 1 request to the API. I have to restart R in order to access it again.

key <-  "xx"
secret <- "xxx"
binance_credentials(key, secret)

## The first request works fine
binance_account()
## The second throws an error
binance_balances()

Error in eval(jsub, SDenv, parent.frame()) : object 'free' not found

The binance_balances function obviously gets stuck with the binance_account function. It throws the following timestamp error:

binance_account()

1: -1021 Timestamp for this request was 1000ms ahead of the server's time.

Actually, I found some solutions by analyzing it :) If you include a Sys.sleep(2)just before the query() in the binance_query function, it runs! But makes the code slower. If you adapt the timestamp function to this, it runs faster. timestamp <- function() { as.character(round(as.numeric(Sys.time()) * 1e3)-2000) }

The code runs obviously too fast and is ahead of time ;)

daroczig commented 6 years ago

Unfortunately, I cannot reproduce this problem :(

Are you using the most recent dev version of the package? Can you reproduce this after installing the package and in a clean R session (eg not via load_all or similar). Also, can you please check if the time is in sync on your computer?

YsoSirius commented 6 years ago

Yes, i was using the most recent version and although I was using clear sessions, the problem appeared several times.

But now on a different computer, I am also not able to reproduce it. It works fine on this one.

If it was my pc being out of sync, this issue can be closed. Ill try it again and keep you updated.

daroczig commented 6 years ago

Thanks, let me know what you find

YsoSirius commented 6 years ago

I cannot reproduce the error on the original PC. Everything works as expected. Obviously it was just a temporary problem.

Thanks a lot!