简体   繁体   中英

Error while calling function in Python3.5

I am trying to run the repository of IqoptionAppi

While I am trying to run the command: api.getcandles(1,60,25)
the following error occured:

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

I have seen the function and is something like this:

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)

The repository says it works in Python 2.7 but I tried installing it on Python 3.5 , it still worked except the above issue. Guide me where exactly I missed.

Problem here is that iqoptionapi/ws/chanels/candles.py module from latest PyPI version differs from Github 's master branch version and there is no amount parameter (it seems to be equal to 2 ).

In master branch:

def __call__(self, active_id, duration, amount):
    ...
    "from": self.api.timesync.server_timestamp - (duration * amount),
    ...

In 0.5 version:

def __call__(self, active_id, duration):
    ...
    "from": self.api.timesync.server_timestamp - (duration * 2),
    ...

So we can ignore this parameter (do not pass it at all and use default value 2 ) or install master branch version using git like

> pip install --upgrade git+https://github.com/n1nj4z33/iqoptionapi.git@master

Here we are using --upgrade flag since version didn't change so we force to reinstall package.

Or another option: you can ask repo owner to release new version and publish it on PyPI .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM