Allow rounding when all value amounts are fixed

53 views
Skip to first unread message

Daniel

unread,
Jan 21, 2024, 6:10:56 AM1/21/24
to Beancount
I am trying to use this entry that beangulp exports:
2023-12-22 * "Buy XYZ" "Buy 86.546 XYZ with 6987.69 USD @ 80.74 USD/XYZ"
Assets:Account:USD -6987.69 USD
Assets:Account:XYZ 86.546 XYZ @ 80.74 USD
 But when I run bean-check, I get: Transaction does not balance: (0.03404 USD)

XYZ is tracked to 3 decimal places and USD is tracked to 2 decimals. 
The way the institution does the calculation is to divide the USD by the price to get the amount of XYZ, then rounds to 3 decimal places.

6987.69/80.74 = 86.5455783998 -> 86.546
However, it looks like beancount tries to multiply 86.546*80.74=6987.72404, which gives the 0.03404 error.

I would rather not have a
6987.69 USD @ 1/80.74 XYZ entry, as because I am using beangulp, I think it would convert it to an ugly decimal after exporting

Is there a way to let beancount allow this entry without destroying the tolerances for all the transactions?

Max Tower

unread,
Jan 21, 2024, 3:21:25 PM1/21/24
to Beancount
One option is to add a blank account to the list to gobble all the rounding errors like this:

2022-11-16 * "BUY AAPL stock"
Assets:Brokers:Etrade:AAPL 145 AAPL @ 114.567 USD
Assets:Brokers:Etrade:Cash -16611.20 USD
Equity:Rounding-Errors:Etrade

I think if you do this, you'll want to make sure that it doesn't deviate from your real account's rounding so your beancount remains in sync with the real account.

Max
Reply all
Reply to author
Forward
0 new messages