pyIOL
Current release: 0.1.1
Cliente Python para interactuar con la API REST de Invertir Online (IOL), una plataforma de trading e inversiones de Argentina.
Disclaimer
ADVERTENCIA IMPORTANTE
Esta libreria NO es oficial de Invertir Online. Es un proyecto independiente desarrollado por la comunidad.
El desarrollador NO se hace responsable por cualquier dano, perdida financiera, o perjuicio que pueda ocasionar el uso de esta libreria, incluyendo pero no limitado a:
- Perdidas economicas por operaciones ejecutadas
- Errores en la interpretacion de datos
- Fallos en la ejecucion de ordenes
- Cualquier otro problema derivado del uso de este software
Esta libreria puede contener bugs no descubiertos. Usela bajo su propia responsabilidad y con extrema precaucion, especialmente en operaciones que involucren dinero real.
Se recomienda encarecidamente probar primero en el entorno sandbox de IOL antes de usar en produccion.
Objetivos
- Proporcionar una interfaz Python simple y tipada para la API de IOL
- Facilitar la automatizacion de consultas de cotizaciones y datos de mercado
- Permitir la gestion programatica de portafolios e inversiones
- Ofrecer modelos de datos tipados para una mejor experiencia de desarrollo
Caracteristicas
- Autenticacion OAuth2 con cache automatico de tokens
- Modelos de datos tipados (dataclasses) para todas las respuestas
- Soporte para multiples mercados (BCBA, NYSE, NASDAQ, etc.)
- Metodos para cotizaciones, portafolio, operaciones, FCI, y mas
- Context manager para manejo seguro de conexiones
Requisitos
- Python >= 3.8
- Cuenta activa en Invertir Online con API habilitada
Instalacion
Desde PyPI
pip install pyiol-client
Desde el repositorio (desarrollo)
# Clonar el repositorio
git clone https://github.com/ezeprimo/py_iol.git
cd py_iol
# Instalar con uv (recomendado)
uv sync
# O con pip en modo desarrollo
pip install -e ".[dev]"
Dependencias
httpx>=0.24.0- Cliente HTTPcachetools>=5.0.0- Cache para tokens
Configuracion
- Crear archivo
.enven la raiz del proyecto:
cp .env.example .env
- Editar
.envcon tus credenciales de IOL:
IOL_USERNAME=tu_usuario_iol
IOL_PASSWORD=tu_password_iol
Uso Basico
Consultar Cotizaciones
from pyIol import IOLClient, Markets, SettlementTerms
# Crear cliente (usa context manager para cerrar conexion automaticamente)
with IOLClient("usuario", "password") as client:
# Cotizacion de GGAL
cotizacion = client.get_stock_quote("GGAL")
print(f"GGAL: ${cotizacion.ultimo_precio}")
print(f"Variacion: {cotizacion.variacion}%")
# Cotizacion con plazo T2
cotizacion_t2 = client.get_stock_quote(
"GGAL",
settlement_term=SettlementTerms.T2
)
Consultar Portafolio
from pyIol import IOLClient, Countries
with IOLClient("usuario", "password") as client:
# Obtener portafolio de Argentina
portafolio = client.get_portfolio(Countries.ARGENTINA)
print(f"Total valorizado: ${portafolio.total_valorizado:,.2f}")
print(f"Ganancia total: ${portafolio.total_ganancia:,.2f}")
# Listar posiciones
for titulo in portafolio.todos_los_titulos:
print(f"{titulo.simbolo}: {titulo.cantidad} unidades")
print(f" Ganancia: {titulo.ganancia_porcentaje:+.2f}%")
Cotizaciones Masivas
from pyIol import IOLClient
with IOLClient("usuario", "password") as client:
# Todas las acciones argentinas
cotizaciones = client.get_massive_quotes("acciones", "argentina")
for titulo in cotizaciones.titulos[:5]:
print(f"{titulo.simbolo}: ${titulo.ultimo_precio}")
# Panel MERVAL
merval = client.get_panel_quotes("acciones", "merval", "argentina")
for titulo in merval.titulos:
print(f"{titulo.simbolo}: {titulo.variacion_porcentual:+.2f}%")
Consultar Operaciones
from pyIol import IOLClient, OperationStates
from datetime import datetime, timedelta
with IOLClient("usuario", "password") as client:
# Operaciones de los ultimos 30 dias
operaciones = client.get_operations(
estado=OperationStates.ALL,
fecha_desde=datetime.now() - timedelta(days=30),
fecha_hasta=datetime.now()
)
for op in operaciones:
print(f"#{op.numero}: {op.tipo} {op.simbolo} - {op.estado}")
Usando Variables de Entorno
import os
from dotenv import load_dotenv
from pyIol import IOLClient
load_dotenv()
with IOLClient(
os.getenv("IOL_USERNAME"),
os.getenv("IOL_PASSWORD")
) as client:
if client.test_authentication():
print("Autenticacion exitosa!")
Estructura del Proyecto
py_iol/
├── pyIol/ # Paquete principal
│ ├── __init__.py # Exports publicos
│ ├── client.py # Cliente HTTP para la API
│ ├── models.py # Dataclasses para respuestas
│ └── constants.py # URLs, mercados, plazos
├── doc/ # Documentacion y ejemplos
│ ├── README.md # Indice de documentacion
│ ├── iol_api_doc.MD # Documentacion de la API de IOL
│ └── notebooks/ # Jupyter notebooks de ejemplo
│ ├── 01_autenticacion.ipynb
│ ├── 02_cotizaciones_basicas.ipynb
│ ├── 03_cotizaciones_avanzadas.ipynb
│ ├── 04_cuenta_portafolio.ipynb
│ ├── 05_trading.ipynb
│ ├── 06_fci.ipynb
│ ├── 07_mep_simplificado.ipynb
│ ├── 08_cpd.ipynb
│ └── 09_asesores.ipynb
├── pyproject.toml # Configuracion del proyecto
├── .env.example # Ejemplo de credenciales
└── README.md # Este archivo
Documentacion
La documentacion completa se encuentra en la carpeta doc/:
- Documentacion de la API - Referencia completa de endpoints de IOL
- Notebooks de ejemplo - Jupyter notebooks interactivos para cada funcionalidad
Endpoints Disponibles
| Categoria | Metodos |
|---|---|
| Autenticacion | test_authentication() |
| Perfil | get_profile_data() |
| Cotizaciones | get_stock_quote(), get_stock_data(), get_stock_options(), get_market_instruments(), get_massive_quotes(), get_panel_quotes(), get_stock_quote_detailed() |
| Cuenta | get_account_status(), get_portfolio() |
| Operaciones | get_operations(), get_operation_detail(), cancel_operation() |
| Trading | buy(), sell(), buy_dollar_bond(), sell_dollar_bond() |
| FCI | get_fci_list(), get_fci_detail(), get_fci_types(), get_fci_managers(), get_fci_types_by_manager(), subscribe_fci(), redeem_fci() |
| Dolar MEP | get_mep_dollar_rate(), get_mep_buy_estimate(), get_mep_sell_estimate(), get_mep_parameters(), validate_mep_operation(), buy_mep_simplified() |
| CPD | can_operate_cpd(), get_cpd_list(), get_cpd_commissions(), operate_cpd() |
| Asesores | get_advisor_movements(), get_investor_test_questions(), calculate_investor_profile(), save_investor_profile(), advisor_sell_dollar_bond() |
Los métodos de consulta y operación disponen de una versión
_raw()cuando está implementada, que retorna la respuesta JSON original de la API.
Constantes Disponibles
Mercados
from pyIol import Markets
Markets.BCBA # Bolsa de Buenos Aires
Markets.NYSE # New York Stock Exchange
Markets.NASDAQ # NASDAQ
Markets.AMEX # American Stock Exchange
Markets.BCS # Bolsa de Santiago
Markets.ROFX # ROFEX (Futuros)
Plazos de Liquidacion
from pyIol import SettlementTerms
SettlementTerms.T0 # Contado inmediato
SettlementTerms.T1 # 24 horas (default)
SettlementTerms.T2 # 48 horas
SettlementTerms.T3 # 72 horas
Estados de Operacion
from pyIol import OperationStates
OperationStates.ALL # Todas
OperationStates.PENDING # Pendientes
OperationStates.FINISHED # Terminadas
OperationStates.CANCELLED # Canceladas
Contribuir
Las contribuciones son bienvenidas. Consulta la Guia de Contribucion para detalles sobre:
- Configuracion del entorno de desarrollo
- Sistema de versionado semantico
- Proceso de publicacion a PyPI
- Estandares de codigo
Resumen rapido:
- Fork el repositorio
- Crea una rama para tu feature (
git checkout -b feature/nueva-funcionalidad) - Commit tus cambios (
git commit -am 'Agrega nueva funcionalidad') - Push a la rama (
git push origin feature/nueva-funcionalidad) - Abre un Pull Request
Community Policies
- Security Policy - Report security vulnerabilities privately.
- Code of Conduct - Community participation standards.
- Changelog - Release history.
Licencia
Este proyecto esta bajo la licencia especificada en el archivo LICENCE.
Autor
Ezequiel Primon - ezeprimo@gmail.com
Enlaces
Recuerda: Esta libreria interactua con sistemas financieros reales. Usala con responsabilidad y siempre verifica las operaciones antes de ejecutarlas.
Metadata
Release files for pyiol-client 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyiol_client-0.1.1.tar.gz | 189.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyiol_client-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 226.0 kB
Release files / pyiol_client-0.1.1.tar.gz
| Download URL | pyiol_client-0.1.1.tar.gz |
|---|---|
| Size | 189.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b40a4fdc98eb8268eef4061e4479ee5a0ba134f0b78b77e9f4e913b6750d033
|
|
BLAKE2b-256 checksum How to use checksums |
cda7826ee8a6445128bc2bba9871d9abe5d285dc47848e0919948d6d387ba604
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 4, 2026.
Transparency logRelease files / pyiol_client-0.1.1-py3-none-any.whl
| Download URL | pyiol_client-0.1.1-py3-none-any.whl |
|---|---|
| Size | 36.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
869e51d926cfb78fd4c41576ba2ad6b98b2ecf85a56f75c0b501250a75f8a53f
|
|
BLAKE2b-256 checksum How to use checksums |
582c8651c253b84ee884d69668b71e4c73de52add437e60249558cc01f3bd1f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 4, 2026.
Transparency log