stock.correlation: Compute and Plot a correlation diagram between stocks

View source: R/stock_correlation.R

stock.correlationR Documentation

Compute and Plot a correlation diagram between stocks

Description

Compute and Plot a correlation diagram between sotcks, or between stocks and a (single) market index.

Usage

stock.correlation(ticker, from, to, market_index = NULL)

Arguments

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.

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 from which we want to download the data. The format should be "yyyy-mm-dd"

market_index

A single character vector storing the ticker of the market index you want to download. Default to NULL

Examples

## Not run:  
x = c("AAPL", "AMZN", "F", "JPM", "DD", "IBM", "INTC") 
start = "1998-01-01"
end = "2015-01-01"


stock.correlation(ticker = x, market_index = "^GSPC", from = start, to = end  ) #S&P500
stock.correlation(ticker = x, market_index = "^IXIC", from = start, to= end  ) #Nasdaq Index
stock.correlation(ticker = x, market_index = "FTSEMIB.MI", from = start, to = end ) #FTSE MIB Index 
stock.correlation(ticker = x, from = start, to = end) #No market index

## End(Not run)


 

gabrielebonvicini/aaa documentation built on May 21, 2022, 12:07 a.m.