[Patch] reworked advanced-portfolio.scm

Derek Atkins warlord at MIT.EDU
Sat Feb 18 11:22:06 EST 2006


Andrew Sackville-West <andrew at farwestbilliards.com> writes:

>   It uses the
> pricedb to get the most recent price for a commodity and uses that
> price to calculate the value of a particular holding. It seems
> people are buying stocks but making no pricedb entry at the time of
> purchase. This breaks the report and also IMO breaks the books in

No, in this case the fact that it breaks the report means the report
is broken.  The "books" are not broken.  Indeed, ALL the reports
should "work" without any pricedb information.  Users can create and
destroy pricedb entries at will.  You should not assume they exist,
and it is certainly not an error for them NOT to exist.

> As I said above, the lack of a pricedb entry essentially breaks the
> advanced portfolio report as its currently written. I'm not opposed
> to making it work right, I'm just trying to make it work within its
> current basic design. But, using its current design, the user needs
> to make a pricedb entry to get it to work properly and I was trying
> to find a graceful way to handle the somewhat-broken state but still
> get some usable data out of it. your further input is appreciated.

IMNSHO this design is broken.  It should fall back to actual
purchase/sale price if the pricedb lookup fails.  IMHO it should also
look at txns nearest the date in question and use THAT in lieu of a
pricedb if the txn date is closer.

E.g., here's a problem case:

  Buy 100 shares on date T0
  pricedb entry on date T1
  pricedb entry on date T2
  Sell 50 shares on date T3

Let's assume that delta-t is something like a week or a month, or even
a year.  The value of the sale at T3 could be VERY DIFFERENT than the
value in the pricedb at time T2.  When looking at the value of your
holding at time T4, IMHO you should use the price from time T3, not
the price from time T2.

Perhaps we need some C code to make this easier to compute "on the
fly".  But it's IMHO how it should work.

> A

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list