iqoption-async


Nameiqoption-async JSON
Version 0.0.1 PyPI version JSON
download
home_pagehttps://github.com/s00rk/iqoption_async
SummaryAn updated Python library for interacting with IQ Option using asyncio and modern WebSockets.
upload_time2024-12-01 07:06:16
maintainerNone
docs_urlNone
authorVictor Rivera
requires_python>=3.11
licenseNone
keywords iqoption trading api asyncio websockets
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:
```bash
pip install iqoption_async
```

For development:
```bash
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:
```python
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:
```python
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):
```python
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:
```python
candles = await client.get_candles("EURUSD", interval_min=1, limit=10, end_time=time.time())
print(candles)
```

### Buying an Option
Place a trade:
```python
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)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/s00rk/iqoption_async",
    "name": "iqoption-async",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "iqoption trading api asyncio websockets",
    "author": "Victor Rivera",
    "author_email": "victor.riverac92@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ab/0b/70113b7c1dbb733c1a82f714109d0435dd4934a6d1f3645548d6efad54c6/iqoption_async-0.0.1.tar.gz",
    "platform": null,
    "description": "# IQOption API Library\n\nAn updated Python library for interacting with the IQ Option platform using modern asynchronous features like `aiohttp` and `websockets`.\n\n## Features\n- Fully asynchronous.\n- Supports real-time data streams (candles, balances, positions).\n- Includes utilities for trading operations.\n\n## Installation\nInstall the library (when published) via pip:\n```bash\npip install iqoption_async\n```\n\nFor development:\n```bash\ngit clone https://github.com/yourusername/iqoption_async.git\ncd iqoption_async\npip install -r requirements.txt\n```\n\n## Usage\n### Initialization\nThe main client to interact with the API is IQOptionClient. Initialize it with your email and password:\n```python\nimport asyncio\nfrom iqoption_async.client import IQOptionClient\n\nclient = IQOptionClient(email=\"your_email@example.com\", password=\"your_password\")\n\nasync def main():\n    success, reason = await client.connect()\n    if success:\n        print(\"Connected successfully!\")\n    else:\n        print(f\"Failed to connect: {reason}\")\n\nasyncio.run(main())\n```\n\n### Retrieving Profile Data\nFetch the user's profile:\n```python\nprofile = await client.get_profile()\nprint(f\"User ID: {profile.id}\")\nprint(f\"Balances: {profile.balances}\")\n```\n\n### Changing Balance\nSwitch between practice and real accounts (PRACTICE, REAL):\n```python\nawait client.change_balance(\"PRACTICE\")\nbalance = await client.get_balance()\nprint(f\"Current practice balance: {balance}\")\n```\n\n### Fetching Candles\nRetrieve candle data for a specific symbol:\n```python\ncandles = await client.get_candles(\"EURUSD\", interval_min=1, limit=10, end_time=time.time())\nprint(candles)\n```\n\n### Buying an Option\nPlace a trade:\n```python\nresult, order_id, expiration = await client.buy(amount=10, symbol=\"EURUSD\", action=\"call\", expiration=1)\nif result:\n    print(f\"Trade successful! Order ID: {order_id}\")\nelse:\n    print(\"Trade failed.\")\n    return\n\nmins = math.ceil(((datetime.fromtimestamp(expiration) -  datetime.now()).seconds / 60))\n\n# WAIT for result\nfinded, status, profit = await client.check_order(order_id, mins)\n# status -> win, loose, equal, sold\nif finded:\n    print(f\"Order with status {status} profit {profit}\")\nelse:\n    print(\"Order not found\")\n\n# ASYNC for result\nasync def func(result):\n    finded, status, profit = result\nawait client.check_order(order_id, mins, func)\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "An updated Python library for interacting with IQ Option using asyncio and modern WebSockets.",
    "version": "0.0.1",
    "project_urls": {
        "Homepage": "https://github.com/s00rk/iqoption_async"
    },
    "split_keywords": [
        "iqoption",
        "trading",
        "api",
        "asyncio",
        "websockets"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "963d290452ac54170875dc945f0b2351111d6acf92804483f4802b5c65437a8c",
                "md5": "5dedb4c128551d896744c49db48b4e2d",
                "sha256": "a7d5a698aa32aa599fbd8226e7c90ebdb664cce68e12bca124cdb0d72121704f"
            },
            "downloads": -1,
            "filename": "iqoption_async-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5dedb4c128551d896744c49db48b4e2d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 16096,
            "upload_time": "2024-12-01T07:06:12",
            "upload_time_iso_8601": "2024-12-01T07:06:12.272339Z",
            "url": "https://files.pythonhosted.org/packages/96/3d/290452ac54170875dc945f0b2351111d6acf92804483f4802b5c65437a8c/iqoption_async-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ab0b70113b7c1dbb733c1a82f714109d0435dd4934a6d1f3645548d6efad54c6",
                "md5": "183f307168948af59de680b7172c5afd",
                "sha256": "c95afabddf2602a07642ebcf6b907c9976f918e4bee6d21937e441bad56d7bbb"
            },
            "downloads": -1,
            "filename": "iqoption_async-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "183f307168948af59de680b7172c5afd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 11691,
            "upload_time": "2024-12-01T07:06:16",
            "upload_time_iso_8601": "2024-12-01T07:06:16.991203Z",
            "url": "https://files.pythonhosted.org/packages/ab/0b/70113b7c1dbb733c1a82f714109d0435dd4934a6d1f3645548d6efad54c6/iqoption_async-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-01 07:06:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "s00rk",
    "github_project": "iqoption_async",
    "github_not_found": true,
    "lcname": "iqoption-async"
}
        
Elapsed time: 0.79017s