Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Annualized Sharpe ratios and Volatilities

    Good morning,

    I have Monthly excess returns of two portfolios P1 and P8 over 29 years. For my master thesis I have to state the Volatilities and SR in one number, while these two numbers should be annualized. So far I have tried different approaches to calculate the needed results but I'm not sure which is the formally correct code to do so.

    Here is an example of the code (for Portfolio P1) I think is correct and the data from 1990 and 1991. I know the Code Looks Kind of sloppy but I will put the calculations into loops later on.
    Code:
    egen Sd_P1= sd(P1), by(Jahr)
    gen Sd_Annual= Sd_P1*sqrt(12)
    
    gen SR= P1/Sd_P1
    gen SR_annual= SR*sqrt(12)
    egen SR_final= mean(SR_annual)
    
    //To get my SD for P1
    gen SD_final= Sd_Annual*sqrt(29)
      
     * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(date Jahr Monat P1 P8)
    360 1990  1  -.0019377362   -.003668688
    361 1990  2   .0008372813    .001459499
    362 1990  3 -.00022618668   .0019396635
    363 1990  4  -.0003067676   -.002378969
    364 1990  5   .0004768702    .005065726
    365 1990  6   .0006901055 -.00016673017
    366 1990  7  -.0012268435  -.0008285865
    367 1990  8  -.0027135995   -.005536701
    368 1990  9  -.0011730944   -.004750926
    369 1990 10  -.0017754886   .0002686236
    370 1990 11   .0014749074    .005864478
    371 1990 12   .0004333424   .0011803983
    372 1991  1   .0016687294    .005055216
    373 1991  2   .0041755983    .005791987
    374 1991  3   .0020613207   .0019960906
    375 1991  4    .002639579  .00008909535
    376 1991  5  .00054460054    .002296731
    377 1991  6  .00011390844  -.0020861127
    378 1991  7 .000027179554   .0012150153
    379 1991  8   .0017399964   .0015752286
    380 1991  9 -.00013826239   .0004809036
    381 1991 10  -.0008881435   .0013854794
    382 1991 11 -.00016042936   -.002432231
    383 1991 12    .000421264    .004964425
    end
    format %tm date
    I think I am using the wrong scaling somewhere, even though the results look Kind of reasonable.

  • #2
    You didn't get a quick answer. Thank you for providing code and sample data.

    A few suggestions. Use descriptive variable names - you seem to be switching from English to German - fine if it doesn't confuse you. Many of us also just use lower case for variable names in almost all cases - saves remembering which are upper and which are lower. Remember most of us are not from your area so don't assume we understand SR and Volatility as they are used in your area.

    I don't understand the sqrt(12). You are doing a standard deviation on monthly data in
    egen Sd_P1= sd(P1), by(Jahr) So I can't see why the sqrt. There may be a legitimate reason for this, but egen with sd by Jahr gives you the standard deviation by year. I also wonder if the annual stockholder return is the mean or sum of the monthly returns.

    Comment


    • #3
      Thank you for your advice phil.

      I've changed the variable names to English. Volatility is the standard deviation of a certain variable. The Sharpe ratio is the generated excess return (given by P1 and P8), divided by the standard deviation of the excess return (variables P1 and P8). This means SR= Var1/sd(Var1), with Var1= P1 or P8 in this example data.
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float(date year month P1 P8)
      360 1990  1  -.0019377362   -.003668688
      361 1990  2   .0008372813    .001459499
      362 1990  3 -.00022618668   .0019396635
      363 1990  4  -.0003067676   -.002378969
      364 1990  5   .0004768702    .005065726
      365 1990  6   .0006901055 -.00016673017
      366 1990  7  -.0012268435  -.0008285865
      367 1990  8  -.0027135995   -.005536701
      368 1990  9  -.0011730944   -.004750926
      369 1990 10  -.0017754886   .0002686236
      370 1990 11   .0014749074    .005864478
      371 1990 12   .0004333424   .0011803983
      372 1991  1   .0016687294    .005055216
      373 1991  2   .0041755983    .005791987
      374 1991  3   .0020613207   .0019960906
      375 1991  4    .002639579  .00008909535
      376 1991  5  .00054460054    .002296731
      377 1991  6  .00011390844  -.0020861127
      378 1991  7 .000027179554   .0012150153
      379 1991  8   .0017399964   .0015752286
      380 1991  9 -.00013826239   .0004809036
      381 1991 10  -.0008881435   .0013854794
      382 1991 11 -.00016042936   -.002432231
      383 1991 12    .000421264    .004964425
      end
      format %tm date

      To calculate the annual return you have to take the monthly returns, add 1 and multiply them, like this: (1+monthly return January)*(1+ monthly return February)…:
      Code:
      bys year: asrol P1, s(product) add1

      What I want is to get the total standard deviation for P1 or P8 over the 29 years. I am not sure how to calculate it. Maybe calculate annual returns and get the standard deviation over this values?

      Comment

      Working...
      X