I'm trying to build a very simple automated tool in Python to allow me to post orders on Binance. It's really to get the hang of Python while having a "goal" in mind, a finish line.
I'm using this great library and of one the basic things I want to do is find out if there is a time difference between my computer time and Binance server's.
I'm using, to this end, the get_server_time method. Both times are returned in EPOCH which is ok but there is a small time difference.
It's not a problem for me to pass orders or to keep on with my journey but I'd like to understand the reason behind it ; I'm curious to be thorough and understanding all of the ins and outs of this.
Here is my code:
# Get Server Time
def get_server_time():
ts = client.get_server_time()['serverTime']
server_time = datetime.utcfromtimestamp(ts / 1000).strftime('%Y-%m-%d %H:%M:%S')
return server_time
print(round(time.time()*1000))
print(client.get_server_time()['serverTime'])
# Check if computer time is the same as server time
if time.time()*1000 != client.get_server_time()['serverTime']:
print("There is a problem in time sync.")
else:
print("Your computer time matches server time.")
And it returns a small time difference, as seen here:
1639147119502
1639147120114
There is a problem in time sync.
I've tried syncing my computer clock through various ways (the most famous you see on Google ; fiddling with the Time Service of Windows10).
Is there any reasons behind this you all could think of ?
Thanks a lot in advance ;)