A Python SDK for interacting with Interactive Brokers API
Project description
IBKR SDK
A Python SDK for interacting with Interactive Brokers Web API.
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
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
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76a4ee553488bf0cbf498b01d428667356fbb8e12d8b5b05692da5bcbe1ecb28
|
|
| MD5 |
e4638004570eeaa48f0e00d95d73733c
|
|
| BLAKE2b-256 |
8400c8a9b5b98064df1f6810e38af8387556e4893fef4e5768830295a7adebb4
|
Provenance
The following attestation bundles were made for ibkr_sdk-0.2.0.tar.gz:
Publisher:
publish.yml on Siddhesh-Agarwal/ibkr-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ibkr_sdk-0.2.0.tar.gz -
Subject digest:
76a4ee553488bf0cbf498b01d428667356fbb8e12d8b5b05692da5bcbe1ecb28 - Sigstore transparency entry: 1764870596
- Sigstore integration time:
-
Permalink:
Siddhesh-Agarwal/ibkr-sdk@ab85a15ad7ef9c29f89ef98b0d8e8bac69ec3ebf -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Siddhesh-Agarwal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ab85a15ad7ef9c29f89ef98b0d8e8bac69ec3ebf -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5279a1ba5be6f45b342e9e6f1446e3e87a748de2bfb1e12623d57cd00a6e07ca
|
|
| MD5 |
e3a2c6cbd68e192d908c414c56109480
|
|
| BLAKE2b-256 |
ebe73f28cd5fba330ef169e86109119870e6c615df11e47920955cc74e3a7a2e
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ibkr_sdk-0.2.0-py3-none-any.whl -
Subject digest:
5279a1ba5be6f45b342e9e6f1446e3e87a748de2bfb1e12623d57cd00a6e07ca - Sigstore transparency entry: 1764871191
- Sigstore integration time:
-
Permalink:
Siddhesh-Agarwal/ibkr-sdk@ab85a15ad7ef9c29f89ef98b0d8e8bac69ec3ebf -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Siddhesh-Agarwal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ab85a15ad7ef9c29f89ef98b0d8e8bac69ec3ebf -
Trigger Event:
release
-
Statement type: