View source: R/var_cov_comparison.R
var.cov.comparison | R Documentation |
This function enables to select different stocks and creates a table that compares variance,volatility, covariance and beta of these stocks with a market index of your choice.
var.cov.comparison(ticker, market_index = "^GSPC", from, to)
ticker |
A character vector storing the tickers of the stocks of which you want the correlation. Note that since data are downloaded from Yahoo finance, the ticker should be the same as the ones reported on Yahoo finance. See examples. |
market_index |
A single character variable storing the ticker of the market index you want to download. Default to "^GSPC" (S&P500) |
from |
A single character variable storing the starting date from which we want to download the data. The format should be "yyyy-mm-dd" |
to |
A single character variable storing the ending date up to the day in which we want to download the stock data. The format should be "yyyy-mm-dd" |
## Not run: var.cov.comparison(ticker =c("AA","AAPL","AXP","BA","BAC","CAT","CVX","DD","DIS", "GE","HD","HPQ","INTC","IBM","JNJ","JPM","KO","MCD","MMM", "MRK","MSFT","NKE","PFE","PG","TRV","VZ","WMT","XOM","T"), from = "2020-01-01", to = "2022-01-01" ) var.cov.comparison( ticker = c ("AAPL" , "AMZN" ), market_index = "FTSEMIB.MI", from = "2020-01-01" , to = "2022-01-01" ) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.