Get historical financial values associated with a ticker symbol. The data includes open stock price, high, low, close, volume, along with timestamps.
Usage
get_yahoo_data(
symbol = "AAPL",
start_date = NULL,
end_date = NULL,
range = "1d",
.verbose = T
)Arguments
- symbol
character- A character string representing the symbol for the financial instrument (e.g., "AAPL" for Apple).- start_date
character- A character string representing the start date in Rdateformat (UTC time). IfNULL, data starts from 1970-01-01.- end_date
character- A character string representing the end date in a valid Rdateformat (UTC time). IfNULL, data is retrieved up to the current date.- range
character- A character string representing the range for the returned datas : default will return daily values.Valid rangevalues"1d","5d","1mo","3mo","6mo","1y","2y","5y","10y","ytd"and"max"- .verbose
logicalIf TRUE, messages are displayed, e.g., when invalid symbols are detected.
Value
A data.frame containing the historical financial data with the following columns:
- open
numericThe opening price for the period (default is each day).- close
numericThe closing price for the period (default is each day).- low
numericThe lowest price for the period (default is each day).- high
numericThe highest price for the period (default is each day).- volume
integerThe traded volume.- timestamp
integerUnix timestamps corresponding to each data point.- date
POSIXctThe day of the financial data point.- currency
characterThe currency in which the data is reported, depending on the marketplace.- symbol
characterThe stock or financial instrument symbol (e.g., "AAPL").- shortname
characterThe abbreviated name of the company or financial instrument.- longname
characterThe full name of the company or financial instrument.- exchangename
characterThe name of the exchange marketplace where the financial instrument is listed.- fullexchangename
characterThe full name of the exchange marketplace.- timezone
characterThe timezone in which the data is reported.- gmtoffset
integerThe UNIX timestamp of difference between the market local time and the GMT time.- regularMarketPrice
numericThe actual price if market is open, or last closing price if not.- fiftyTwoWeekLow
numericLowest price for the last 52 weeks.- fiftyTwoWeekHigh
numericHighest price for the last 52 weeks.- regularMarketDayHigh
numericThe highest price of the day (local exchange place day).- regularMarketDayLow
numericThe lowest price of the day (local exchange place day).
Details
The default data.frame have a line for each day.
If the user provide another range than '1d' (one day), lines will be filtered out, in order to match the desired range.
Valid ranges are: "1d", "5d", "1mo", "3mo", "6mo", "1y", "2y", "5y", "10y", "ytd", and "max".
The function allows the user to specify a date range using start and end dates. If no date range is specified, it retrieves all available data from the beginning of time (default for start) to the current date (default for end).
