【发布时间】:2018-06-26 09:55:27
【问题描述】:
我正在尝试运行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 上安装它,除了上述问题外它仍然有效。引导我到我错过的地方。
【问题讨论】:
-
我相信您将 self 作为第一个参数。当调用一个类的成员方法时,python会为你做。
-
@Sianur 但是我在调用函数时没有使用它,您可以在我的示例中看到它。
-
发布您创建 api 对象的行
-
@miindlek 好的,看到这个:
api = IQOptionAPI("iqoption.com", "name@email.com", "Passwordhidden"),这就是我创建对象的方式。 -
好吧,我本地安装了,只有2个参数(
self除外):active_id,duration
标签: python python-3.x python-2.x