Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Jun 21, 2012 #1
    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
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Financial contract 2 - Average annual return computed in two ways.
  1. Financial contract (Replies: 0)

Loading...