W_sd_sr: Compute the optimal power-law parameter and the portfolio...

View source: R/Portfolio_management_crypto.R

W_sd_srR Documentation

Compute the optimal power-law parameter and the portfolio weights according to the approach proposed by Kristoufek (2013)

Description

This function computes the optimal power-law parameter and the portfolio weights according to the approach proposed by Kristoufek (2013) using in-sample data

Usage

W_sd_sr(V, alpha, ret_data, rf = 0.005, type = "StdDev")

Arguments

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

Details

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.

Value

a list containing the following objects:

sd_all

a vector of all standard deviations obtained in-sample for each value of alpha

min_sd

value of alpha that min the standard deviation in-sample

sr_all

a vector of all Sharpe Ratios obtained in-sample for each value of alpha

min_sr

value of alpha that max the Sharpe Ratio in-sample

ws_last_best_sd

portfolio weights computed with the alpha that minimized the std.dev. and the latest Google Trends data

ws_last_best_sr

portfolio weights computed with the alpha that maximized the Sharpe ratios and the latest Google Trends data

References

Kristoufek, L. (2013). Can Google Trends search queries contribute to risk diversification?. Scientific reports, 3, 2713.

Examples

## 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)


deanfantazzini/bitcoinFinance documentation built on June 12, 2024, 4:10 p.m.