fava
fava copied to clipboard
Support for multiple levels of currency conversions
I am new to beancount! Thank you for this great visualization tool!
Given a simple beancount file with three commodities: EUR, USD and some imaginary stock called HOOL which is tracked in USD.
option "operating_currency" "EUR"
option "operating_currency" "USD"
2022-01-01 open Equity:Opening-Balances
2022-01-01 open Assets:US:HOOL
2022-01-01 open Assets:Cash
2022-01-30 * "Some stock" ""
Equity:Opening-Balances -100 HOOL
Assets:US:HOOL 100 HOOL
2022-01-30 * "Some USD" ""
Equity:Opening-Balances -100 USD
Assets:Cash 100 USD
2022-01-28 * "Some EUR" ""
Equity:Opening-Balances -100 EUR
Assets:Cash 100 EUR
2022-01-30 price HOOL 100 USD
2022-01-30 price EUR 1.25 USD
2022-02-28 price HOOL 200 USD
2022-02-28 price EUR 1.12 USD
When Converting to USD, both HOOL and EUR are converted, but when converting to EUR, only USD is converted, but not HOOL:
| USD | EUR |
|---|---|
![]() |
![]() |
I had a quick look at the source and seems like that beancount.core.convert.convert_position only resolves "one level deep", there is also a beancount.core.convert.convert_amount which supports multiple levels of conversion, but not for positions, but just amounts.
In my mind there are multiple solutions:
- Workaround, I could also put HOOL prices in EUR into the DOC
- Extend the function on fava side (e.g. by permutating the pricemap, or extending the existing function, e.g. like with
get_market_value)
It will work if you change it as below. i.e. specify the cost. I can't remember the mechanics of why (presumably the conversion is based on cost and not price) but this is a more realistic entry to have in your journal anyway.
@@ -7,6 +7,6 @@
2022-01-30 * "Some stock" ""
Equity:Opening-Balances -100 HOOL
- Assets:US:HOOL 100 HOOL
+ Assets:US:HOOL 100 HOOL {1 USD}
Even if you add the cost in USD for a HOOL purchase, the report tables will not convert down to EUR even if there is a USD-EUR price quote in the file.
If you use, say, beanprice to automate price quote retrieval, some commodities will not be available in the desired currency through the available APIs. But we could chain multiple conversions.
It would be great to be able to specify HOOL-USD and USD-EUR quotes (fetchable from APIs) and have the reports converted all the way down to the desired currency - EUR in this case.
With #1722, you can now select multiple currencies - the conversions will be performed in sequence
Thanks, I guess you meant to link #1732!

