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.

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.3.tar.gz (20.1 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.3-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ibkr_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 20.1 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.3.tar.gz
Algorithm Hash digest
SHA256 946ca2afff391e0ab9c276e3608c8992afa8238d2e6d2d1bdf65723214745771
MD5 7e1c1388d1ef8a59fe46f42097fc265c
BLAKE2b-256 4d9448805f6e9ac5cec58616d860266fc41852be845b8d45c989765db0cc1147

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ibkr_sdk-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 18.2 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d9e9837ce08c20cfe6a7c365078639bd78ab324a8f2aa1a59b80bd4d59b6ac14
MD5 5e262001edd25480aa400dca3da82f83
BLAKE2b-256 2f545b92c6e564b397c5df9583d62d883aff3f693ea072df248e2e60a4532e91

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