Closing lots when brokers report dissimilar cost basis (IBKR)

103 views
Skip to first unread message

nug get

unread,
Apr 13, 2024, 4:30:58 AMApr 13
to Beancount
Hi everyone
I recently closed some positions I held at InteractiveBrokers, for which i have a nice API-based ingestion pipeline to beancount. However I noted lots of "No position matches"-Errors.
Turns out, the reported cost basis / Trade prices  of the closed positions are very slightly off (by a handful of USD-cents) the reported cost basis at purchase. As a result, beancount can't match the lots.

  1. Has anyone dealt with this specific issue with IBKR before?
  2. What would be your best practice?
    1. change the cost basis reported at opening time to match the cost basis at closing time?
    2. change the cost basis reported at closing time to match the cost basis at opening time?
    3. ...?
Below a sample pair of transactions, as i obtain them via the FlexQuery API.note the $172.74 vs. $172.86
Thanks for any hints!
nugget

2022-04-08 * "VBR" "BUY 3 VBR @ 172.74 USD"
  Assets:Invest:IB:VBR             3 VBR {172.74 USD, 2022-04-08}
  Assets:Invest:IB:USD       -518.22 USD
...
2024-03-04 * "VBR" "SELL -3 VBR @ 183.81 USD"
  Assets:Invest:IB:VBR               -3 VBR {172.86 USD, 2022-04-08} @ 183.81 USD


nug get

unread,
Apr 13, 2024, 4:33:08 AMApr 13
to Beancount
just to add, my pdf activity statements from IBKR also state those two different costs ("T.Price") in activity statements from 2022 and today, so the numbers are clearly coming from them

Justus Pendleton

unread,
May 8, 2024, 10:27:35 PMMay 8
to Beancount
This is (probably, I've never looked at what FlexQuery reports) IBKR adding the transaction costs to the cost basis (which is how US tax accounting works). So when you buy something it will have a (very slightly) higher cost basis than whatever the order execution said.

nug get

unread,
May 12, 2024, 10:13:46 AMMay 12
to Beancount
Yes, IBKR actually confirmed exactly this to me: in the opening transactions, fees get included in the cost bases. not so in the closing transactions. This seems the standard, so rather a general thing than a IBKR-specific issue.

What would be the beancounter's way of handling this?
I dont know anything better than manually resolving the "No position matches" errors one at the time by matching and correcting the cost bases. Since my personal investment style does not involve too many individual trades this works for me, but i assume this gets out of hand quickly for more active folks?
How is everyone else going about this?

Justus Pendleton

unread,
May 13, 2024, 10:21:52 PMMay 13
to Beancount
On Sunday, May 12, 2024 at 9:13:46 PM UTC+7 nugget....@gmail.com wrote:
What would be the beancounter's way of handling this?
I dont know anything better than manually resolving the "No position matches" errors one at the time by matching and correcting the cost bases. Since my personal investment style does not involve too many individual trades this works for me, but i assume this gets out of hand quickly for more active folks?
How is everyone else going about this?

You need to enter the initial transaction with the proper price. In your example that means 172.86, not 172.74. Isn't that number reported in your initial trade confirmation? I don't remember where I get it from. I enter that into my ledger manually, since I don't trade and only have one or two transactions every few years.
Reply all
Reply to author
Forward
0 new messages