fava icon indicating copy to clipboard operation
fava copied to clipboard

Wrong balance for converted values of Unrealized gain

Open alaruss opened this issue 3 years ago • 1 comments

I'm just starting with beancount/fava and trying to enter initial data to the ledger. My main currency is EUR but I have some stocks with price in USD. When I want to check the current balance with unrealized gains converted to the main currency I get the wrong value.

Here is an example of the ledger:

option "operating_currency" "EUR"
plugin "beancount.plugins.unrealized" "Unrealized"
plugin "beancount.plugins.implicit_prices"

2022-01-01 open Equity:Opening-Balances
2022-01-01 open Assets:Trading:AAPL  AAPL

2022-01-01 * "Buy Apple"
  Assets:Trading:AAPL                                      10 AAPL {100.0 USD}
  Equity:Opening-Balances 

2022-01-01 price USD 1.0 EUR


2022-08-01 price USD 1.0 EUR
2022-08-01 price AAPL 110 USD

When I check balance in fava with "At Cost" option everything is correct:

2022-08-01 U Unrealized gain Change: 100 USD    Balance 1100 USD
2022-01-01 * Buy Apple       Change: 1000 USD   Balance 1000 USD

But if I change to "Converted to EUR" I get wring value in the current Balance column

2022-08-01 U Unrealized gain Change: 100 EUR    Balance 1200 EUR
2022-01-01 * Buy Apple       Change: 1000 EUR   Balance 1000 USD

More interesting, if I choose "Converted to USD" I get the same result too

2022-08-01 U Unrealized gain Change: 100 USD    Balance 1200 USD
2022-01-01 * Buy Apple       Change: 1000 USD   Balance 1000 USD

Am I missing something in the ledger?

Beancount version 2.3.5 Fava version 1.22.2

image

alaruss avatar Aug 01 '22 14:08 alaruss

The various conversion options achieve something similar to the Unrealized plugin in Beancount, but more general (the "At Market Value" is basically the same thing). Fava and the plugin just don't really work together, since you get the unrealized gains added twice. On 2022-08-01 in your example, your Assets account contains both the original 10 AAPL {100 USD} and the unrealized gains of 100 USD, so converting that to USD you end up with 10*110 + 100.

See also #1022

yagebu avatar Aug 06 '22 09:08 yagebu