Portfolio Report calculation issue

19 views
Skip to first unread message

sagarthaker

unread,
Sep 8, 2010, 6:18:45 AM9/8/10
to jGnash-User
Hi Craig,

I am using jGnash 2.4.1. I have found following issue with the
Portfolio report calculation. (After it started running. :))

I have done following transactions for one stock in past one year


DATE TRANSACTION PRICE QTY
1-Jan-09 BUY 546.80 30
30-Mar-09 SELL 889.00 30
1-Feb-10 BUY 296.75 50

As per above transactions, I have bought and sold same security over a
period of time.
As per the calculations, my Actual Reliased Profit is 10266 and Avg.
Price of the Stock is 296.75 as on date.

If I run the report on 30-Mar-09, I will also see the realized profit
as 10266.

But after the Buy transaction goes for a toss.
Now I see following data in the report
Reliased Profit as per report = 14954 and Avg. Price is 390.52.

As per my observation the report is designed to take all the buy
transactions to calculate the avg. price and that is being used to
calculated rest of the values.
But in my opinion the report should work on FIFO basis to calculate
values, to have correct realized profit as well as avg. price.
Hope this example clarifies the issue.

Regards,

Sagar





Craig Cavanaugh

unread,
Sep 8, 2010, 6:52:28 PM9/8/10
to jgnas...@googlegroups.com
I see and understand.  The RG is currently based on average sale price

Over a set of transactions, the following algorithm is used per each security

Total Sales are calculated
Total Shares sold are calculated

Avg Sale Price is calculated as: Total Sales / Total Shares
RG is calculated as: (Avg Sale Price - Cost Basis Per Share) * Total Shares Sold

The code can be viewed at the link below.
http://jgnash.svn.sourceforge.net/viewvc/jgnash/jgnash2/trunk/src/jgnash/engine/InvestmentPerformanceSummary.java?revision=2133&view=markup

The above calculate correlates well with other portfolio reporting applications.  That does not mean it is correct, and maybe there should be an option for both forms of calculations.

I had planned to go back at a later date and add Lot based calculations to support real time gains calculations.  This would support a FIFO based calculation.

On the slate next is to merge in a change to support reversed sign on certain type of reporting for non-accountants for the 2.5.0 release, and being adding budgeting functionality for 2.6.0 along with a database upgrade.

I will add FIFO based calculation to the TODO list, and if you want, you could create a new feature request on SF.  I do want to knock out budgeting to round out the feature set of jGnash.

Thanks,
Craig

sagarthaker

unread,
Sep 9, 2010, 12:58:54 AM9/9/10
to jGnash-User
Hi Craig,

Thanks for the explanation.
I have added a feature request in SF.

Regards,

Sagar


On Sep 9, 3:52 am, Craig Cavanaugh <jgnash.de...@gmail.com> wrote:
> I see and understand.  The RG is currently based on average sale price
>
> Over a set of transactions, the following algorithm is used per each
> security
>
> Total Sales are calculated
> Total Shares sold are calculated
>
> Avg Sale Price is calculated as: Total Sales / Total Shares
> RG is calculated as: (Avg Sale Price - Cost Basis Per Share) * Total
> Shares Sold
>
> The code can be viewed at the link below.http://jgnash.svn.sourceforge.net/viewvc/jgnash/jgnash2/trunk/src/jgn...
> <http://jgnash.svn.sourceforge.net/viewvc/jgnash/jgnash2/trunk/src/jgn...>
Reply all
Reply to author
Forward
0 new messages