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 dateSys.date()
.- file
Either
NULL
(default) to return the data as adata.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.
Examples
### download 21st century DAX data
data <- download_data(symbol = "^GDAXI", from = "2000-01-03")
head(data)
#> Date Open High Low Close Adj.Close Volume
#> 1 2000-01-03 6961.72 7159.33 6720.87 6750.76 6750.76 43072500
#> 2 2000-01-04 6747.24 6755.36 6510.46 6586.95 6586.95 46678400
#> 3 2000-01-05 6585.85 6585.85 6388.91 6502.07 6502.07 52682800
#> 4 2000-01-06 6501.45 6539.31 6402.63 6474.92 6474.92 41180600
#> 5 2000-01-07 6489.94 6791.53 6470.14 6780.96 6780.96 56058900
#> 6 2000-01-10 6785.47 6975.26 6785.47 6925.52 6925.52 42006200