Lu-Yi-Hsun / iqoptionapi

IQ Option API
373 stars 287 forks source link

Sample "buy_order" for EURUSD #63

Open keinbuck opened 5 years ago

keinbuck commented 5 years ago

Can someone please give me an example for buying EURUSD as forex. See below for how I tried, but it ends in an infinite loop... Thank you guys in advance!

instrument_type="forex" instrument_id="EURUSD" side="buy"#sell type="market"#limit amount=10 limit_price=0#for limit ,if you choose market this not work, leverage=20#you can get more information in get_available_leverages() stop_lose_price=1.12# take_profit_price=1.16#

check,order_id=I_want_money.buy_order(instrument_type,instrument_id,side,type,amount,limit_price,leverage,stop_lose_price,take_profit_price)

Lu-Yi-Hsun commented 5 years ago

@keinbuck

i check what happen now

Lu-Yi-Hsun commented 5 years ago

@keinbuck

1. updat to Version 3.5

i fix the bug

2. check leverage Available

if your leverage is not Available you will happen this

sample code can work 2018/12/11

from iqoptionapi.stable_api import IQ_Option
I_want_money = IQ_Option("email", "password")
instrument_type="forex"
instrument_id="EURUSD"
side="buy"#sell
type="market"#limit
amount=10
limit_price=0#for limit ,if you choose market this not work,

leverage=200#you can get more information in get_available_leverages()
#^^^^^^^^^^^^^

stop_lose_price=1.12#
take_profit_price=1.16#
check,order_id=I_want_money.buy_order(instrument_type,instrument_id,side,type,amount,limit_price,leverage,stop_lose_price,take_profit_price)
keinbuck commented 5 years ago

Thank you for the fast reply... So the way i used the Code was correct?! Will try tomorrow with version 3.5. The lerverage in my example was available (20) for EURUSD.

Lu-Yi-Hsun commented 5 years ago

@keinbuck you need use "get_available_leverages()" check ""available leverage"" in sample code work in "200"

keinbuck commented 5 years ago

Thats what i did and Response was [20, 30]. Why 200 in your example?

Lu-Yi-Hsun commented 5 years ago

@keinbuck

sample for check available leverages

from iqoptionapi.stable_api import IQ_Option
I_want_money = IQ_Option("email", "password")
instrument_type="forex"
instrument_id="EURUSD"
print(I_want_money.get_available_leverages(instrument_type,instrument_id))

return

(True, {'instrument_type': 'forex', 'group_id': 1, 'leverages': [{'active_id': 1, 'unregulated': [200, 300, 500, 1000], 'unregulated_default': 300, 'regulated': [200, 300, 500, 1000], 'regulated_default': 300}]})

so only [200, 300, 500, 1000] available can use

keinbuck commented 5 years ago

In my case (Europe) just 20 and 30 is available...

Lu-Yi-Hsun commented 5 years ago

ok,try v3.5

keinbuck commented 5 years ago

Thanks!!!!