Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buy position does not work any more? #55

Open
EVAZA opened this issue Oct 9, 2017 · 7 comments
Open

Buy position does not work any more? #55

EVAZA opened this issue Oct 9, 2017 · 7 comments

Comments

@EVAZA
Copy link

EVAZA commented Oct 9, 2017

IQ Option seems changed their API. The current code does not work any more... Have anyone a solution?

@kanXuT
Copy link

kanXuT commented Oct 11, 2017

They added (or req. now) another params in buyV2:
skey - is stored in profile
user_balance_id - not sure if it's required but I added that and works fine

@milteven12
Copy link

milteven12 commented Oct 11, 2017

Hello @kanXuT , please, could you explain what should I do?
My current code is:
captura eurusd

PS: How can I get the skey and user_balance_id?
I tried print (api.profile.skey) but the output is None.

@kanXuT
Copy link

kanXuT commented Oct 12, 2017

Sorry not using this api and not famiiar with Python, so this is just where you can look for:
you need update buyv2.py ad add something like this:

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

And if skey and balance_id is not set/deffined, you need fill them up first from profile message ;)

@iQBotProject
Copy link

what we should to do exactly

@iQBotProject
Copy link

@kanXuT i try a version of api have skey and balance difined and the property in profil and i add self.__balance_id = None

profile.py

from iqoptionapi.ws.objects.base import Base


class Profile(Base):
    """Class for IQ Option Profile websocket object."""

    def __init__(self):
        super(Profile, self).__init__()
        self.__name = "profile"
        self.__skey = None
        self.__balance = None
        self.__balance_id = None
        
    @property
    def skey(self):
        """Property to get skey value.

        :returns: The skey value.
        """
        return self.__skey

    @skey.setter
    def skey(self, skey):
        """Method to set skey value."""
        self.__skey = skey

    @property
    def balance(self):
        """Property to get balance value.

        :returns: The balance value.
        """
        return self.__balance

    @balance.setter
    def balance(self, balance):
        """Method to set balance value."""
        self.__balance = balance

    @property
    def balance_id(self):
        """Property to get balance_id value.

        :returns: The balance_id value.
        """
        return self.__balance_id

    @balance_id.setter
    def balance_id(self, balance):
        """Method to set balance_id value."""
        self.__balance_id = balance_id

buyV2.py

from iqoptionapi.ws.chanels.base import Base


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.
        """
        data = {"price": price,
                "act": active,
                "exp": self.api.timesync.expiration_timestamp,
                "type": option,
                "direction": direction,
                "time": self.api.timesync.server_timestamp, 
                "skey": self.api.profile.skey, 
                "user_balance_id": self.api.profile.balance_id
               }

        self.send_websocket_request(self.name, data)

always buy not happened
i think skey and balance_id is always None

@milteven12
Copy link

@yesamine , just a comment: I have the same version, you don't need to modify the call function to:
def call(self, price, active, option, direction,skey,user_balance_id)
?

The thing is, skey and user_balance_id aren't 'None', if you see the log when it connect to the server you will se the values there but I don't know how to retrieve it.

@iQBotProject
Copy link

now i tested the iqoptionbot in TEST mode work good and trade
and i see skey and balance_id in loge file
the probleme this robot not working with other methods like TBL , TBH , ... and have many issues (candles and market ... )

but buy (call , put) work fin thats mean i miss somthing in my simple buy code

import time
from iqoptionapi.api import IQOptionAPI

api = IQOptionAPI("iqoption.com", "myemail@example.com", "mypass")

api.connect()
time.sleep(1)

balance = api.profile.balance
time.sleep(1)
print (balance)

api.setactives([1, 2])
time.sleep(1)

api.subscribe('tradersPulse')
reslt = api.buy(1, 1, "turbo", "call")
time.sleep(2)
print reslt 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants