Skip to main content

A modern, Pydantic-based parser for Interactive Brokers (IBKR) Flex Query reports

Project description

py-ibkr

A modern, Pydantic-based parser for Interactive Brokers (IBKR) Flex Query reports. This version replaces the legacy ibflex library with strict type checking and improved support for newer IBKR XML fields.

Features

  • Pydantic Models: All data is parsed into typed Pydantic models with validation.
  • Robust Parsing: Handles "messy" IBKR data (e.g., legacy enums like Deposits/Withdrawals, inconsistent date formats).
  • Forward Compatible: Designed to handle new fields gracefully.

Installation

uv pip install py-ibkr
# or
pip install py-ibkr

Usage

Parsing a Flex Query File

from py_ibkr import parse, FlexQueryResponse

response = parse("path/to/report.xml")

print(f"Query Name: {response.queryName}")

for statement in response.FlexStatements:
    print(f"Account: {statement.accountId}")
    
    # Access Trades
    for trade in statement.Trades:
        print(f"Symbol: {trade.symbol}, Quantity: {trade.quantity}, Price: {trade.tradePrice}")
        
    # Access Cash Transactions
    for cash_tx in statement.CashTransactions:
        print(f"Type: {cash_tx.type}, Amount: {cash_tx.amount}")

Models

You can import models directly for type hinting:

from py_ibkr import Trade, CashTransaction

def process_trade(trade: Trade):
    print(trade.symbol)

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

py_ibkr-0.1.0.tar.gz (45.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_ibkr-0.1.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_ibkr-0.1.0.tar.gz
  • Upload date:
  • Size: 45.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for py_ibkr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4893274f175c630e2b669b2672ce4bb081146d1e9ac3e0106e6b7a96bd716e2f
MD5 4a0cb4dd8000ae03dc5022d3f9a87964
BLAKE2b-256 ff4ce61f7155d866d7ff1bc3ecb8f4775d302aa5ddf0bfdfd96279016d9f87da

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_ibkr-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for py_ibkr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b4b448fe6f102ed93207b9b91bda10687200331399e973b40d9b03ee2ae1cb5
MD5 faa407986f736d5ff368b89e416fd51b
BLAKE2b-256 c22ec820495864dfd9113a5d76cdcde3f831e4d99c8ab1ecb8d8648dd8364b33

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