python-binance icon indicating copy to clipboard operation
python-binance copied to clipboard

BinanceAPIException: APIError(code=-1021): Timestamp for this request is not valid.

Open laurent101 opened this issue 9 years ago • 3 comments

Hi,

I ended up with having my signed requests rejected due to an invalid timestamp!

Anyone experienced the same issue?

Thanks

laurent101 avatar Sep 23 '17 21:09 laurent101

I am, on this line order = client.get_my_trades(symbol=symbol)

but on this line it works prices = client.get_ticker()

badjano avatar Dec 17 '17 23:12 badjano

Sorry, didn´t see the other issue

badjano avatar Dec 18 '17 00:12 badjano

This is my solution for timestamps issue. The code made equal windows time to binance server time.

from binance.client import Client client = Client('api_key', 'api_secret') import time import win32api gt = client.get_server_time() aa = str(gt) bb = aa.replace("{'serverTime': ","") aa = bb.replace("}","") gg=int(aa) ff=gg-10799260 uu=ff/1000 yy=int(uu) tt=time.localtime(yy) win32api.SetSystemTime(tt[0],tt[1],0,tt[2],tt[3],tt[4],tt[5],0)

"The integer 10799260 for adjusting time zone and fine tuning for miliseconds."

nadirdogan avatar Feb 28 '18 22:02 nadirdogan