As promised, here is my post about portfolio calculations. I have some suggestions.
I think the calculation of (+/-), the variable $glPercent, is not the best approach for the real percentage of gain/loss, and I would prefer to redefine the Current Value too ($curValue).
In fact you buy 50 shares today for $120 each. The total value of the shares you have is 50X$120=$6000. If you pay $200 of fees, The total cost for you is $6200. If the share value rises to $150, your portfolio value would be 50X$150=$7500. The gain/loss must be calculated by market value of your shares - total purchase cost(incl. fees) = $7500-$6200=$1300. This represents a gain of 1300/6200=20.96%
According to your variable definition, the variable $glPercent is actually calculating the gain/loss as a percentage of the current value, and I also think that there is no need for a vaiable like $curValue. The current value is being calculated by market value of shares - fees. I think it is better to have a variable calculating purchase price + fees, instead of that.
What I propose is renaming the variable $curValue to, for example, $totalCost. Define $totalCost=$origCost+fees_ Change the variable $gainLoss=$curPrice-$totalCost and $glPercent=($curPrice-$totalCost)/$totalCost.
I would like to know the opinions of someone else about this. I have changed my index.php file. If someone wants to see, just let me know.
Joined: Aug 27, 2002 Posts: 15211 Location: Kansas
Posted:
Tue Feb 10, 2004 11:24 am
This was debated when it was first written. I had at least 2 stock savvy people directing me on this. That's one of the reasons that there are 2 different configurable ways for calculation open/close prices. I will leave the disucssion open to see what others think. OTOH, this is the joy of OpenSource - you can customize it for your purposes!
Ok. I prefer to do this in the way I posted here. If anyone is interested and prefer to have the script configured in the way I said, I will be more than happy to help, providing my configuration.
View next topic View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum