A Simple websocket API for IQ Option.
- Version: 0.3a
- Python: 2, 3
- Website: https://github.com/harwee/IQOption-Api
- Author: Sri Harsha Gangisetty
Please use the code from async
branch master branch will be updated onceall the basic functionality is completly rewritten in async branch.
- Ability to place Put, Sell Digital Options
from iqoption_api import IQOption
api = IQOption("mail@email.com","password")
api.login() # Returns True if successful else False
api.start_socket_connection()
print(api.active_account) # prints `real` or `practice`
print(api.balance) # prints active account balance
print(api.real_balance) # prints real account balance
print(api.practice_balance) # prints practice account balance
api.change_account("real") # `real` or `practice` Returns Account Type (`real` or `practice`)
print(api.positions)
print(api.tick) ## range 0, 59
print(api.instruments_to_id) ## All Instruments Websocket Returned
print(api.forex_instruments)
print(api.cfd_instruments)
print(api.crypto_instruments)
api.subscribe_market("EURUSD")
api.market_data
api.update_expiration_list("EURUSD")
print(api.binary_expiration_list["EURUSD"])
### Sample Response
[{u'expiration_length': 60, u'type': u'PT1M', u'dead_time_length': 10, u'time': 1512475620}, {u'expiration_length': 300, u'type': u'PT5M', u'dead_time_length': 10, u'time': 1512475800}]
api.open_position(direction="put",
expiration_time=api.binary_expiration_list["EURUSD"][-1]["time"],
market_name="EURUSD",
price=5,
type="turbo"
)
# api.update_candle_data(market_name,interval,start_time,end_time)
api.update_candle_data("EURUSD",1,0,int(time.time())) ## get latest 1000 candles with 1 second interval
# api.candle_data[market_name][interval] # list of lists [time,open,close,high,low]
print(api.candle_data["EURUSD][1]) # prints candles