Advanced portfolio report

Morrison J. Chang mjchang at ix.netcom.com
Sat Dec 1 18:29:03 EST 2007


On Sat, 2007-12-01 at 09:01 -0800, Andrew Sackville-West wrote:
> On Fri, Nov 30, 2007 at 10:51:32PM -0500, Mike Alexander wrote:
> > --On November 30, 2007 12:20:14 PM -0800 Andrew Sackville-West 
> > <ajswest at mindspring.com> wrote:
> >>

[some good stuff about corporate splits]

> On to lots:
> 
> >>> If there are lots assigned to the splits for a stock or other asset,
> >>> the report should use them.  In this last case, the sale was part of
> >>> the second of three acquisitions.  This is correctly recorded in the
> >>> splits (which I realize is hard to do now, but someday it might be
> >>> easier) and the report should really use this information to
> >>> determine  the basis for the shares sold like the lot scrubber does.
> >>
> >> I honestly don't have a clue about lots and how they work. Its very
> >> possible that I've duplicated code that the lots system already
> >> handles. However, it's not immediately clear to me that lots will be
> >> used and so we have to build for the case we know we have, which is
> >> the txn data. At this point, I'm not sure I'm really willing to go
> >> that deep into it, as my main goal is to get something usable out of
> >> the mess that curerntly exists. But maybe there's something obvious
> >> and simple that I'm missing.  Again, a test file would be great.
> >
> > Use of lots simply assigns a lot to each split that represents a purchase 
> > or sale of shares.  For the purposes of your report all I'm asking is that 
> > you ask each split what lot it is in and if you find a purchase and a sale 
> > in the same lot, you use that purchase to compute the basis for the sale.  
> > If the sale is not in a lot (or if you can't find the corresponding 
> > purchase in the lot, which indicates a bug) then use the FIFO, LIFO, or 
> > whatever rule to find the corresponding purchase.  It's pretty simple and 
> > wouldn't complicate things much at all.  You can use xaccSplitGetLot to get 
> > the lot a split is in.  Then, if this is not null, you can use 
> > gnc-lot-get-split-list to get a list of splits in the lot.
> 
> 
> Okay, I understand how that works. Basically I have to track the lots
> along with the price and number of shares in the basis list. The
> problem is how to deal with the "Average" basis. Currently, with the
> average-method, instead of tracking separate cells for each txn, it
> just collapses each txn into a single cell that gets adjusted
> along. So first I'd have to *not* collapse it into a single cell, but
> keep track of each txn. no biggie. The problem is how to adjust the
> average when you yank a lot out of the middle while also performing
> "non-lot" sales. I don't understand lots in the real world application
> and whether its a case of "once you use lots you must always use lots"
> or some other case. Here is an example of the situation, maybe you
> have some insight.
> 
> using average-method basis
> 
> 1/1/01 purchase 10 shares @ 50
> 1/2/01 purchase 10 shares @ 60 assigned to lot 1
> 1/3/01 purchase 10 shares @ 70
> 
> at this point basis is 30 shares at 60=1800 (regardless of method)
> 
> 1/4/01 sell 5 shares with no lot assignment
> 
> because its average basis, the new basis is 25 shares at 60 = 1500
> but, if we're trying to track lots, how do we apply that? which 5
> shares do we remove? If the sale is a lot sale, it gets easier,
> because you can recalculate the average with those specific shares
> removed. Does it work if we track the average separately all along and
> recalculate it when we get a lot sale? I just don't see how it would
> work if you hit a non-lot sale.
> 
> I'm not arguing against using lots here, BTW. Just trying to figure
> out this corner case. 
> 
> hmmm... having just re-read all this, it may be as simple as
> *ignoring* lots for the average-method, as it just doesn't apply.
> 
Andrew, you are correct. 
FIFO and lots are cost basis calculations.
Average basis is a different basis calculation.
'Once down the path of <basis> forever it will control your destiny' [or
at least that account] 

http://www.irs.gov/publications/p564/ar02.html#d0e1350

Here are some additional links to IRS publication that might be useful.

http://www.irs.gov/faqs/faq-kw34.html

http://www.irs.gov/pub/irs-pdf/p550.pdf
http://www.irs.gov/pub/irs-pdf/p564.pdf

Of course since the report applies the same rule to all accounts
regardless of intent, hopefully the user knows better and talks to their
accountant or tax advisor.

-Morrison



More information about the gnucash-devel mailing list