Bar*_*rry 12 python datetime cryptoapi binance-api-client
我正在编写一些 Python 代码来使用 Binance API 创建订单:
from binance.client import Client
client = Client(API_KEY, SECRET_KEY)
client.create_order(symbol='BTCUSDT',
recvWindow=59999, #The value can't be greater than 60K
side='BUY',
type='MARKET',
quantity = 0.004)
Run Code Online (Sandbox Code Playgroud)
不幸的是我收到以下错误消息:
"BinanceAPIException: APIError(code=-1021): Timestamp for this request was 1000ms ahead of the server's time."
Run Code Online (Sandbox Code Playgroud)
我已经检查了币安服务器时间和本地时间之间的差异(以毫秒为单位):
import time
import requests
import json
url = "https://api.binance.com/api/v1/time"
t = time.time()*1000
r = requests.get(url)
result = json.loads(r.content)
print(int(t)-result["serverTime"])
OUTPUT: 6997
Run Code Online (Sandbox Code Playgroud)
看来60000的recvWindow还是不够用(但也可能不会超过60K)。我仍然遇到同样的错误。有人知道我该如何解决这个问题吗?
提前谢谢了!
归档时间: |
|
查看次数: |
18377 次 |
最近记录: |