R/TreynorRatio.R
TreynorRatio.RdThe Treynor ratio is similar to the Sharpe Ratio, except it uses beta as the volatility measure (to divide the investment's excess return over the beta).
TreynorRatio(Ra, Rb, Rf = 0, scale = NA, modified = FALSE)an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns
return vector of the benchmark asset
risk free rate, in same period as your returns
number of periods in a year (daily scale = 252, monthly scale = 12, quarterly scale = 4)
a boolean to decide whether to return the Treynor ratio or Modified Treynor ratio
To calculate modified Treynor ratio, we divide the numerator by the systematic risk instead of the beta.
Equation: $$TreynorRatio = \frac{\overline{(R_{a}-R_{f})}}{\beta_{a,b}}$$ $$ModifiedTreynorRatio = \frac{r_p - r_f}{\sigma_s}$$
https://en.wikipedia.org/wiki/Treynor_ratio, Carl Bacon, Practical portfolio performance measurement and attribution, second edition 2008 p.77
data(portfolio_bacon)
data(managers)
round(TreynorRatio(managers[,1], managers[,8], Rf=.035/12),4)
#> [1] 0.2528
round(TreynorRatio(managers[,1], managers[,8], Rf = managers[,10]),4)
#> [1] 0.2428
round(TreynorRatio(managers[,1:6], managers[,8], Rf=.035/12),4)
#> HAM1 HAM2 HAM3 HAM4 HAM5 HAM6
#> Treynor Ratio: SP500 TR 0.2528 0.3925 0.201 0.1209 0.0052 0.3042
round(TreynorRatio(managers[,1:6], managers[,8], Rf = managers[,10]),4)
#> HAM1 HAM2 HAM3 HAM4 HAM5 HAM6
#> Treynor Ratio: SP500 TR 0.2428 0.3883 0.1956 0.1144 0.0219 0.3401
round(TreynorRatio(managers[,1:6], managers[,8:7], Rf=.035/12),4)
#> HAM1 HAM2 HAM3 HAM4 HAM5 HAM6
#> Treynor Ratio: SP500 TR 0.2528 0.3925 0.2010 0.1209 0.0052 0.3042
#> Treynor Ratio: EDHEC LS EQ 0.1297 0.1088 0.0776 0.0504 0.0014 0.0966
round(TreynorRatio(managers[,1:6], managers[,8:7], Rf = managers[,10]),4)
#> HAM1 HAM2 HAM3 HAM4 HAM5 HAM6
#> Treynor Ratio: SP500 TR 0.2428 0.3883 0.1956 0.1144 0.0219 0.3401
#> Treynor Ratio: EDHEC LS EQ 0.1242 0.1068 0.0753 0.0471 0.0060 0.1086
print(TreynorRatio(portfolio_bacon[,1], portfolio_bacon[,2], modified = TRUE)) #expected 0.7975
#> [1] 0.7806747
print(TreynorRatio(managers['2002',1], managers['2002',8], modified = TRUE))
#> [1] -0.727545
print(TreynorRatio(managers['2002',1:5], managers['2002',8], modified = TRUE))
#> HAM1 HAM2 HAM3 HAM4 HAM5
#> Treynor Ratio: SP500 TR -0.727545 -6.045167 -2.123832 -0.4990387 -5.37482