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.2.tar.gz (48.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.2-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_ibkr-0.1.2.tar.gz
  • Upload date:
  • Size: 48.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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.2.tar.gz
Algorithm Hash digest
SHA256 7596117239309fa787216320834a8fae234d14a767984712e8d1e69620ca98a5
MD5 1e9c5726a4ff0ebf4de834d7d2e1470b
BLAKE2b-256 9490250c85cebb29ecfbddd9230fac3708bf08dc7d25d6c751c1a5de7254bcf3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_ibkr-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 eaea3b98a2bfec9a21769734fbaecf8eda4b4c918efeb652d0f27e3a5bbfa20d
MD5 7f9a525e90384b747baae2432fe81bc5
BLAKE2b-256 c2d1ea3b08c012934ab85e9c2dda8ae229c825fbf2a1fef15143f5a411910084

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