Skip to main content

A Python SDK for interacting with Interactive Brokers API

Project description

IBKR SDK

A Python SDK for interacting with Interactive Brokers Web API.

PyPI Downloads

Installation

From PyPI

pip install ibkr-sdk

Quick Start

from ibkr import IBKRClient

client = IBKRClient()
client.connect("username", "password")

# List accounts
accounts = client.portfolio.accounts()

# Get positions
positions = client.portfolio.positions("DU123456")

# Get open orders
orders = client.orders.list_orders()

Features

  • Full API Coverage: All REST endpoints from IBKR API v2.31.0
  • Pydantic Models: Type-safe request/response parsing with validation
  • Cookie-based Auth: Session authentication via /iserver/auth/status
  • snake_case Fields: Pythonic attribute names with camelCase alias support

Architecture

ibkr/
├── client.py        # IBKRClient and API classes
├── auth.py          # Session/auth handling
├── exceptions.py    # Custom exceptions
├── types.py         # Enums
└── models/          # Pydantic models
    ├── account.py
    ├── portfolio.py
    ├── orders.py
    ├── marketdata.py
    ├── contract.py
    ├── scanner.py
    ├── fa.py
    └── fyi.py

API Classes

Class Description
client.portfolio Account info, positions, ledger, summary
client.orders Open orders, order status
client.marketdata Snapshot, historical data
client.contract Contract search, info
client.scanner Scanner parameters, run
client.fa Financial advisor endpoints
client.fyi Notifications, settings

Authentication

client = IBKRClient()
client.connect(username, password)

# Keep session alive
client.tickle()

# End session
client.disconnect()

Models

All models accept camelCase JSON (from API) and expose snake_case attributes:

from ibkr.models import AccountAttributes, IndividualPosition

# Works with API JSON
acct = AccountAttributes(**{"accountId": "DU123", "currency": "USD"})
print(acct.account_id)  # "DU123"

Exceptions

Exception Description
IBKRError Base exception
IBKRAPIError API error response
IBKRValidationError JSON/validation error
IBKRConnectionError Network error

Development

# Install dependencies
uv sync

# Run tests
uv run pytest tests/

# Lint
ruff check

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

ibkr_sdk-0.2.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

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

ibkr_sdk-0.2.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file ibkr_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: ibkr_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ibkr_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 76a4ee553488bf0cbf498b01d428667356fbb8e12d8b5b05692da5bcbe1ecb28
MD5 e4638004570eeaa48f0e00d95d73733c
BLAKE2b-256 8400c8a9b5b98064df1f6810e38af8387556e4893fef4e5768830295a7adebb4

See more details on using hashes here.

Provenance

The following attestation bundles were made for ibkr_sdk-0.2.0.tar.gz:

Publisher: publish.yml on Siddhesh-Agarwal/ibkr-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ibkr_sdk-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ibkr_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ibkr_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5279a1ba5be6f45b342e9e6f1446e3e87a748de2bfb1e12623d57cd00a6e07ca
MD5 e3a2c6cbd68e192d908c414c56109480
BLAKE2b-256 ebe73f28cd5fba330ef169e86109119870e6c615df11e47920955cc74e3a7a2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for ibkr_sdk-0.2.0-py3-none-any.whl:

Publisher: publish.yml on Siddhesh-Agarwal/ibkr-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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