Skip to content

A11ksa/API-Expert-Option

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 API-Expert-Option – Async WebSocket Client for Expert Option

High-performance, production-ready Python client with Playwright login (get_token) & full trade lifecycle.

Python AsyncIO Playwright Status License


✨ Features

  • Async: blazing fast non-blocking WebSocket client
  • 🔐 Playwright Login: secure token-based login with get_token()
  • 📈 Market Data: assets, quotes, candles, payouts in real-time
  • 🧾 Orders: open, monitor, and resolve trades with full lifecycle
  • 🩺 Logging & Debugging: with built-in health-checks
  • 🧪 Examples: quick-start usage and scripts

🔧 Installation

git clone https://github.com/A11ksa/API-Expert-Option
cd API-Expert-Option
python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate
pip install -U pip
pip install .
python -m playwright install chromium

🚀 Quick Start

import asyncio
from api_expert_option import AsyncExpertOptionClient, OrderDirection, get_token

async def main():
    # 1. Fetch token using playwright helper (get_token)
    token_info = get_token(email="you@example.com", password="yourpassword")
    demo_token = token_info.get("demo")

    # 2. Connect
    client = AsyncExpertOptionClient(token=demo_token, is_demo=True)
    if not await client.connect():
        print("Connection failed.")
        return

    # 3. Balance
    balance = await client.get_balance()
    print(f"Balance: {balance.balance} {balance.currency}")

    # 4. Place Order
    order = await client.place_order(
        asset="EURUSD",
        amount=5.0,
        direction=OrderDirection.CALL,
        duration=60
    )

    # 5. Await result
    profit, status = await client.check_win(order.order_id)
    print("Result:", status, "Profit:", profit)

    # 6. Disconnect
    await client.disconnect()

asyncio.run(main())

📐 Architecture

+----------------------------+              +-----------------------------+
|      Playwright Login     |   --> TOKEN → |   sessions/session.json     |
|     (opens browser)       |              |    demo/live tokens stored  |
+----------------------------+              +-----------------------------+
              |
              v
+-----------------------------+ WebSocket (async) +--------------------------+
|  AsyncExpertOptionClient    |<----------------->|   Expert Option Servers  |
+-----------------------------+                   +--------------------------+

💡 Examples

🔁 Streaming Candles

await client.subscribe_candles("EURUSD", timeframe=60)
async for candle in client.iter_candles("EURUSD", 60):
    print(candle)

📉 Trade with PUT

order = await client.place_order(
    asset="EURUSD",
    amount=10.0,
    direction=OrderDirection.PUT,
    duration=60
)
profit, status = await client.check_win(order.order_id)
print(status, profit)

🗝️ Tokens & Sessions

get_token() will store tokens in sessions/session.json

Manual override:

{
  "live": "EXPERT_LIVE_TOKEN",
  "demo": "EXPERT_DEMO_TOKEN"
}

🆘 Troubleshooting

  • Browser not installed?python -m playwright install chromium
  • 🔒 Login fails? → delete sessions/session.json
  • 🌐 Region errors? → check IP or VPN
  • ⚠️ SSL errors? → check your Python/OpenSSL env

📬 Contact

Email Telegram


🛠️ Contributing

  1. Fork + open a pull request
  2. Follow formatting (PEP8, type hints)
  3. Include tests when appropriate

📄 License

MIT — see LICENSE

About

API Expert Option

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages