Martin,

I think I have now done enough reading and testing (both beancount and 
ledger), that I can continue conversation without sounding too stupid 
(forgive me, if it is still  the case)

So, effectively what I think I want

*Step 1:* I run a report, which shows my Net Worth, converted to single 
currency at certain date, using all exchange rates valid for that date. Let 
us call it Day A Net Worth Report 

I think in beancount query language such report will look like this

select account, SUM(convert(position, 'CurrencyCode',<Date A>)) from close 
on <Date A> WHERE account ~'Assets' OR account ~'Liabilities'

This query will give me some output, similar to:

       account             sum_convert
---------------------- -----------------
Assets:US:PaymentUSD        12300.0 EUR
Assets:Broker:stock:XYZ      2100.0 EUR
Liabilities:DE:creditCard   -3000.0 EUR      

So my net worth is 11400.00 Euro (I didn't find a way how to make beancount 
query to put a total)



*Step 2* I run the same report, but for day B (which is after day A).

*Step 3:* And now I want a single report, which will show how I got from *Day 
A net Worth*  to *Day B Net Worth.  *I want to have a set of numbers, 
which, when I add them together, will give me exactly the difference in Net 
Worth between pints A and B
 

I even have written a document 
<https://docs.google.com/document/d/1z57E8KZ9hIF71s39dDKaE5ow1N7BdJ-eX8y2BFjR9kc/edit?usp=sharing>,
 
which describes how I think this can be achieved, document contains example 
spreadsheet 
<https://docs.google.com/spreadsheets/d/1-wdXsPcBLjbYO9qLi924X2JWPw8plkWeGbSdjttcsZY/edit?usp=sharing>
 with 
formulas, for very simple case

I think it shall work like this:



   1. 
   
   Expenses and Incomes are tracked at the historical exchange rate (e.i. 
   at the exchange rate, available during transaction). When exchange rate 
   changes, Expenses and Income do not get re-calculated.  
   
This is believed to be inline with conventional wisdom , that if you have 
consumed pizza for 100 USD, there is no reason to re-calculate how much 
this pizza is worth now in EUR, when USD/EUR exchange rate changed. It only 
makes sense to know how much that pizza was worth in EUR, when you consumed 
it.


   1. 
   
   Assets and Liabilities on the other side are recalculated with every 
   event of exchange rate change.  
   
This is also inline with conventional wisdom. If instead of consuming 100 
USD in a form of pizza,  you put them in a bank account and all of a sudden 
this USD currency became more expensive vs EUR, this means you actually got 
reacher in terms on EUR and you want to see it. 


   1. 
   
   The exchange rate changes are taken care in the following way:
   
A special Commodity Revaluation transaction is logged. Following the 
principle of double-entry accounting 

   - 
   
   one shoulder of transaction is logged to corresponding Asset and / or 
   Liability accounts to adjust these accounts to new exchange rate. 
   
another shoulder is logged to special Gain due to commodity price change 
(trading 
account, using Peter Selinger’s terminology). 


In my example I do not distinguish realized and unrealized gain. I just 
create some virtual income account "Gain due to commodity price change". 
this term shall cover everything: gain due to stock price change as well as 
due to currency exchange rate.  This is because from one side, the term 
"realized gain" is closely linked to the term "taxable gain", hence depends 
on local legislation. From the other side, for the gain first becomes 
unrealized and only then, one can realize it (say by selling the stock).   Gain 
due to commodity price change the same.

So, using example from beancount documentation 
<https://docs.google.com/document/d/1WjARst_cSxNE-Lq6JnJ5CC41T3WndEsiMw4d46r2694/edit#>
 
converting unrealized gain to realized shall look like this

2014-02-17 * "Selling some IBM"
 Assets:US:ETrade:IBM                             -3 IBM {160.00 USD} @ 
170.00 USD
 Assets:US:ETrade:Cash                              500.05 USD
 Expenses:Financial:Commissions                       9.95 USD
 
*Income:GainDueToCommodityPriceChange:realized         -30 
USD Income:GainDueToCommodityPriceChange:unrealized        30** USD *





Does it make any sense?


Once again, this is all driven by idea to have an explanation on how I got 
from Day A net Worth to Day B Net Worth. 
I must say I still don't understand how people who do trading and spend and 
get paid in different currencies live without such report. I just wouldn't 
trust calculation, if I can't see how I got from A to B.


Note: In my document 
<https://docs.google.com/document/d/1z57E8KZ9hIF71s39dDKaE5ow1N7BdJ-eX8y2BFjR9kc/edit#>you
 
can see, that I have tested ledger, and  It looks like ledger does 
calculation as per desired calculation method, however it seems not to be 
possible to produce a single income statement-like report. One would have 
to query ledger is different ways and paste together different parts of 
different reports, to get the situation as presented in Appendix A 
<https://docs.google.com/document/d/1z57E8KZ9hIF71s39dDKaE5ow1N7BdJ-eX8y2BFjR9kc/edit#heading=h.ibvb27d8cznn>

It has been later found however, that on more complex example, ledger 
produces results with unrealized gains, which appear to be wrong.  See more 
details here 
<https://groups.google.com/forum/#!topic/ledger-cli/t8spw-5sXt8>.





>>

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/d3086e02-6ce7-4b0e-b7ee-d45da5877a96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to