* Tobias Pfeiffer <[email protected]> [2022-09-01 08:39]:
> However, I don't understand the example.
> 
>   2004/05/01 Stock purchase
>     Assets:Broker                     50 AAPL @ $30.00
>     Expenses:Broker:Commissions        $19.95
>     Assets:Broker                  $-1,519.95

This example is actually not ideal.  It would be better to write:

  2004/05/01 Stock purchase
    Assets:Broker                     50 AAPL {$30.00} @ $30.00

since that makes it clearer that you're creating what ledger calls a
"lot".

In order to understand what's going on with lots, it's very useful to
run "bal --lots".  This is important because ledger allows you to
remove lots that do not exist, so it's a good idea to run "bal --lots"
periodically -- anything in red is a bed sign.  In fact, the example
from the ledger tutorial is broken: the first transaction creates a
lot with a specific date, but the second transaction doesn't remove
that specific lot (since it doesn't specify the date).

For example the example you posted creates:

50 AAPL {$30.00} [2004-05-01]  Assets:Broker

This is a lot.  It was a cost ($30) and a date.

>   2005/08/01 Stock sale
>     Assets:Broker                    -50 AAPL {$30.00} @ $50.00
>     Expenses:Broker:Commissions        $19.95
>     Income:Capital Gains           $-1,000.00
>     Assets:Broker                   $2,480.05
> 
> Clearly the second transaction does not balance if I leave out the lot
> price "{$30.00}". What exactly is happening here with the lot price so
> that this transaction balances?

You sell 50 AAPL for $50, so that's $2500.  You also have a capital
gain of $20 per share ($50 - $30), so that's income of $1000; income
is negative in ledger, so that's -$1000.

* Tobias Pfeiffer <[email protected]> [2022-09-01 09:03]:
> So this looks like it is basically equivalent to
> 
>   2005/08/01 Stock sale
>     Assets:Broker                    -50 AAPL @ $30.00
>     Expenses:Broker:Commissions        $19.95
>     Income:Capital Gains           $-1,000.00
>     Assets:Savings                  $2,480.05
> 
> except that the former explicitly keeps the information about the sell
> price, and also tracks it in the price history, is that right?

Well, apart from the fact that it's incorrect (*) because you're in fact
not selling at $30.

(*) Incorrect in the sense that it doesn't represent the true nature
of the transaction.  It's not a faithful representation of what
happened.

The basic problem is that selling at $30 and selling something bought
at $30 at $50 leads to the same result:

50 * $30 = 1500

50 * $50 = 2500
50 * ($50-$30) = -1000 (capital gain)
----------------
Total     1500

So it's easy to get these sales wrong.  Maybe ledger should post the
capital gains to some account automatically so reduce errors but the
problem is that there might not be a single capital gains account, so
you'd need special syntax to specify where the capital gains/loss
goes.

-- 
Martin Michlmayr
https://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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/YxAT2XmbveK9EY/j%40jirafa.cyrius.com.

Reply via email to