futures_klines 工作与 get_klines 出现错误 未读取所有发送的参数;读“3”参数但已发送“4”
我正在使用 Python 中的 Binance 客户端来获取 K 线数据,该数据对于期货调用来说效果很好,但我需要使用期货中不可用的其他交易品种的现货数据。有什么想法如何解决这个问题吗?在线示例看起来是相同的,但由于某种原因它说只允许 3 个参数而不是 4 个。这三个是什么?
from binance.client import Client
binance = Client(api_key=binance_api_key, api_secret=binance_api_secret)
df_check=check_binanceklines(symbol=symbol)
def check_binanceklines(symbol='BTCUSDT',interval='1m',limit=60,since="1 hour ago UTC"):
klines = binance.futures_klines(symbol=symbol,interval={'1m':Client.KLINE_INTERVAL_1MINUTE}[interval],since=since,limit=limit)
***# issue below!***
klines = binance.get_klines(symbol=symbol,interval={'1m':Client.KLINE_INTERVAL_1MINUTE}[interval],since=since,limit=limit)
Traceback (most recent call last):
File "binance-test.py", line 254, in <module>
df_check=check_binanceklines(symbol=symbol) # get 1 hour ago, every minute
File "binance-test.py", line 29, in check_binanceklines
klines = binance.get_klines(symbol=symbol,interval= {'1m':Client.KLINE_INTERVAL_1MINUTE}[interval],since=since,limit=limit)
File "C:\Users\lee\AppData\Local\Programs\Python\Python38\lib\site- packages\binance\client.py", line 868, in get_klines
return self._get('klines', data=params, version=self.PRIVATE_API_VERSION)
File "C:\Users\lee\AppData\Local\Programs\Python\Python38\lib\site- packages\binance\client.py", line 371, in _get
return self._request_api('get', path, signed, version, **kwargs)
File "C:\Users\lee\AppData\Local\Programs\Python\Python38\lib\site- packages\binance\client.py", line 334, in _request_api
return self._request(method, uri, signed, **kwargs)
File "C:\Users\lee\AppData\Local\Programs\Python\Python38\lib\site-packages\binance\client.py", line 315, in _request
return self._handle_response(self.response)
File "C:\Users\lee\AppData\Local\Programs\Python\Python38\lib\site-packages\binance\client.py", line 324, in _handle_response
raise BinanceAPIException(response, response.status_code, response.text)
binance.exceptions.BinanceAPIException: APIError(code=-1104): Not all sent parameters were read; read '3' parameter(s) but was sent '4'.
I'm using the Binance client in python to get klines data which works fine for the futures call but I need to use the spot data for other symbols not available on futures. any ideas how to fix this? the online examples look to be the same but for some reason it says only 3 params not 4 allowed. what are the 3?
from binance.client import Client
binance = Client(api_key=binance_api_key, api_secret=binance_api_secret)
df_check=check_binanceklines(symbol=symbol)
def check_binanceklines(symbol='BTCUSDT',interval='1m',limit=60,since="1 hour ago UTC"):
klines = binance.futures_klines(symbol=symbol,interval={'1m':Client.KLINE_INTERVAL_1MINUTE}[interval],since=since,limit=limit)
***# issue below!***
klines = binance.get_klines(symbol=symbol,interval={'1m':Client.KLINE_INTERVAL_1MINUTE}[interval],since=since,limit=limit)
Traceback (most recent call last):
File "binance-test.py", line 254, in <module>
df_check=check_binanceklines(symbol=symbol) # get 1 hour ago, every minute
File "binance-test.py", line 29, in check_binanceklines
klines = binance.get_klines(symbol=symbol,interval= {'1m':Client.KLINE_INTERVAL_1MINUTE}[interval],since=since,limit=limit)
File "C:\Users\lee\AppData\Local\Programs\Python\Python38\lib\site- packages\binance\client.py", line 868, in get_klines
return self._get('klines', data=params, version=self.PRIVATE_API_VERSION)
File "C:\Users\lee\AppData\Local\Programs\Python\Python38\lib\site- packages\binance\client.py", line 371, in _get
return self._request_api('get', path, signed, version, **kwargs)
File "C:\Users\lee\AppData\Local\Programs\Python\Python38\lib\site- packages\binance\client.py", line 334, in _request_api
return self._request(method, uri, signed, **kwargs)
File "C:\Users\lee\AppData\Local\Programs\Python\Python38\lib\site-packages\binance\client.py", line 315, in _request
return self._handle_response(self.response)
File "C:\Users\lee\AppData\Local\Programs\Python\Python38\lib\site-packages\binance\client.py", line 324, in _handle_response
raise BinanceAPIException(response, response.status_code, response.text)
binance.exceptions.BinanceAPIException: APIError(code=-1104): Not all sent parameters were read; read '3' parameter(s) but was sent '4'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以使用以下参数调用
binance.client.Client.get_klines()
:因此
since
是无效参数。请改用startTime
或endTime
。这些参数要求以毫秒为单位的时间戳。下面是一个工作示例,它提供了过去 60 分钟(包括当前分钟)的信息:输出:
binance.client.Client.get_klines()
can be called with the following parameters:Therefore
since
is an invalid parameter. UsestartTime
orendTime
instead. These parameters ask for a timestamp in milliseconds. Here is a working example which gives you the last 60 minutes (including the current minute):Output: