View source: R/Portfolio_management_crypto.R
W_sd_sr | R Documentation |
This function computes the optimal power-law parameter and the portfolio weights according to the approach proposed by Kristoufek (2013) using in-sample data
W_sd_sr(V, alpha, ret_data, rf = 0.005, type = "StdDev")
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 |
This function computes the optimal power-law parameter alpha that min the std. dev or max the Sharpe ratio for the given dataset and returns the optimal portfolio weights using the latest Google Trends data.
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
portfolio weights computed with the alpha that minimized the std.dev. and the latest Google Trends data
portfolio weights computed with the alpha that maximized the Sharpe ratios and the latest Google Trends data
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=W_sd_sr(V, alpha, ret_data=R, rf=0.003, type="StdDev")
#Plots
plot(y = google_port$sd_all,
x = alpha,
xlab = "Discrimination parameter",
ylab = "StdDev",pch=21)
plot(y = google_port$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.