price-db overwrites stock price set with @

38 views
Skip to first unread message

henry atts

unread,
Jan 22, 2021, 10:28:12 PM1/22/21
to Ledger
Say I have an entry in ledger.dat like this

2021/01/20 stocks
    Assets:Brokerage                           
    Assets:Bank:Checking           30 "XXX" @ €100.00

Then the output of  `ledger bal bank:checking' will be 3000€
With this entry in my price-db file

P 2021-01-20  XXX       €100.00

It will be the same. But when the share value changes some days later and I add a new entry
to the price-db file

P 2021-01-22  XXX       €200.00

from then on the bank account amount changes retroactively to 6000€. Which
would be great anyway, but it does not mirror the current situation, since I sold
the shares and want the price to be set for the day of the sale.

henry


Remco Rijnders

unread,
Jan 23, 2021, 5:43:29 AM1/23/21
to ledge...@googlegroups.com
On Fri, Jan 22, 2021 at 01:17:23AM -0800, henry wrote in
<01efc02b-9762-4299...@googlegroups.com>:
Hi Henry,

I think the problem here is that you are putting 30 XXX's into your checking
account. That is not what you want, you no longer have XXX's, but you have the
monetary value of them instead.

Do you get the expected result with a booking more like this?:

2021/01/20 stocks
Assets:Bank:Checking €3000.00
Assets:Brokerage -30 "XXX" @ €100.00

henry atts

unread,
Jan 23, 2021, 11:39:43 AM1/23/21
to Ledger
Hi Remco,

yah, that solves my problem. Great thanks!

Henry

Martin Michlmayr

unread,
Jan 24, 2021, 12:42:29 AM1/24/21
to ledge...@googlegroups.com
* Remco Rijnders <re...@webconquest.com> [2021-01-23 05:42]:
> Do you get the expected result with a booking more like this?:
>
> 2021/01/20 stocks
> Assets:Bank:Checking €3000.00
> Assets:Brokerage -30 "XXX" @ €100.00

Note that when selling, you should also specify the cost base (and
probably the date) of what you're selling.

In the example:

2020/08/08 Buy stocks
Assets:Brokerage 30 "XXX" @ €80.00
Assets:Bank:Checking -€2400.00

2021/01/20 Sell stocks
Assets:Bank:Checking €3000.00
Assets:Brokerage -30 "XXX" {€80.00} [2020-08-08] @ €100.00
Income:Capital gains -€600

You can do:
ledger bal Assets:Brokerage --lots
If you see something in red, you know there's a problem.

With the original example:

$ ledger -f d bal broker --empty
0 Assets:Brokerage
$ ledger -f d bal broker --lots
30 XXX {€80.00} [2020-08-08]
-30 XXX {€100.00} [2021-01-20] Assets:Brokerage

--
Martin Michlmayr
https://www.cyrius.com/
Reply all
Reply to author
Forward
0 new messages