Financial contract 2 - Average annual return computed in two ways.

  • Thread starter JohanL
  • Start date
155
0
First i calculate the the average annual return for the Dow jones industrial average
over the last 22 years by using the first and last value.

To continue writing my code i also need to calculate
the average return between two days separated by one year
for every day over the last 22 years.

Shouldnt these two numbers be the same?



clear

fid = fopen( 'DJ30Daily.csv', 'r' );
str = fread( fid, '*char' );
sts = fclose( fid );
str( str == '"' ) = [];
str( str == ',' ) = '.';
cac = textscan( str, '%f' );

DJ30Daily = cell2mat(cac);

DJ30Daily = DJ30Daily(121:5668);

n=length(DJ30Daily);

K=DJ30Daily(n)-DJ30Daily(1);

P=(K/DJ30Daily(1));

AverageAnnualReturnPercentLast22y = nthroot(P, 22)


m=252-1;

d=n-m;

Ptot=0;


for i=1:d

K2=DJ30Daily(i+m)-DJ30Daily(i);
P2=K2/DJ30Daily(i);

P2=P2+1;

Ptot=Ptot+P2;

end


AverageReturnBetweenDaysSepartedBy1yearOverTheLast22years=Ptot/d



******************************

AverageAnnualReturnPercentLast22y =

1.0575


AverageReturnBetweenDaysSepartedBy1yearOverTheLast22years =

1.0863
 

Want to reply to this thread?

"Financial contract 2 - Average annual return computed in two ways." You must log in or register to reply here.

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top