View source: R/stock_correlation.R
stock.correlation | R Documentation |
Compute and Plot a correlation diagram between selected sotcks, or between stocks and a (single) market index. After computing the correlations a statistical test shows only the significant correlations. The non-significant ones are crossed
stock.correlation(ticker, from, to, market_index = NULL)
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 |
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.