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 545 forks source link

How can i get the Profit % return of an active? #20

Open adel02 opened 7 years ago

adel02 commented 7 years ago

How can I get the profit % return of an active for different expiration time? like profit return of EURUSD in 60sec turbo ---> 85% profit return of USDJPY in 15min binary ---> 79%

Thanks

adel02 commented 7 years ago

I have found it, here is how

add : in line 55 in client.py

if message["name"] == "api_option_init_all_result":
            self.api.api_option_init_all_result = message["msg"]

in line 47 in api.py api_option_init_all_result = []

in line 263 in api.py

def get_api_option_init_all(self):

        data = json.dumps(dict(name="api_option_init_all",
                               msg=""))
        self.websocket.send(data)

And now to access the result :

self.api.api_option_init_all_result = None
self.api.get_api_option_init_all()
while self.api.api_option_init_all_result == None :
        pass
self.profit = (100.0-self.api.api_option_init_all_result["result"]["turbo"]["actives"][str(self.active)]["option"]["profit"]["commission"])/100.0

to get an idea about the data recieved, here is the file :

json.txt

Hope it will be useful

shiundu commented 7 years ago

@adel02 I have tried this but its kinda confusing, any help?!

MadOne199 commented 7 years ago

I will try to show in another language - Java.

We send a request via the websocket -

// api_option_init_all to get percentage returns // {"msg":"","name":"api_option_init_all"} System.out.println("WSS SENT : " +"{\"msg\":\"\",\"name\":\"api_option_init_all\"}"); wst.sendText("{\"msg\":\"\",\"name\":\"api_option_init_all\"}"); // ...

When we receive the response to the websocket and verify it relates to that request, we pull out the info.

if(objt.getString("name").equalsIgnoreCase("api_option_init_all_result")){

// Update all the ForexPairs percentage (profit percentage = 100 - commission) // Note the percentage will match you account type ie increased % for VIP account

            try {
                arryIntForexPairsTurboPercent[1] = 100 - objt.getJSONObject("msg").getJSONObject("result").getJSONObject("turbo").getJSONObject("actives").getJSONObject("1").getJSONObject("option").getJSONObject("profit").getInt("commission");
            } catch (Exception e) {
                // TODO Auto-generated catch block
                //e.printStackTrace();
            }

            try {
                arryIntForexPairsTurboPercent[2] = 100 - objt.getJSONObject("msg").getJSONObject("result").getJSONObject("turbo").getJSONObject("actives").getJSONObject("2").getJSONObject("option").getJSONObject("profit").getInt("commission");
            } catch (Exception e) {
                // TODO Auto-generated catch block
                //e.printStackTrace();
            }

etc for all pairs - 1,2,3,etc

This is just an example that may help some of you see what is wanted. Good luck

pavilion20bw commented 4 years ago

@adel02 how did you know it was api_option_init_all? I'm observing websocket in chrome, but there is no related send/receive msgs. Did you click on any button or something?