I want to keep track of the full price I've payed for investments on ledger, to know the weighted average price.

So given the following register taked from the documentation:

2004/05/01 Stock purchase
    Assets:Broker                     50 AAPL @ $30.00
    Expenses:Broker:Commissions        $19.95
    Assets:Broker                  $-1,519.95  ; note_1

I can use an automated transaction to know how many AAPL I have using something like:

= expr ( commodity == 'AAPL' and /^Assets:/)
    (Allocation:Equities)             1.000

This way I can now how much AAPL I currently have, but I cannot know how much I have invested, specificaly I would like to keep track of all the postings like the one with the note_1 on the first example.

This way I can keep track of the total price I've payed for the investments I have, that can be calculated by:

$-1,519.95 / 50 AAPL

Is there any good way to keep track of that?


ledger-cli v3.2.0 (released on May 1, 2020) introduced a new option: --average-lot-prices (reports the average price at which each commodity was purchased in a balance report).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.