Is this behavior expected?

29 views
Skip to first unread message

Marcelo Muñoz

unread,
Jul 28, 2025, 10:37:39 PMJul 28
to Ledger
in the doc, it shows this example,

2012-04-10 My Broker
    Assets:Brokerage            10 AAPL @ $50.00
    Assets:Brokerage:Cash      $-500.00

2012-04-10 My Broker
    Assets:Brokerage            10 AAPL {$50.00}
    Assets:Brokerage:Cash      $-500.00


and the doc says they're functionally equivalent.
Taking this example, I built this other one, but
Ledger says the second doesn't balance.

2004/05/01 Stock purchase
    Assets:Broker                                 49 AAPL @ $30.00  
    Assets:Broker                                  1 AAPL {$30.00}  
    Expenses:Broker:Commissions               $19.95
    Assets:Broker                         $-1,519.95

but this does

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


Is this behavior expected? If I'm wrong, could you point me to the
appropriate documentation for me to understand?

Marcelo Muñoz

unread,
Jul 28, 2025, 10:39:57 PMJul 28
to Ledger
Hi guys! I'm a bit confused. Reading section '5.17 Prices versus costs'

in the doc, it shows this example,

2012-04-10 My Broker
    Assets:Brokerage            10 AAPL @ $50.00
    Assets:Brokerage:Cash      $-500.00

2012-04-10 My Broker
    Assets:Brokerage            10 AAPL {$50.00}
    Assets:Brokerage:Cash      $-500.00


and the doc says they're functionally equivalent.
Taking this example, I built this other one, but
Ledger says that don't balance


2004/05/01 Stock purchase
    Assets:Broker                                 49 AAPL @ $30.00  
    Assets:Broker                                  1 AAPL {$30.00}  
    Expenses:Broker:Commissions               $19.95
    Assets:Broker                         $-1,519.95

but this does

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


Is this behavior expected? If I'm wrong, could you point me to the
appropriate documentation for me to understand?

John Wiegley

unread,
Jul 30, 2025, 7:13:54 PMJul 30
to Marcelo Muñoz, Ledger
>>>>> "MM" == Marcelo Muñoz <ma.muno...@gmail.com> writes:

MM> in the doc, it shows this example,
MM> 2012-04-10 My Broker
MM>     Assets:Brokerage            10 AAPL @ $50.00
MM>     Assets:Brokerage:Cash      $-500.00

MM> 2012-04-10 My Broker
MM>     Assets:Brokerage            10 AAPL {$50.00}
MM>     Assets:Brokerage:Cash      $-500.00

MM> and the doc says they're functionally equivalent.
MM> Taking this example, I built this other one, but
MM> Ledger says the second doesn't balance.

I’m a little surprised that the docs say these are functionally equivalent.

The first once balances $-500 against $500. The second balances $-500 against
10 AAPL {$50.00}. In terms of the cost basis they are equivalent, but there is
some extra magic that happens when @ is used, in order to balance the cost
against the cash position.

John
Reply all
Reply to author
Forward
0 new messages