Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

txn vs pricedb pricing?

27 views
Skip to first unread message

Jim Robinson

unread,
Feb 8, 2025, 2:16:45 PMFeb 8
to Ledger
Hi folks,

This morning I was chasing down a mismatch between what ledger was producing and what my spreadsheets were producing for the balance of some stocks.

It looks like the issue is that on 2025-02-07 midday I bought some shares and so ledger logged the price of the shares using that txn entry.  Meanwhile, at market EOD, I also have a script that updates the pricedb file with the closing prices.

Neither entry, ledger txn or pricedb entry, has a timestamp. I am inferring that ledger was  coded to decide to use the last txn entry to determine the "current" price of the shares when one is available, otherwise use the last pricedb entry?

One obvious way to work around this would be to add another pricedb entry using today's date, but I was wondering if there was some better way to tell ledger to prefer the pricedb entry?

2025-02-07 * (e4e4b4703903) Schwabb - Buy
    Assets:Schwabb:VXUS        2.4191 VXUS @@ $150.00
    Assets:Schwabb:Cash Sweep

$ date
Sat Feb  8 01:12:11 PM CST 2025

$ grep VXUS ~/.pricedb | tail
P       2025-01-27      VXUS    $60.72
P       2025-01-28      VXUS    $60.79
P       2025-01-29      VXUS    $60.80
P       2025-01-30      VXUS    $61.53
P       2025-01-31      VXUS    $60.92
P       2025-02-03      VXUS    $60.31
P       2025-02-04      VXUS    $61.08
P       2025-02-05      VXUS    $61.48
P       2025-02-06      VXUS    $61.75
P       2025-02-07      VXUS    $61.35

$ ledger pricedb VXUS | tail
P 2025/01/27 00:00:00 VXUS $60.72
P 2025/01/28 00:00:00 VXUS $60.668380462725
P 2025/01/29 00:00:00 VXUS $60.80
P 2025/01/30 00:00:00 VXUS $61.53
P 2025/01/31 00:00:00 VXUS $60.92
P 2025/02/03 00:00:00 VXUS $60.31
P 2025/02/04 00:00:00 VXUS $61.08
P 2025/02/05 00:00:00 VXUS $61.48
P 2025/02/06 00:00:00 VXUS $61.75
P 2025/02/07 00:00:00 VXUS $62.006531354636


Jim

John Wiegley

unread,
Feb 8, 2025, 6:36:49 PMFeb 8
to Jim Robinson, Ledger
>>>>> "JR" == Jim Robinson <jim.ro...@gmail.com> writes:

JR> Neither entry, ledger txn or pricedb entry, has a timestamp. I am
JR> inferring that ledger was  coded to decide to use the last txn entry to
JR> determine the "current" price of the shares when one is available,
JR> otherwise use the last pricedb entry?

Yes, this is exactly right.

JR> One obvious way to work around this would be to add another pricedb entry
JR> using today's date, but I was wondering if there was some better way to
JR> tell ledger to prefer the pricedb entry?

It was intended taht you add a price entry with a later time. For example, a
price entry at midnight the next day or 23:59 that day, should be taken as
“truth” for all entries of that day.

John

Jim Robinson

unread,
Feb 8, 2025, 9:56:05 PMFeb 8
to Ledger
Thank you!  I never realized the pricedb format would accept a timestamp.

Tavis Ormandy

unread,
Feb 18, 2025, 5:54:52 PMFeb 18
to ledge...@googlegroups.com
On 2025-02-09, Jim Robinson wrote:
> Thank you! I never realized the pricedb format would accept a timestamp.
>

If you can't add timestamps to your workflow immediately, a temporary
solution could be using the (@@) syntax. That should be identical to @@,
except the price history isn't affected!

I use this for lots I only have the average cost basis for, and don't
want to pollute the pricedb.

Tavis.


--
_o) $ lynx lock.cmpxchg8b.com
/\\ _o) _o) $ finger tav...@sdf.org
_\_V _( ) _( ) @taviso

Reply all
Reply to author
Forward
0 new messages