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
Release history Release notifications | RSS feed
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.1.tar.gz
(20.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ibkr_sdk-0.1.1-py3-none-any.whl
(18.1 kB
view details)
File details
Details for the file ibkr_sdk-0.1.1.tar.gz.
File metadata
- Download URL: ibkr_sdk-0.1.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49fdf3582c6c74812748378f786ca004593fcd37dd717eb4cc3e61afe86322a0
|
|
| MD5 |
f5b2ceae3422a3adc14b7b1065c333b3
|
|
| BLAKE2b-256 |
a408d7e5cedec20a3cb0d52043d6dd70f491994acdfa46327c891802f900fd0b
|
File details
Details for the file ibkr_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ibkr_sdk-0.1.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c1b41bfbdb13e59a0144ec0f58f07f58a48143c814206b8d505698e7c7a1206
|
|
| MD5 |
8afb7effc820e22f5e4157d537af7aac
|
|
| BLAKE2b-256 |
a73ed970f1b3bf88f681d2b068d9b6f0273bbcd10b3e1750c0a507481dacd54a
|