download_data: Download financial data from Yahoo Finance

View source: R/download_data.R

download_dataR Documentation

Download financial data from Yahoo Finance

Description

This function downloads stock data from https://finance.yahoo.com/.

Usage

download_data(
  symbol,
  from = "1902-01-01",
  to = Sys.Date(),
  file = NULL,
  verbose = TRUE
)

Arguments

symbol

A character, the stock's symbol. It must match the identifier on https://finance.yahoo.com/.

from

A character, a date in format "YYYY-MM-DD", setting the lower data bound. Must not be earlier than "1902-01-01" (default).

to

A character, a date in format "YYYY-MM-DD", setting the upper data bound. Default is the current date Sys.date().

file

Either

  • NULL (default) to return the data as a data.frame,

  • or a character, the name of the file where the data is saved as a .csv-file.

verbose

Set to TRUE to return information about download success.

Details

The downloaded data has the following columns:

  • Date: The date.

  • Open: Opening price.

  • High: Highest price.

  • Low: Lowest price.

  • Close: Close price adjusted for splits.

  • Adj.Close: Close price adjusted for dividends and splits.

  • Volume: Trade volume.

Value

A data.frame if file = NULL.

Examples

### download 21st century DAX data
data <- download_data(symbol = "^GDAXI", from = "2000-01-03")
head(data)


fHMM documentation built on Oct. 12, 2023, 5:10 p.m.