iqoptionapi icon indicating copy to clipboard operation
iqoptionapi copied to clipboard

Buy option not working anymore

Open redmiix24 opened this issue 5 years ago • 39 comments

yes the buy option is not working anymore, surely iqoption changed some parameters. Will troubleshoot the problem and come back here

Regards

redmiix24 avatar Dec 10 '19 17:12 redmiix24

so there is not the possibiliy to pass orders automatically ?????

Frank-prog-stack avatar Dec 11 '19 10:12 Frank-prog-stack

@Frank-prog-stack apparently iqoption changed something in their socket stream. Now the error in Python is : buy takes 5 arguments (6 was given)

redmiix24 avatar Dec 11 '19 12:12 redmiix24

@Frank-prog-stack apparently iqoption changed something in their socket stream. Now the error in Python is : buy takes 5 arguments (6 was given)

how to fix ??

dwighthalpert avatar Dec 11 '19 16:12 dwighthalpert

@Frank-prog-stack I have checked quickly this morning. I need time to know what is going on. Also some other threads are saying they changed it to XHR messages instead of WS. Will look into it when I have time. I developed separate project with @Lu-Yi-Hsun library. Now it seems that he cannot continue support it for free and I understand. So probably will do something on my own and release it here.

redmiix24 avatar Dec 11 '19 17:12 redmiix24

@redmiix24 Hope you find how to fix it. Please do a pull request once you've figured it out.

pavilion20bw avatar Dec 11 '19 23:12 pavilion20bw

Checking with Chrome DevTools, the traderoom application is definitely using XHR. The body of a trade request looks like {"category":"button_pressed","name":"traderoom_deal-call","value":1.0,"user_id":xxx,"group_id":147,"platform_id":9,"app_version":"1632.5.2413.release","device_id":"xxx","time":1576255163458,"parameters":{"asset_id":"5","balance_type":"4","expiration_time":"1576255200","instrument_type":"turbo","leverage_value":"1","order_type":"market"}}

On the other hand, other WS requests still work. So what gives?

lp1982 avatar Dec 13 '19 17:12 lp1982

@lp1982 I successfully send post request with "button_pressed" in Python and it returned code 200 however no call or put has been made because I know I need to make a function that put the server time in my request and I also need to make another function to calculate the expiration time.

Timesyn I can get it with socket but expiration I need to so how it's working , it seems a bit difficult for me. Anyhow I'm half way through .

Will share my code later

redmiix24 avatar Dec 13 '19 17:12 redmiix24

Isn't this just, for turbos,

get_expiration_time(int(self.api.timesync.server_timestamp),duration)

Defined as

def get_expiration_time(self, duration):
    exp = time.time()
    if duration >= 1 and duration <= 5:
        option = 3#"turbo"
        # Round to next full minute
        # datetime.datetime.now().second>30
        if (exp % 60) > 30:
            exp = exp - (exp % 60) + 60*(duration+1)
        else:
            exp = exp - (exp % 60)+60*(duration)

The Darth-Carrotpie code for the binaries is wrong though. I modified it as follows to work for 15-minute binaries (don't try it for greater times, I'm not sure it will give the correct option)

    elif duration > 5:
        option = 1#"binary"
        period = int(round(duration / 15))
        tmp_exp = exp - (exp % 60)  # nuima sekundes
        tmp_exp = tmp_exp - (tmp_exp % 3600)  # nuimam minutes
        j = 0
        while exp > tmp_exp + (j)*15*60:  # find quarter
            j = j+1
        quarter = tmp_exp + (j)*15*60
        if quarter - exp > 5*60:
            exp = quarter + (period-1)*15*60
        else:
            exp = quarter + period*15*60
    else:
        logging.error("ERROR get_expiration_time DO NOT LESS 1")
        exit(1)
    return exp, option

lp1982 avatar Dec 13 '19 19:12 lp1982

@ redmiix24 can I have your mail address please ?

Frank-prog-stack avatar Dec 14 '19 06:12 Frank-prog-stack

@Frank-prog-stack same username + gmail.com

redmiix24 avatar Dec 14 '19 07:12 redmiix24

Everyone can Pull request to fix this public version

Lu-Yi-Hsun avatar Dec 14 '19 08:12 Lu-Yi-Hsun

