[英]Error while calling function in Python3.5
我正在嘗試運行IqoptionAppi的存儲庫
當我嘗試運行命令時: api.getcandles(1,60,25)
發生以下錯誤:
api.getcandles(1,60,25)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __call__() takes 3 positional arguments but 4 were given
我已經看過這個功能,是這樣的:
from iqoptionapi.ws.chanels.base import Base
class GetCandles(Base):
"""Class for IQ option candles websocket chanel."""
# pylint: disable=too-few-public-methods
name = "candles"
def __call__(self, active_id, duration, amount):
"""Method to send message to candles websocket chanel.
:param active_id: The active/asset identifier.
:param duration: The candle duration (timeframe for the candles).
:param amount: The number of candles you want to have
"""
data = {"active_id": active_id,
"duration": duration,
"chunk_size": 25,
"from": self.api.timesync.server_timestamp - (duration * amount),
"till": self.api.timesync.server_timestamp}
self.send_websocket_request(self.name, data)
該存儲庫說它可以在Python 2.7
工作,但是我嘗試在Python 3.5
上安裝它,除了上述問題,它仍然可以工作。 指導我到底想念的地方。
這里的問題是最新的PyPI版本的 iqoptionapi / ws / chanels / candles.py模塊與Github的master
分支版本不同,並且沒有amount
參數(似乎等於2
)。
在master
分支中:
def __call__(self, active_id, duration, amount):
...
"from": self.api.timesync.server_timestamp - (duration * amount),
...
在0.5
版本中:
def __call__(self, active_id, duration):
...
"from": self.api.timesync.server_timestamp - (duration * 2),
...
因此,我們可以忽略此參數(完全不要傳遞它,並使用默認值2
)或使用git
安裝master
分支版本
> pip install --upgrade git+https://github.com/n1nj4z33/iqoptionapi.git@master
由於版本沒有更改,因此我們在這里使用--upgrade
標志,因此我們強制重新安裝軟件包。
或另一個選擇:您可以要求回購所有者發布新版本並將其發布在PyPI上 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.