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. Instale via git
pip install git+https://github.com/IzioGanasi/biblioteca_myiq.git

ou via Pypi

pip install myiq
  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():
    # Configure suas credenciais em variáveis de ambiente ou arquivo seguro
    email = "seu_email" 
    senha = "sua_senha"
    
    iq = IQOption(email, 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")
    
    await iq.close()

asyncio.run(main())

Exemplos de Cada Módulo

1. Autenticação HTTP (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 (IQOption)

from myiq import IQOption
import asyncio

async def demo_client():
    iq = IQOption("email", "senha")
    await iq.start()
    
    # Listar ativos abertos no momento para Blitz
    actives = await iq.get_actives("turbo")
    for id, info in actives.items():
        if info['open']:
            print(f"Ativo {info['name']} (ID: {id}) disponível")
            
    await iq.close()

asyncio.run(demo_client())

3. Utilitários

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 e Eventos

from myiq import IQOption
import asyncio

async def demo_dispatcher():
    iq = IQOption("email", "senha")
    await iq.start()
    
    def on_candle(msg):
        print("Nova vela gerada:", 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(10)
    await iq.close()

asyncio.run(demo_dispatcher())

5. Modelos Pydantic

from myiq import Balance, Candle

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

Raw WebSocket Return Dictionaries

Balance

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

Candle

{
  "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/: Core da biblioteca.
    • core/: Clientes, conexão, reconexão e descoberta de ativos.
    • http/: Autenticação.
    • models/: Modelos de dados.
  • requirements.txt: Dependências.
  • pyproject.toml: Configuração de build (PyPI).

Licença

MIT

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.2.tar.gz (19.7 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.2-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: myiq-0.1.2.tar.gz
  • Upload date:
  • Size: 19.7 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.2.tar.gz
Algorithm Hash digest
SHA256 b877a0e8010891a6c0e2881ce9fc4547d0967e0b2ce9e0aa01fc3b8db1859b33
MD5 8a7ff813f87471f03c33fd6dc83bd11c
BLAKE2b-256 e6ef729697241c30795f8d52db871816a4696a65a0ab0cd9940a559aaa97de2c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: myiq-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 18.0 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9251806aece4e9054f620e6d3a10128aaa036bcff82693d132760d72d5d667fc
MD5 596f2f75bfb4eba07b0d1a5886bc24b5
BLAKE2b-256 a90bdb793c74eca5b6c45ada6c452ab086c4579aae5957d04e9df25ba215f5bd

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