An updated Python library for interacting with IQ Option using asyncio and modern WebSockets.
Project description
IQOption API Library
An updated Python library for interacting with the IQ Option platform using modern asynchronous features like aiohttp and websockets.
Features
- Fully asynchronous.
- Supports real-time data streams (candles, balances, positions).
- Includes utilities for trading operations.
Installation
Install the library (when published) via pip:
pip install iqoption_async
For development:
git clone https://github.com/yourusername/iqoption_async.git
cd iqoption_async
pip install -r requirements.txt
Usage
Initialization
The main client to interact with the API is IQOptionClient. Initialize it with your email and password:
import asyncio
from iqoption_async.client import IQOptionClient
client = IQOptionClient(email="your_email@example.com", password="your_password")
async def main():
success, reason = await client.connect()
if success:
print("Connected successfully!")
else:
print(f"Failed to connect: {reason}")
asyncio.run(main())
Retrieving Profile Data
Fetch the user's profile:
profile = await client.get_profile()
print(f"User ID: {profile.id}")
print(f"Balances: {profile.balances}")
Changing Balance
Switch between practice and real accounts (PRACTICE, REAL):
await client.change_balance("PRACTICE")
balance = await client.get_balance()
print(f"Current practice balance: {balance}")
Fetching Candles
Retrieve candle data for a specific symbol:
candles = await client.get_candles("EURUSD", interval_min=1, limit=10, end_time=time.time())
print(candles)
Buying an Option
Place a trade:
result, order_id, expiration = await client.buy(amount=10, symbol="EURUSD", action="call", expiration=1)
if result:
print(f"Trade successful! Order ID: {order_id}")
else:
print("Trade failed.")
return
mins = math.ceil(((datetime.fromtimestamp(expiration) - datetime.now()).seconds / 60))
# WAIT for result
finded, status, profit = await client.check_order(order_id, mins)
# status -> win, loose, equal, sold
if finded:
print(f"Order with status {status} profit {profit}")
else:
print("Order not found")
# ASYNC for result
async def func(result):
finded, status, profit = result
await client.check_order(order_id, mins, func)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iqoption_async-0.0.1.tar.gz.
File metadata
- Download URL: iqoption_async-0.0.1.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c95afabddf2602a07642ebcf6b907c9976f918e4bee6d21937e441bad56d7bbb
|
|
| MD5 |
183f307168948af59de680b7172c5afd
|
|
| BLAKE2b-256 |
ab0b70113b7c1dbb733c1a82f714109d0435dd4934a6d1f3645548d6efad54c6
|
File details
Details for the file iqoption_async-0.0.1-py3-none-any.whl.
File metadata
- Download URL: iqoption_async-0.0.1-py3-none-any.whl
- Upload date:
- Size: 16.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7d5a698aa32aa599fbd8226e7c90ebdb664cce68e12bca124cdb0d72121704f
|
|
| MD5 |
5dedb4c128551d896744c49db48b4e2d
|
|
| BLAKE2b-256 |
963d290452ac54170875dc945f0b2351111d6acf92804483f4802b5c65437a8c
|