getReturns: Obtain stock data from Yahoo Finance

Description Usage Arguments Value Author(s) See Also Examples

Description

Download a collection of stock data from Yahoo Finance.

Usage

1
2
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". If using freq="month" (the default) or freq="week", the DD should be specified as the last day of the month or week, respectively.

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.

full

A list, where each item is a data frame containing information from the CSV file downloaded from Yahoo Finance.

Author(s)

David Diez and Nicolas Christou

See Also

stockModel, optimalPort, testPort, portReturn

Examples

1
2
3
4
5
6
7
#===> 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)

jankcorn/stockPortfolio documentation built on May 14, 2019, 9:35 a.m.