n1nj4z33 / iqoptionapi

IQ Option API 4.x (Python 2.7) The project is obsolete and is not supported because of problems with access to IQ Options in Russia
120 stars 559 forks source link

Time out while try to buy order #87

Open MongkonEiadon opened 6 years ago

MongkonEiadon commented 6 years ago

I've sent the request with

{
  "name": "buyV2",
  "msg": {
    "price": 1,
    "act": 76,
    "exp": 1521911963,
    "type": "turbo",
    "direction": "call",
    "time": 1521911903.05
  }
}

but the result is respond

{
  "name": "buyComplete",
  "request_id": "",
  "msg": {
    "isSuccessful": false,
    "message": ["Time for purchasing options is over, please try again later."],
    "result": { "request_id": null }
  }
}

I've checked the timeout is in the future,

remarco commented 6 years ago

how you get this respond???

MongkonEiadon commented 6 years ago

I've tried to use another extensions for google chrome -- "Simple Websocket Client" then i open secured connection by send

{"name":"ssid","msg":"your ssid token after login"}

then this channel will be authorized websocket channel, so when you send any request the response will sent back from iqoption immediately.

for this problem i've solved by this implementation in buyV2.py

class Buyv2(Base):
    """Class for IQ option buy websocket chanel."""
    # pylint: disable=too-few-public-methods

    name = "buyV2"

    def __call__(self, price, active, option, direction):
        """Method to send message to buyv2 websocket chanel.

        :param price: The buying price.
        :param active: The buying active.
        :param option: The buying option.
        :param direction: The buying direction.
        """

        exp = int(self.api.timesync.expiration_timestamp)
        #Round to next full minute
        if datetime.datetime.now().second > 30:
            exp = exp - (exp % 60) + 60
        else:
            exp = exp - (exp % 60)

        data = {
            "price": price,
            "act": active,
            "exp": exp,
            "type": option,
            "direction": direction,
            "time": self.api.timesync.server_timestamp
        }

        self.send_websocket_request(self.name, data)

image

remarco commented 6 years ago

check timestamp. your exp time is less then minute. you must buy not in current minute but for next minute.