This example shows how to calculate the average cost of shares.
When dealing with shares, ledger keeps a separate record based on
purchase price and date.
Let's take a simple example:
2014-01-01 * Opening balances
Assets:Cash 100.00 GBP
Equity:Opening balances
2014-02-01 * Buy 1 AAA for 10 GBP
Assets:Investments 1 AAA @ 10.00 GBP
Assets:Cash -10.00 GBP
2014-03-01 * Buy 1 AAA for 20 GBP
Assets:Investments 1 AAA @ 20.00 GBP
Assets:Cash -20.00 GBP
Now you can run: ledger bal --lots assets:investment
to see the exact information:
1 AAA {10.00 GBP} [2014/02/01]
1 AAA {20.00 GBP} [2014/03/01] Assets:Investments
In order to calculate the average cost, you need to create a
transaction which removes all existing lots (make sure to get
cost and date right) and adds the correct number of the commodity at
the total price:
2014-03-02 * Calculate average cost of AAA
Assets:Investments -1 AAA {10.00 GBP} [2014-02-01] @ 10.00 GBP
Assets:Investments -1 AAA {20.00 GBP} [2014-03-01] @ 20.00 GBP
Assets:Investments 2 AAA @@ 30.00 GBP
Now ledger contains the average price:
ledger -f funds.ledger bal --lots assets:investments
2 AAA {15.00 GBP} [2014/03/02] Assets:Investments
--
Martin Michlmayr
http://www.cyrius.com/
--
---
You received this message because you are subscribed to the Google Groups
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.