Consider the series of weekly prices \(P_1, \dots, P_i, \dots, P_{\bar{t}}\), where \(\bar{t}\) is the number of observations in the sample. Let’s define the time index as \(t_i = (0, \frac{1}{f}, \dots, \frac{\bar{t}-1}{f})\) where \(f = 52\) denote the number of weeks in a year. Then, fitting the following linear model, i.e. \[P_i = \alpha + \beta t_i + e_t \text{,}\] and given the estimated \(\beta\) and the \(R^2\) of the regression, the Diaman Ratio is computed as: \[DR = \beta R^2\] Some considerations:
The Diaman Ratio is obtained from a regression of the historical price series against time, so for the observed time period, given the same return and volatility of returns, the Diaman Ratio discriminates between different trajectories.
The Diaman Ratio is not tied to the risk-free rate, although it can be easily incorporated into the calculation.
Changing the frequency of data used for evaluating a series can lead to very different ranking results just by using weekly data instead of daily data.
The Diaman Ratio is capable of estimating both positive and negative slopes, but it has difficulty in the presence of directional changes and non-linear historical series.
Show diaman_ratio function
diaman_ratio <-function(x, weekly =TRUE){# length of the time series t <-length(x)# log-price log_x <-log(x)# time indicator f <-ifelse(weekly, 52, 365) t_i <-c(1:t)/f# regression p_i <-lm(log_x ~ t_i)# coefficient beta beta <-coef(p_i)[2]# R2 of the regression r2 <-summary(p_i)$r.squared# diaman ratio dr <-c(diaman_ratio = beta*r2)attr(dr, "trend") <-cumprod(exp(predict(p_i)))return(dr)}
The downside risk is a measure of risk similar to standard deviation, but the DSR is concentrated on the negative part of the volatility of the investment. Its reference value \(r_{\texttt{target}}\) is not the mean of the return, but the minimum acceptable return, for example the risk-free rate, fixed a priori. The downside risk measure the deviations of the returns with respect to a minimum threshold \(r_{\texttt{target}}\) and it is computed as follows: \[DSR = \sqrt{\int_{-\infty}^{T}(r_{\texttt{target}}-x)^2f(x)dx}\]
In general, an elevate Sortino Ratio denote that the variability of the returns is not centered below the acceptable threshold fixed. On the other hand a low Sortino Ratio denote that the variability is concentrated below the minimum return, therefore in general we should prefer instruments with an high Sortino’s value. \[SR = \frac{r_{\Pi} - r_{\texttt{target}}}{\text{DSR}}\]
sortino_ratio function
sortino_ratio <-function(x, r_target =0){# Log-price log_x <-log(x)# Log-returns mean r <-c(0, diff(log_x))# Mean return r_pi <-mean(r, na.rm =TRUE)# Density of log-returns ker <-density(r) ker <- dplyr::tibble(x = ker$x, p = ker$y/sum(ker$y)) ker <- ker[ker$x < r_target,]# Downside risk dsr <-sqrt(sum(ker$p*(r_target - ker$x)^2))# Sortino ratio sr <- (r_pi - r_target)/dsrreturn(sr)}