getReturns {stockPortfolio}R Documentation

Obtain stock data from Yahoo Finance

Description

Download a collection of stock data from Yahoo Finance.

Usage

getReturns(ticker, freq = c("month", "week", "day"), get = c("overlapOnly", "all"), start = "1970-01-01", end = NULL)

Arguments

ticker A character vector where each element is a ticker.
freq The frequency of the stock data to be downloaded. Default is "month" for 12 observations per year and other options are "week" and "day".
get The default, "overlapOnly", will return the stock returns for which all stocks had data and drop any dates with NA; if it is monthly data, minor corrections are made when appropriate. The "all" option yields all stock returns regardless of whether data for all stocks is available; stock data obtained under the "all" option may not work in the other functions in this package if NA values are present.
start Start date in the format "YYYY-MM-DD".
end End date in the format "YYYY-MM-DD".

Value

getReturns outputs an object of class "stockReturns", which is a list of the following:

R Stock returns, where the first row is the most recent and the last row is the oldest.
ticker The tickers of the stocks.
period How frequently stock returns are included in the data.
start The oldest date for which stock returns are included.
end The most recent date for which stock returns are included.

Author(s)

David Diez and Nicolas Christou

See Also

stockModel, optimalPort, testPort, portReturn

Examples

#===> Citi and Bank of America, 2004-2008 <===#
# cBac <- getReturns(c('C','BAC'), start='2004-01-01', end='2008-12-31')
# print(cBac)
# summary(cBac)
# plot(cBac)
# lines(cBac, lwd=2)
# pairs(cBac)

[Package stockPortfolio version 1.0 Index]