Learn R Programming

RTL (version 1.3.7)

promptBeta: Computes betas of futures contracts with respect to the 1st line contract

Description

Returns betas of futures contracts versus front futures contract.

Usage

promptBeta(x = x, period = "all", betatype = "all", output = "chart")

Value

betas data frame tibble or plotly chart of betas htmlwidgets

Arguments

x

Wide dataframe with date column and multiple series columns (multivariate). tibble

period

"all" or numeric period of time in last n periods as character eg "100". character

betatype

"all" "bull" "bear". character

output

"betas" or "chart". character

Author

Philippe Cote

Examples

Run this code
if (FALSE) {
 x <- dflong %>%
 dplyr::filter(grepl("CL",series)) %>%
 dplyr::mutate(series = readr::parse_number(series)) %>% dplyr::group_by(series) %>%
 RTL::returns(df = ., retType = "abs",period.return = 1,spread = TRUE) %>%
 RTL::rolladjust(x = .,commodityname = c("cmewti"),rolltype = c("Last.Trade")) %>%
 # removing the day it prices went negative...
 dplyr::filter(!date %in% c(as.Date("2020-04-20"),as.Date("2020-04-21")))
promptBeta(x = x, period = "all", betatype = "all", output = "chart")
promptBeta(x = x, period = "all", betatype = "bull", output = "betas")
promptBeta(x = x, period = "100", betatype = "bear", output = "betas")
}

Run the code above in your browser using DataLab