buy&hold code problem

immy

New Member
#1
How to code simply "buy and hold" of portfolio of 5 stocks using AFL with dynamic positionsize?
I mean buy open of first day and sell close of the last day of the series.

The problem is I need to calculate total profit of following investment:
Buy 5 stocks at first day open and hold;
Positionsize=20% of equity;
Sell all positions at close of last day.

But the problem is more complicated because the first date is different for each stock.
First stock is traded from 1970 till now, other were not available at that time. So actually when buying 1st stock position size is 100% of equity. When second stock is started to trade position size is 50% of equity to each stock. Then one day all 5 stocks are traded so positionsize is 20% of actual equity to each.

Many thanks for your help!
 

Similar threads