Question
How can I change the server time of Binance, one of the biggest cryptocurrency exchange, using the programming language Python?
Details
- I am using the python library `python-binance' to interact with Binance.
- When I typed the code below, you get the local time based on your location.
from binance.client import Client
from datetime import datetime
# client = Client('api_key' , 'api_secret') # Binance API key
raw_server_time = client.get_server_time()
server_time = datetime.fromtimestamp(raw_server_time['serverTime']/1000.0)
server_time
Since I am in France, the result is as follows:
>>> datetime.datetime(2020, 5, 23, 12, 49, 10, 13000)
- Even though I am in France, I would like to make Binance think that I am in the Eastern part of the USA (e.g. New York). So I have tried the requests library, supported in the python-binance library as below.
proxies = {
'http': 'http://168.169.146.12:8080'
}
# in the Client instantiation
client = Client(api_key, api_secret, {'proxies': proxies})
# or on an individual call
client.get_all_orders(symbol='BTCUSDT', requests_params={'proxies': proxies})
But I get the following error message.
>>> BinanceAPIException: APIError(code=-1021): Timestamp for this request was 1000ms ahead of the server's time.
You can find more detailed information about the code above in the documentation page of the python-binance library. The http server was found in the website free-proxy.cz. A screenshot of the list of New-York based proxies are also provided below.
