last Version:2.1.1
This API is Diligent development!!
Please Read Document
last update:2018/7/21
Version 2.1.1
- fix reconnect register stream problem
- fix checkwin reconnect
- check connect
- reconnect
Version 2.1
- Add heartbeat request for keep connect
- !!reimplement!! realtime candel for candle "size"
- rewrite README.md realtime candle
- fix realtime candel data problem
Version 2.0
- Forex
- Stock
- Commodities
- Crypto
- ETFs
sucess on python3.6.5
#hight level api ,This api is write base on ""iqoptionapi.api" for more easy
from iqoptionapi.stable_api import IQ_Option
#low level api
from iqoptionapi.api import IQOptionAPI
.
├── docs
├── iqoptionapi(API code)
├── http(doing http get/post)
└── ws
├── chanels(Doing websocket action)
└── objects(Get back data from websocket action)
For Python3
sudo pip3 install -U git+git:https://github.com/Lu-Yi-Hsun/iqoptionapi.git
For Python2
sudo pip2 install -U git+git:https://github.com/Lu-Yi-Hsun/iqoptionapi.git
import time
from iqoptionapi.stable_api import IQ_Option
I_want_money=IQ_Option("email","password")
goal="EURUSD"
print("get candles")
print(I_want_money.get_candles(goal,60,111,time.time()))
when you buy some thing you need to know ""ticker"" symbol
if you want to buy ""Alphabet Inc."" ticker symbol:""GOOGL"" buysomeapi("GOOGL")
you can find ticker symbol here
https://iqoption.com/en/assets
from iqoptionapi.stable_api import IQ_Option
import logging
logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
!!!
Login NOT support SMS Authorization yet
I suggest close it because your robot will stop to wait you to check sms code (on phone)....
!!!
I_want_money=IQ_Option("email","password")
some time connect will close so this way can check connect and reconnect
sample
I_want_money=IQ_Option("email","password")
#check if connect
if I_want_money.check_connect()==False:
I_want_money.connect()#if not connect it will reconnect
I_want_money=IQ_Option("email","password")
print(I_want_money.__version__)
you will get right all ACTIVES and code
print(I_want_money.get_all_ACTIVES_OPCODE())
Sample
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("email","pass")
goal="EURUSD"
print("get candles")
print(I_want_money.get_candles(goal,60,111,time.time()))
Money=1
ACTIVES="EURUSD"
ACTION="call"#or "put"
expirations_mode=1
force_buy= "True"
I_want_money.buy(Money,ACTIVES,ACTION,expirations_mode,force_buy)
I_want_money.buy(Money,ACTIVES,ACTION,expirations,force_buy)
#Money:How many you want to buy type(int)
#ACTIVES:sample input "EURUSD" OR "EURGBP".... you can view by get_all_ACTIVES_OPCODE
#ACTION:"call"/"put" type(str)
#expirations:input minute,careful too large will false to buy(Closed market time)thank Darth-Carrotpie's code (int)https://github.com/Lu-Yi-Hsun/iqoptionapi/issues/6
#force_buy= True: if fail try buy untill sucess
#False:if fail break
#return:(True/False,id):if sucess return (True,id_number) esle return(False,None)
(only for option)
It will do loop until get win or loose
❗
it have a little problem when network close and reconnect miss get "listInfoData"
this function will doing Infinity loop
I_want_money.check_win(23243221)
#""you need to get id_number from buy function""
#I_want_money.check_win(id_number)
#this function will do loop check your bet until if win/equal/loose
(only for option)
more better way
an other way to fix that(implement by get_betinfo)
input by int
I_want_money.check_win_v2(23243221)
#""you need to get id_number from buy function""
#I_want_money.check_win_v2(id_number)
#this function will do loop check your bet until if win/equal/loose
(only for option)
it will get infomation about Bet by "id"
❗
if your bet(id) not have answer yet(game_state) or wrong id it will return False input by int
isSuccessful,dict=I_want_money.get_betinfo(4452272449)
#I_want_money.get_betinfo
#INPUT: int
#OUTPUT:isSuccessful,dict
from iqoptionapi.stable_api import IQ_Option
import logging
logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
I_want_money=IQ_Option("email","password")
strike_list=I_want_money.get_strike_list_data("EURUSD",1)
print("Strike List")
for i in strike_list:
print("key",i,"value",strike_list[i])
#Choose first Strike List
instrument_id=strike_list[list(strike_list)[0]]
I_want_money.buy_digit(3,"put",instrument_id)
strike_list=I_want_money.get_strike_list_data("EURUSD",1)
#strike_list=I_want_money.get_strike_list_data(ACTIVE,expirations)
#ACTIVE:"EURUSD"....
#expirations: it seem only 1 and 5 for choose
#return:dict{strike data,instrument_id}
I_want_money.buy_digit(3,"put",instrument_id)
#I_want_money.buy_digit(price,direction,instrument_id)
#price:how many you want to buy
#direction:"call"/"put"
#instrument_id:you need get from strike list
Forex | Stock | Commodities | Crypto | ETFs | |
---|---|---|---|---|---|
instrument_type | "forex" | "cfd" | "cfd" | "crypto" | "cfd" |
if you want to buy ""Alphabet Inc.""
find ticker symbol
https://iqoption.com/en/assets
you can find "Alphabet Inc."'s ticker symbol is "GOOGLE"
instrument_id="GOOGL"
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("email","password")
instrument_type="crypto"
instrument_id="BTCUSD"
side="buy"#sell
type="market"#limit
amount=11
limit_price=2#for limit ,if you choose market this not work,
leverage=3#you can get more information in get_available_leverages()
stop_lose_price=1#
take_profit_price=20000#
check,order_id=I_want_money.buy_order(instrument_type,instrument_id,side,type,amount,limit_price,leverage,stop_lose_price,take_profit_price)
print(I_want_money.get_order(order_id))
print(I_want_money.get_positions("crypto"))
print(I_want_money.get_position_history("crypto"))
print(I_want_money.get_available_leverages("crypto","BTCUSD"))
print(I_want_money.close_position(order_id))
print(I_want_money.get_overnight_fee("crypto","BTCUSD"))
return (True/False,buy_order_id/False)
if Buy sucess return (True,buy_order_id)
instrument_type="crypto"
instrument_id="BTCUSD"
side="buy"#sell
type="market"#limit
amount=11#How many money you want investment
limit_price=2#for limit ,if you choose market this not work,
leverage=3#you can get more information in get_available_leverages()
stop_lose_price=1#stop lose price
take_profit_price=20000#take profit price
I_want_money.buy_order(instrument_type,instrument_id,side,type,amount,limit_price,leverage,stop_lose_price,take_profit_price)
get infomation about buy_order_id
return (True/False,get_order,None)
I_want_money.get_order(buy_order_id)
you will get there data
return (True/False,get_positions,None)
I_want_money.get_positions(instrument_type)
you will get there data
return (True/False,position_history,None)
I_want_money.get_positions_history(instrument_type)
get available leverages
return (True/False,available_leverages,None)
I_want_money.get_available_leverages(instrument_type,actives)
you will do this
return (True/False)
I_want_money.cancel_order(buy_order_id)
you will do this
return (True/False)
I_want_money.close_position(buy_order_id)
return (True/False,overnight_fee,None)
I_want_money.get_overnight_fee(instrument_type,active)
❗
get_candles can not get "real time data" ,it will late about 30sec
if you very care about real time you need use
"get realtime candles" OR "collect realtime candles"
sample
""now"" time 1:30:45sec
-
you want to get candles 1:30:45sec now
you may get 1:30:15sec data have been late approximately 30sec
-
you want to get candles 1:00:33sec
you will get the right data
I_want_money.get_candles(ACTIVES,interval,count,endtime)
#ACTIVES:sample input "EURUSD" OR "EURGBP".... youcan
#interval:duration of candles
#count:how many candles you want to get from now to past
#endtime:get candles from past to "endtime"
from iqoptionapi.stable_api import IQ_Option
import logging
import time
#logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
print("login...")
I_want_money=IQ_Option("email","password")
goal="EURUSD"
size="all"#size=[1,5,10,15,30,60,120,300,600,900,1800,3600,7200,14400,28800,43200,86400,604800,2592000,"all"]
maxdict=10
print("start stream...")
I_want_money.start_candles_stream(goal,size,maxdict)
#DO something
print("Do something...")
time.sleep(10)
print("print candles")
cc=I_want_money.get_realtime_candles(goal,size)
for k in cc:
print(goal,"size",k,cc[k])
print("stop candle")
I_want_money.stop_candles_stream(goal,size)
- input:
- goal:"EURUSD"...
- size:[1,5,10,15,30,60,120,300,600,900,1800,3600,7200,14400,28800,43200,86400,604800,2592000,"all"]
- maxdict:set max buffer you want to save
size
- input:
- goal:"EURUSD"...
- size:[1,5,10,15,30,60,120,300,600,900,1800,3600,7200,14400,28800,43200,86400,604800,2592000,"all"]
- output:
- dict
- input:
- goal:"EURUSD"...
- size:[1,5,10,15,30,60,120,300,600,900,1800,3600,7200,14400,28800,43200,86400,604800,2592000,"all"]
Sample
from iqoptionapi.stable_api import IQ_Option
I_want_money=IQ_Option("email","password")
goal="EURUSD"
I_want_money.start_mood_stream(goal)
print(I_want_money.get_traders_mood(goal))
I_want_money.stop_mood_stream(goal)
get percent of higher(call)
if you want to know percent of lower(put) just 1-higher
I_want_money.get_traders_mood(goal)
#input:input "EURUSD" OR "EURGBP".... you can view by get_all_ACTIVES_OPCODE
#output:(float) the higher(call)%
#if you want to know lower(put)% try 1-I_want_money.get_traders_mood(goal)
get all you start mood
I_want_money.get_all_traders_mood(goal)
#output:(dict) all mood you start
I_want_money.get_all_profit()
#return type(dict) sample:dict["EURUSD"]=0.85
I_want_money.get_balance()
I_want_money.change_balance(MODE)
#MODE: "PRACTICE"/"REAL"