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

[!WARNING] The package is not yet published on PyPI. Use the GitHub installation method instead.

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.0.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.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ibkr_sdk-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 d94500eeba015a9b8bc6ff852f4a6ba93c3f91e1191ebc2876f541d2958d338e
MD5 65318cf35dd3015ffe5a9da665728ee7
BLAKE2b-256 28cd099ad553bf5f96c786e6c747e6f172abaa9d6f8fd7e8c65712f800f0f752

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ibkr_sdk-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 57f4c6316eab19167e1551fa1b0e4c977491abf466124f2aeb15bf7127b8f610
MD5 aa06de9886f3702af1ed43791b26d1d2
BLAKE2b-256 da997e7f96c68867b4cbf211f1f917ba8f54a4893d01eb1100a2ae195f94f701

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