Skip to main content

A modern, asynchronous Python library for IQ Option API

Project description

IQ Option ML Trader Library

Este projeto fornece uma biblioteca Python para comunicação com a API da IQ Option, permitindo a obtenção de candles, balances e execução de trades Blitz.

Instalação

  1. Certifique-se de ter o Python instalado (recomendado 3.10+).
  2. Instale as dependências:
pip install -r requirements.txt

Uso Básico

import asyncio
from myiq import IQOption

async def main():
    iq = IQOption("seu_email", "sua_senha")
    await iq.start()
    balances = await iq.get_balances()
    print(balances)
    candles = await iq.fetch_candles(active_id=76, duration=60, total=1500)
    print(f"[candles] Received {len(candles)} candles")

asyncio.run(main())

Exemplos de Cada Módulo

1. Autenticação HTTP (myiq.http.auth.IQAuth)

from myiq import IQAuth
import asyncio

async def demo_auth():
    auth = IQAuth("email", "senha")
    ssid = await auth.get_ssid()
    print("SSID:", ssid)

asyncio.run(demo_auth())

2. Cliente Core (myiq.core.client.IQOption)

from myiq import IQOption
import asyncio

async def demo_client():
    iq = IQOption("email", "senha")
    await iq.start()
    balances = await iq.get_balances()
    print("Balances:", balances)
    await iq.ws.ws.close()

asyncio.run(demo_client())

3. Utilitários (myiq.core.utils)

from myiq import get_req_id, get_sub_id, get_client_id

print("req_id:", get_req_id())
print("sub_id:", get_sub_id())
print("client_id:", get_client_id())

4. Dispatcher (myiq.core.dispatcher.Dispatcher)

from myiq import IQOption
import asyncio

async def demo_dispatcher():
    iq = IQOption("email", "senha")
    await iq.start()
    def on_candle(msg):
        print("Candle event:", msg)
    iq.dispatcher.add_listener("candle-generated", on_candle)
    await iq.start_candles_stream(active_id=76, duration=60, callback=lambda d: None)
    await asyncio.sleep(5)
    await iq.ws.ws.close()

asyncio.run(demo_dispatcher())

5. Modelos Pydantic (myiq.models.base)

from myiq import Balance, Candle

raw_balance = {"id": 123, "type": 4, "amount": 100.0, "currency": "USD"}
balance = Balance(**raw_balance)
print(balance)

raw_candle = {
    "id": 1,
    "from": 1700000000,
    "to": 1700000060,
    "open": 1.1234,
    "close": 1.1240,
    "min": 1.1220,
    "max": 1.1250,
    "volume": 2500.0,
}
candle = Candle(**raw_candle)
print(candle)

Dicionários crus dos retornos do WebSocket

Balance (evento portfolio.order-changed ou portfolio.position-changed)

{
  "id": 123,
  "type": 4,
  "amount": 100.0,
  "currency": "USD"
}

Candle (evento candle-generated)

{
  "id": 1,
  "from": 1700000000,
  "to": 1700000060,
  "open": 1.1234,
  "close": 1.1240,
  "min": 1.1220,
  "max": 1.1250,
  "volume": 2500.0
}

Estrutura do Projeto

  • myiq/: Biblioteca personalizada para comunicação com a API da IQ Option.
    • core/: Componentes principais (cliente, conexão, dispatcher).
    • http/: Autenticação HTTP.
    • models/: Modelos de dados Pydantic.
  • requirements.txt: Lista de dependências.

Notas

  • O bot opera no ativo EUR/USD Blitz (ID 76) por padrão.
  • O timeframe padrão é de 1 minuto.
  • O valor da entrada padrão é 1.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

myiq-0.1.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

myiq-0.1.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file myiq-0.1.0.tar.gz.

File metadata

  • Download URL: myiq-0.1.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for myiq-0.1.0.tar.gz
Algorithm Hash digest
SHA256 581ba83599472f2f7c9df860c45916b00897e98c92dd0f7c3b443f3fd6039add
MD5 72513bc1534880a19ee143e941dc9227
BLAKE2b-256 05262d4acd03b6f30ef5c1a88a5b3f9deedd41e313b77b31353ac4123c82f641

See more details on using hashes here.

File details

Details for the file myiq-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: myiq-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for myiq-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 25074478c7f72b0d5c831ecd634e17255dadab9c9a5b7587a76cc832e7c799d8
MD5 ed1d1ed2089661d24ea21574e9f74e17
BLAKE2b-256 6876af065b6f8841a06d741be2a975cc80989eb3e82f252306433c69f35d0c70

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page