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
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 py_ibkr-0.1.1.tar.gz.
File metadata
- Download URL: py_ibkr-0.1.1.tar.gz
- Upload date:
- Size: 46.0 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1744c8dab849edb215f1ab33ad39bc79d4a825ad574886468e1a41ab16f70514
|
|
| MD5 |
5fa2b58691798b7170195f631fe862d4
|
|
| BLAKE2b-256 |
8df512e7410e82cccf8d4f1d48e082b1573588a7d2ab73d6a535a9721939ffda
|
File details
Details for the file py_ibkr-0.1.1-py3-none-any.whl.
File metadata
- Download URL: py_ibkr-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.2 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68295444e45e924bbc75ba5a5604c710799515bbef128cc9901b66a4b80fd487
|
|
| MD5 |
fa003cd2239951663931974b747f4309
|
|
| BLAKE2b-256 |
09cb00093154bc50c0120e947ebb810292e22805b4ac497f018056e88770ffee
|