1

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.

11
  • I believe you are providing self as a first argument. When calling a class member method, python does it for you. Commented Jun 26, 2018 at 9:58
  • @Sianur But I am not using it while calling the function you can see it in my example. Commented Jun 26, 2018 at 10:00
  • Post the lines where you create the api object Commented Jun 26, 2018 at 10:07
  • @miindlek ok see this: api = IQOptionAPI("iqoption.com", "[email protected]", "Passwordhidden"), This is the way I have create the object. Commented Jun 26, 2018 at 10:10
  • well, i've installed it locally and there are only 2 parameters (except self): active_id, duration Commented Jun 26, 2018 at 10:33

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Afer updating, I am getting the error: TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.