Lu-Yi-Hsun / iqoptionapi

IQ Option API
372 stars 289 forks source link

Cannot buy for binary option in version 3.9 #110

Open jackynguyen93 opened 5 years ago

jackynguyen93 commented 5 years ago

After update new version, the buy function didn't work anymore. It returned success but didn't have any order in iqoption. I have checked function buy_multi but it also did not work. Please check this important issue. Thanks

glira commented 5 years ago

To me work in real account but not work more in practice please we need of help! buy example

from iqoptionapi.stable_api import IQ_Option
import logging
import time
logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
I_want_money=IQ_Option("user","pass")
goal="EURUSD"
print("get candles")
print(I_want_money.get_candles(goal,60,111,time.time()))
Money=2
ACTIVES="EURUSD"
ACTION="call"#or "put"
expirations_mode=1
balance_mode = I_want_money.get_balance_mode()
print(balance_mode)
idbuy = I_want_money.buy(Money,ACTIVES,ACTION,expirations_mode)
print (idbuy)

The output is

...
PRACTICE
2019-09-11 00:21:56,448 {"msg": {"time": 1568172115.639, "direction": "call", "act": 1, "type": "turbo", "exp": 1568172180, "price": 2}, "name": "buyV2", "request_id": ""}
2019-09-11 00:21:56,729 {"name":"timeSync","msg":1568172116650}
2019-09-11 00:21:56,761 {"name":"option-rejected","microserviceName":"binary-options","msg":{"index":64982359,"option_id":5632861306,"reason":"no_money","amount":2000000,"currency":"BRL","enrolled_amount":490000,"balance_type_id":1,"balance_id":243005874,"option_type":"turbo","option_type_id":3,"user_id":50536774,"open_time":1568172116,"expiration_time":1568172180,"profit_percent":177,"direction":"call","value":1.104985,"active_id":1,"platform_id":0,"tournament_id":null,"user_group_id":184}}
2019-09-11 00:21:56,790 {"name":"buyComplete","request_id":"","msg":{"isSuccessful":false,"message":["Insufficient funds for this transaction."],"result":{"request_id":null}}}
(False, None)
Lu-Yi-Hsun commented 5 years ago

@glira @jackynguyen93 PLEASE UPDATE TO v3.9.1 because IQOPTION update the server

!!importance!! before v3.9.1 version the buy() api without add ""user_balance_id":int(self.api.profile.balance_id)" it try to buy in REAL MODE(REAL MONEY)!!! without call change_balance() API

https://github.com/Lu-Yi-Hsun/iqoptionapi/commit/72428a0dca797100a6200b8e99c7937b77fa9d2e#diff-3a83549416a011249baa2c026484f498R39

jackynguyen93 commented 5 years ago

Yeah, thanks @Lu-Yi-Hsun figured out this issue.

jackynguyen93 commented 5 years ago

Hi @Lu-Yi-Hsun , Still cannot order. After buy it returns (False, None)

Lu-Yi-Hsun commented 5 years ago

ok i check now

Lu-Yi-Hsun commented 5 years ago

@jackynguyen93 I can work! try the code

from iqoptionapi.stable_api import IQ_Option
import logging
import random
import time
from datetime import datetime,timedelta
import logging
logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
I_want_money=IQ_Option("email","password")

I_want_money.change_balance("PRACTICE")
                        #MODE: "PRACTICE"/"REAL"

Money=10
ACTIVES="EURUSD"
ACTION="call"#or "put"
expirations_mode=1

print(I_want_money.buy(Money,ACTIVES,ACTION,expirations_mode))
glira commented 5 years ago

To me work fine after update! thank Lu-Yi-Hsun !

jackynguyen93 commented 5 years ago

@glira which python version you are using. I'm using python 3.7 and I got the issue with strftime('%s'). @Lu-Yi-Hsun It's work after I top up my practice balance. lol. Thank you so much

jackynguyen93 commented 5 years ago

@glira @Lu-Yi-Hsun does check_win function work ? It does not work for me :(

glira commented 5 years ago

@jackynguyen93 i am use 3.6 3.5 use this check_win_v2