@lp1982 @Frank-prog-stack

only expiration time is not taken into consideration although its showing in my output

input

import requests
import json
import urllib3
import time
from websocket import create_connection



def get_expiration_time(self, duration):
    exp = time.time()
    if duration >= 1 and duration <= 5:
        #option = 3 #"turbo"
        # Round to next full minute
        # datetime.datetime.now().second>30
        if (exp % 60) > 30:
            exp = exp - (exp % 60) + 60*(duration+1)
            print int(exp)
        else:
            exp = exp - (exp % 60)+60*(duration)
            print int(exp)
            

ws = create_connection("wss://iqoption.com/echo/{randomnumber}/{randomnumber}/websocket")
result = ws.recv()
data = json.loads(result)
get_expiration_time(data["msg"],1)


url = 'https://event.iqoption.com/api/v1/events'

headers = {  'Host': 'event.iqoption.com',
             'Connection': 'keep-alive',
             'Content-Length': '1191',
             'X-Action': 'single',
             'Origin': 'https://iqoption.com',
             'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36',
             'Content-Type': 'application/json',
             'Accept': '*/*',
             'DNT': '1',
             'Referer': 'https://iqoption.com/traderoom',
             'Accept-Encoding': 'gzip}, deflate}, br',
             'Accept-Language': 'en-GB},en-US;q=0.8},en;q=0.6',
}              


payload =   {
    "category": "button_pressed",
    "name": "traderoom_deal-call",
    "value": 50,
    "user_id": XXXXXX,
    "group_id": XXX,
    "platform_id": 9,
    "app_version": "1632.5.2413.release",
    "device_id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "time": data["msg"],
    "parameters": {
      "asset_id": "77",
      "balance_type": "4",
      "expiration_time": get_expiration_time(data["msg"],1),
      "instrument_type": "turbo",
      "leverage_value": "1",
      "order_type": "market"
    }
  }


print payload

r = requests.post(url, data=json.dumps(payload), headers=headers)
print(r.content)

output

time : 1576312653177
expiration_time : 1576312740


{'category': 'button_pressed', 'platform_id': 9, 'app_version': '1632.5.2413.release', 'user_id': XXXXX, 'name': 'traderoom_deal-call', 'parameters': {'asset_id': '77', 'instrument_type': 'turbo', 'order_type': 'market', 'leverage_value': '1', 'balance_type': '4', 'expiration_time': None}, 'time': 1576312653177, 'group_id': XXX, 'value': 50, 'device_id': 'XXXXXXXXXXXXXXXXXXXXXXXXXX'}
{"code":200,"errors":[]}

as you can see 'expiration_time': None

anyone can try a fix ?

redmiix24 avatar Dec 14 '19 08:12 redmiix24

@redmiix24 your get_expiration_time doesnt return anything

zidokobik avatar Dec 14 '19 08:12 zidokobik

@zidokobik if you print it before its working however inside the json its not taking into consideration

redmiix24 avatar Dec 14 '19 08:12 redmiix24

Yeah, sorry, you're missing the end of the code as you didn't include the binaries part.

else:
    logging.error("ERROR get_expiration_time DO NOT LESS 1")
    exit(1)
return exp, option

lp1982 avatar Dec 14 '19 11:12 lp1982

@lp1982 fixed it and now there is expiration time , but still not executing anything.

I went back to @Lu-Yi-Hsun code and the error thrown was "late by 30 seconds"

I'm troubleshooting his expiration.py file where the function of get_expiration_time

Will update you soon

redmiix24 avatar Dec 14 '19 11:12 redmiix24

I just make a pull request that should fix it, unfortunately I was working with ver5.1 so .... things got rollback a bit

dwighthalpert avatar Dec 24 '19 17:12 dwighthalpert

@dwighthalpert thanks a lot brother

redmiix24 avatar Dec 24 '19 17:12 redmiix24

Here is the version which work correctly ???

Le 24 déc. 2019 19:02, "SamBee" [email protected] a écrit :

@dwighthalpert https://github.com/dwighthalpert thanks a lot brother

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/168?email_source=notifications&email_token=ANYHVIGE7LBFWEIOUPJBZ3LQ2I6CJA5CNFSM4JZCBKMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHTOCZI#issuecomment-568779109, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANYHVIH63V7LWKXBDXISNGLQ2I6CJANCNFSM4JZCBKMA .

Frank-prog-stack avatar Dec 24 '19 19:12 Frank-prog-stack

What are we supposed to learn to develop an entire Iq Option API like Lu-Yi-Hsun did? Can someone give me for example a training PDF? I know the Python language but I don't know anything about API development?

Le 24 déc. 2019 21:01, "EVERYDAY ON LINE" [email protected] a écrit :

Here is the version which work correctly ???

Le 24 déc. 2019 19:02, "SamBee" [email protected] a écrit :

@dwighthalpert https://github.com/dwighthalpert thanks a lot brother

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/168?email_source=notifications&email_token=ANYHVIGE7LBFWEIOUPJBZ3LQ2I6CJA5CNFSM4JZCBKMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHTOCZI#issuecomment-568779109, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANYHVIH63V7LWKXBDXISNGLQ2I6CJANCNFSM4JZCBKMA .

Frank-prog-stack avatar Dec 24 '19 19:12 Frank-prog-stack

I just make a pull request that should fix it, unfortunately I was working with ver5.1 so .... things got rollback a bit

Still the error is same,

Cannot purchase and option (the asset is not available at the moment)

I cloned your git and tried too, same op

vivekkairi avatar Dec 25 '19 05:12 vivekkairi

@vivekkairi Are you sure that the market is opening?

dwighthalpert avatar Dec 25 '19 05:12 dwighthalpert

@vivekkairi Are you sure that the market is opening?

Ya I can manually place order from browser

vivekkairi avatar Dec 25 '19 05:12 vivekkairi

@vivekkairi Did you try with OTC market? Ex: EURUSD-OTC

kkagill avatar Dec 25 '19 06:12 kkagill

@vivekkairi Did you try with OTC market? Ex: EURUSD-OTC

Ya it worked but what's OTC? I want to do Binary trading

vivekkairi avatar Dec 25 '19 06:12 vivekkairi

OTC market is for weekends & holidays. It is binary trading.

kkagill avatar Dec 25 '19 06:12 kkagill

@vivekkairi It's chrismas, Stock markets are closed, only otc markets are open

https://blog.iqoption.com/en/trading-schedule-during-the-holidays/

dwighthalpert avatar Dec 25 '19 06:12 dwighthalpert

@vivekkairi how can I program a whole IQ Option API like did Lu-Yi-Hsun. What are prerequisites and steps ? Help me with an advice please !!!

Le 25 déc. 2019 08:26, "dwighthalpert" [email protected] a écrit :

@vivekkairi https://github.com/vivekkairi It's chrismas, Stock markets are closed, only otc markets are open

https://blog.iqoption.com/en/trading-schedule-during-the-holidays/

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/168?email_source=notifications&email_token=ANYHVIBMXZSHXW2FD4A5ZA3Q2L4HZA5CNFSM4JZCBKMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHT67EY#issuecomment-568848275, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANYHVICXBEKBUTQN5NSF3LLQ2L4HZANCNFSM4JZCBKMA .

Frank-prog-stack avatar Dec 25 '19 07:12 Frank-prog-stack

@dwighthalpert Thanks for fixing buyv2! 截圖 2019-12-25 下午3 56 28

Everyone Merry Christmas :)

PoYuTsai avatar Dec 25 '19 07:12 PoYuTsai

@vivekkairi how can I program a whole IQ Option API like did Lu-Yi-Hsun. What are prerequisites and steps ? Help me with an advice please !!! Le 25 déc. 2019 08:26, "dwighthalpert" [email protected] a écrit : @vivekkairi https://github.com/vivekkairi It's chrismas, Stock markets are closed, only otc markets are open https://blog.iqoption.com/en/trading-schedule-during-the-holidays/ — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#168?email_source=notifications&email_token=ANYHVIBMXZSHXW2FD4A5ZA3Q2L4HZA5CNFSM4JZCBKMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHT67EY#issuecomment-568848275>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANYHVICXBEKBUTQN5NSF3LLQ2L4HZANCNFSM4JZCBKMA .

Even I'm new to these stuffs, it's majorly WS and XHR requests. Analyze them.

vivekkairi avatar Dec 25 '19 08:12 vivekkairi