Learn R Programming

AssetAllocation (version 1.1.1)

get_data_from_tickers: Downloads prices in xts format from a list of tickers from Yahoo Finance (<https://finance.yahoo.com/>).

Description

get_data_from_tickers retrieves adjusted closing prices from Yahoo Finance for a set of tickers and returns the prices and returns.

Usage

get_data_from_tickers(tickers, starting_date = "2007-01-01")

Value

An object of class "List" containing two objects of class "xts" with respectively the prices and returns of the assets, with column names corresponding to the tickers.

Arguments

tickers

A vector containing a tickers.

starting_date

A date on which the allocation rule is applied.

Details

The function retrieves data from Yahoo Finance (<https://finance.yahoo.com/>) using the getSymbols function from the quantmod package. It calculates returns from adjusted prices. The ticker names must correspond to those found in Yahoo Finance.

Examples

Run this code
## download data for the following exchange-traded-funds: MTUM, VLUE, USMV, and QUAL.
factor_ETFs <- get_data_from_tickers(c("MTUM", "VLUE", "USMV", "QUAL"),
                                     starting_date = "2020-01-01")

Run the code above in your browser using DataLab