Welcome
to Ganuenta
Actuarial & Financial Information Systems
Design & Copyright Axis® IT Last revised: 2012-01-30
Building a stock portfolio
«A careful portfolio manager will probably invest in stocks
from the blue chip list, building a sound portfolio, aiming
at a decent steady average dividend income. Of course,
shares will be sold but not as a rule. Under this policy
selling short is a mortal sin.»
G A N U E N T A
Consultancy
Actuarial & Financial Information Systems
Middelburg - The Netherlands
Determining Profit & Loss in a stock portfolio in a certain period of time is trivial when taking the algebraïc sum of the values of all stocks at the beginning of that period (balance), the value of the purchases and the values of the sales during that period.
However, if one is interested in which part is coming from or going into reservations for exchange rate differences, or which part may be considered as realized and which part is not, life is not that easy.
In that case the purchase value of the sold package is needed.
Two special cases need to be focused on:
- the results of an entire portfolio during the financial
year
- the profit & loss on a particular stock in a FIFO-
system.
In both cases a recursive function is needed, while case 2 involves the technique of splitting and assembling purchase packages of a particular stock, in order to assign the proper gains or losses on any sale transaction. This requires a second recursive funtion.
APL-like languages are extremely well suited for this purpose.
Please, have a look in the samples about how it is achieved.