Skip to content

Add a bunch of fields that appear in my flex queries on new types#96

Open
vroonhof wants to merge 19 commits intocsingley:masterfrom
vroonhof:master
Open

Add a bunch of fields that appear in my flex queries on new types#96
vroonhof wants to merge 19 commits intocsingley:masterfrom
vroonhof:master

Conversation

@vroonhof
Copy link

IBKR seems to be in migration from AssetSummary to SymbolSummary
note: sort order of attributes on different types seems to have diverged. may be a worth a new sort, not doing this here to keep diff minial.

Currency conversion rates sometimes appear for 'RUS' (though always with -1 rates)

vroonhof and others added 19 commits May 27, 2025 00:30
IBKR seems to be in migrarion from AssetSummary to SymbolSummary
Currency conversion rates sometimes appear for 'RUS' (though always
Most of these are empty but present on my reports, it just seems to inherit from Trade
Add missing fields for current IBKR Flex Query format

- Add positionActionID to Trade, Lot, SymbolSummary, AssetSummary, Order
- Add 32 missing fields to SymbolSummary (closePrice, cost, mtmPnl, etc.)
- Add RUS to CURRENCY_CODES (used by IBKR for Russian-related data)
- Remove hardcoded URL override that broke API calls

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: vroonhof <38109466+vroonhof@users.noreply.github.com>
Fix initialInvestment type and add liteSurchargeAccruals field
Interactive Brokers frequently adds new fields to their XML exports,
causing parsing failures for attributes/elements not defined in Types.py.

This commit adds an opt-in tolerance mechanism:
- enable_unknown_attribute_tolerance(): silently ignore unknown XML
  attributes and element types during parsing
- disable_unknown_attribute_tolerance(): restore strict behavior (default)

When tolerance is enabled:
- Unknown XML attributes on data elements are filtered out before parsing
- Unknown element types return None and are filtered from containers
- Unknown contained elements in FlexStatement/FlexQueryResponse are skipped
- All known attributes continue to be parsed normally

The functions are exported from the top-level ibflex package. On the
original upstream ibflex package, these functions do not exist, so
calling them raises AttributeError - providing a clear version guard.

Includes 14 new tests covering:
- Default off behavior
- Enable/disable toggling
- Package-level accessibility (version guard)
- Unknown attributes with and without tolerance
- Unknown element types
- Full round-trip parsing with unknown fields
- Container filtering

Co-authored-by: vroonhof <vroonhof@users.noreply.github.com>
Co-authored-by: vroonhof <38109466+vroonhof@users.noreply.github.com>
…other data elements

The assertion fires in both strict and tolerant modes. When tolerance
is on, unknown contained elements are filtered out after the assertion.

Co-authored-by: vroonhof <vroonhof@users.noreply.github.com>
Updated README to clarify enhancements and features of the vendored ibflex library.
…date

Mark package as vendored with version suffix and documentation
Added `liteSurchargeAccrualsLong`, `liteSurchargeAccrualsShort`, `cgtWithholdingAccruals`, `cgtWithholdingAccrualsLong`, and `cgtWithholdingAccrualsShort` to `EquitySummaryByReportDateInBase` dataclass in `ibflex/Types.py` to fix parsing errors reported in issue #132.
Added a regression test `tests/test_equity_summary_fields.py` to verify the fix.

Co-authored-by: vroonhof <38109466+vroonhof@users.noreply.github.com>
…664759381441106

Fix missing fields in EquitySummaryByReportDateInBase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants