Lot prices data in csv report

4 views
Skip to first unread message

Pranshu Goyal

unread,
Oct 2, 2025, 1:03:46 AM (yesterday) Oct 2
to Ledger
I'm trying to write a script to calculate capital gains. For this I intend to get a csv register report on some accounts with lot prices data, and then do the capital gains calculation in the script. But the csv report with such a query doesn't give me lot prices data:

> ledger csv stocks --lot-prices

It only outputs the number of units bought or sold. I also tried looking into format strings but found no option to get lots data. Am I missing something or the feature isn't there?

Igbanam Ogbuluijah

unread,
Oct 2, 2025, 3:01:53 AM (yesterday) Oct 2
to ledge...@googlegroups.com
I may not fully understand this, but does bal -G work? If you have the details in ledger, and you're looking for gains at a particular time, this should work; no?


Igbanam


--

---
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 ledger-cli+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ledger-cli/5ce280cd-88f8-44e2-8d82-1e59119dd942n%40googlegroups.com.

Pranshu Goyal

unread,
Oct 2, 2025, 8:21:22 AM (21 hours ago) Oct 2
to ledge...@googlegroups.com
I didn't know about this option, thanks for introducing it. I tried it out. It does what it says on the tin, and works even for csv reports, but I see these issues:

-  it doesn't seem to work with dates. None of the date filters, -b, -p seem to narrow the report for a period. I need this to figure out capital gains(realized) in a financial year.
- I'm unable to use --unrealized to figure out the realized gains from the total gains. In my data there's a commodity with just two transactions, first bought and then all units sold at a loss. For this commodity the --unrealized flag calculates the loss correctly but shows it as unrealized which seems to be incorrect, as when the commodity is sold the loss becomes realized.

These issues aside, in principle it should solve my problem. Yet it doesn't because not all capital gains are considered equal due to the ever changing minutiae of tax laws which ledger can't be expected to incorporate. I'm trying to use ledger for comprehensive tax filing, and Capital gains is the only part remaining. Hence I turned to scripting on the generated csv reports.

Pranshu Goyal


You received this message because you are subscribed to a topic in the Google Groups "Ledger" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ledger-cli/zCeEnQTyVAU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ledger-cli+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ledger-cli/CAOmRJrcyzkLXZEfdHn5ScDnSBMpRuDF1uVgpb9qWFMBsVamoLg%40mail.gmail.com.

Igbanam Ogbuluijah

unread,
3:36 AM (1 hour ago) 3:36 AM
to ledge...@googlegroups.com
I'm glad my suggestion opened up a solution pathway!

I'm no accountant; just a curious dev. So I know even less about tax laws around capital gains. There's not much I can do at this point with out an example ledger. If you can, without sharing details of what you're working on, please share an example ledger which has the issues you're trying to solve. If I can't get to it, someone else in the group can.

Thank you!


Igbanam


Reply all
Reply to author
Forward
0 new messages