View source: R/Portfolio_management_crypto.R
W_sd_sr_out | R Documentation |
This function computes the optimal power-law parameter and the portfolio weights according to the approach proposed by Kristoufek (2013) using out-of-sample data. Default lag for portfolio weights is 1, but it can be modified by the user.
W_sd_sr_out(V, alpha, ret_data, rf = 0.005, type = "StdDev", lag_ws = 1)
V |
a zoo object containing the Google Trends search terms (cryptocurrency ticker or other type) |
alpha |
is a vector of possible values for the power-law parameter alpha (usually between -2 and +2) |
ret_data |
a zoo object containing the return data of the selected cryptocurrencies |
rf |
is the risk-free rate needed for the computation of the SharpeRatio |
type |
one of "StdDev" or "VaR" or "ES" to use as the denominator for computing the SharpeRatio |
lag_ws |
the lag to be applied to the portfolio weights for computing the out-of-sample analysis |
This function computes the optimal power-law parameter alpha that min the std. dev or max the Sharpe ratio for the given dataset,
using (pseudo) out-of-sample data. The portfolio weights (computed for a given alpha) are lagged by a quantity
defined by lag_ws
.
a list containing the following objects:
a vector of all standard deviations obtained in-sample for each value of alpha
value of alpha that min the standard deviation in-sample
a vector of all Sharpe Ratios obtained in-sample for each value of alpha
value of alpha that max the Sharpe Ratio in-sample
Kristoufek, L. (2013). Can Google Trends search queries contribute to risk diversification?. Scientific reports, 3, 2713.
## Not run:
library(PerformanceAnalytics)
data(crypto_google_data)
R <- crypto_google_data[,2:6]
R<- zoo::zoo( apply(R, 2, QuantTools::returns), order.by=lubridate::ymd(crypto_google_data[,1]))
R<-R[2:nrow(R),]
alpha <- seq(from = -2, to = 2, by = 0.1)
V=zoo::zoo(crypto_google_data[,7:11], order.by=lubridate::ymd(crypto_google_data[,1]) )
V<-V[2:nrow(V),]
google_port_out=W_sd_sr_out(V, alpha, ret_data=R, rf=0.003, type="StdDev", lag_ws=4)
#Plots
plot(y = google_port_out$sd_all,
x = alpha,
xlab = "Discrimination parameter",
ylab = "StdDev",pch=21)
plot(y = google_port_out$sr_all,
x = alpha,
xlab = "Discrimination parameter",
ylab = "SharpeRatio")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.