Updating lot information for an automated transaction

54 views
Skip to first unread message

samt

unread,
Feb 15, 2021, 6:26:52 PM2/15/21
to Ledger
I am trying to track previously sold lots in ledger using automated transactions. I have created this automated transaction rule to achieve this:

= /^Assets:Investments:/ & (expr amount < 0) & tag("realized-capital-gains")
    (Sold Lots:$account)  (-1 * amount)


I wanted to know if it's possible for me to update the lot details for these transactions; in particular, I wanted to add a customized note to the generated lot indicating the date of sale and the sale price per share.

- Sam

samt

unread,
Mar 7, 2021, 12:51:04 PM3/7/21
to Ledger
Any guidance on this? It would really help me a lot to have the sale date and sale price of each of these "Sold Lots" lots. I need to be able to determine the fraction of the capital gain that was earned in the calendar year of the sale (i.e. (asset sale price) - (asset price on Jan 1st in the year of the sale)).

John Wiegley

unread,
Mar 7, 2021, 1:35:51 PM3/7/21
to samt, Ledger
>>>>> "s" == samt <tetruash...@gmail.com> writes:

s> Any guidance on this? It would really help me a lot to have the sale date
s> and sale price of each of these "Sold Lots" lots. I need to be able to
s> determine the fraction of the capital gain that was earned in the calendar
s> year of the sale (i.e. (asset sale price) - (asset price on Jan 1st in the
s> year of the sale)).

What I do is assign a unique identifier to each "position", so that by
querying later I can see every transaction related to that position, including
those short-term sales and repurchases that do nothing more than effect the
cost basis.

Btw, I'm working on a new utility called "trade-journal" that is a simplified
Ledger focused just on keeping a trading journal, which converts its input
files into properly annotated Ledger files, thus saving you from most of the
calculation and repetition.

https://github.com/jwiegley/thinkorswim/tree/master/trade-journal

John
Reply all
Reply to author
Forward
0 new messages