Hi folks,
   I have some stock purchases that I have specified using total costs. 
Because of not-round-numbers, I'm having trouble specifying the lot so I 
can sell it cleanly.

Here's an example:

2023/11/01 * Buy Shares
    Assets:401K                             6.456 FSKAX @@ $734.43
    Income:Opening Balances              -$734.43

2023/11/02 * Sell Shares
    Assets:401K                            -6.456 FSKAX {$113.7592936803} 
[2023/11/01] @ $120.00
    Income:Capital Gains                  -$40.29
    Assets:401K                           $774.72

The first transaction uses the total posting cost. To record the second 
transaction, I ran, `ledger --lots balance Assets:401K`. I copied that $113 
number verbatim as printed.

So I've sold all the shares, but now when I run `ledger --lots balance 
Assets:401K`, the result is:

             $774.72
6.456 FSKAX {$113.7592936803} [2023/11/01]
-6.456 FSKAX {$113.7592936803} [2023/11/01]  Assets:401K

So it looks like the lot I sold doesn't quite match what ledger thinks I 
owned. I anticipate the issue is that the precision used in printing is 
different than the precision used to store lots internally.

I tried selling using the total posting cost:

2023/11/02 * Sell Shares
    Assets:401K                            -6.456 FSKAX {{$734.43}} 
[2023/11/01] @ $120.00
    Income:Capital Gains                  -$40.29
    Assets:401K                           $774.72

That works great as long as I sell whole lots. But as soon as I try to sell 
a partial lot, it doesn't work at all. (The capital gains are not 
calculated correctly.)

The best idea I have right now is to just not use total posting costs, and 
always use the per-share price. But I find total posting costs to be 
convenient for many use cases.

Any suggestions?

Thanks folks!
Bob Wilson

-- 

--- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/94432f4e-fa9d-42af-8b76-3f2924c12b3bn%40googlegroups.com.

Reply via email to