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 API.

Installation

From PyPI

pip install ibkr-sdk

From GitHub

pip install git+https://github.com/Siddhesh-Agarwal/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.1.2.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.1.2-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ibkr_sdk-0.1.2.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ibkr_sdk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f3f11f44c69a20d2e28df10ad1a0b50d879370d2eae187176c932b2663a2f219
MD5 e5af7ff6ec4ddb3e34794c4dda716d8a
BLAKE2b-256 5c692526bcfe9ea1bf4222ee07954100f6cc69fbe455d0867815977f53108e24

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ibkr_sdk-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ibkr_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 87b780120219f8488775403eae77d648132150c5f8f0031379db06e00ef1233f
MD5 f09550865a827d04897e6424acefa2d4
BLAKE2b-256 2622849f172832ece5b5747ef26d00fe525afcd8366c7c583f1f697ec9dd7ec8

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