Skip to content

IBKR: don't double count transfers reported as Transfer and TransferLot - #441

Merged
vroonhof merged 1 commit into
mainfrom
ccr-d1421f0c-zo8zx4
Oct 27, 2026
Merged

vroonhof merged 1 commit into
mainfrom
ccr-d1421f0c-zo8zx4

Conversation

@vroonhof

Copy link
Copy Markdown
Owner

Fixes #440

Problem

When a Flex query has both the "Transfer" and "Lot" options selected under Transfers, IBKR reports each transfer once as a <Transfer> and again split up into <TransferLot> entries. ibflex puts both into stmt.Transfers, so the importer added the transferred quantity twice. This led to a confusing "negative balance" error.

Fix

As suggested in the issue discussion, the Transfer entry is treated as authoritative. A TransferLot is skipped when a Transfer exists for the same conid and date. A query that only has "Lot" selected is handled as before: TransferLots without a matching Transfer are still processed.

Changes

  • ibkr_importer.py: collect the (conid, date) keys of Transfer entries and skip TransferLot entries that match one.
  • Added a regression test with one Transfer of 84 shares plus TransferLots of 52.412 and 31.588. It checks that there is exactly one mutation of 84. The test fails without the fix.
  • docs/importer_ibkr.md: added a note that selecting both options is fine.

Testing

  • pytest tests/: 915 passed, 6 skipped
  • flake8 is clean on the changed files

Generated by Claude Code

When a Flex query has both the "Transfer" and "Lot" options selected,
IBKR reports each transfer as a Transfer and again split into TransferLot
entries. ibflex puts both into stmt.Transfers, so the quantity was counted
twice, leading to a confusing negative balance error. Skip TransferLot
entries that are covered by a Transfer for the same conid and date.

Fixes #440

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016RuX6myhTcq7NRKnWuD1h6
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T23:39:03.653501Z 06c58b4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

📄 Sample PDF and XML Preview

A sample Steuerauszug has been generated from vtandchill_2025.xml for this PR.

⬇️ Download

(Artifact expires in 14 days. Requires GitHub login to download. View workflow run)

@vroonhof
vroonhof merged commit 6c34ad7 into main Oct 27, 2026
7 checks passed
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.

IBKR: Having both "Transfer" and "TransferLot" entries in the xml file leads to double-counting of transfers

2 participants