Get the historic of stock market data for financial ticker symbols, e.g., values at each closing day.
Usage
get_historic(symbols = c("SAAB-B.ST"), wait.time = 0, .verbose = T, ...)Arguments
- symbols
character- A character string representing the financial indices to search for, e.g., ticker symbol(s).- wait.time
double, default =0- A character string representing an additional waiting time between 2 calls to the Yahoo API.- .verbose
logical, default =TRUE- IfTRUE, send messages to the console.- ...
Arguments passed on to
get_yahoo_datasymbolcharacter- A character string representing the symbol for the financial instrument (e.g., "AAPL" for Apple).start_datecharacter- A character string representing the start date in Rdateformat (UTC time). IfNULL, data starts from 1970-01-01.end_datecharacter- A character string representing the end date in a valid Rdateformat (UTC time). IfNULL, data is retrieved up to the current date.rangecharacter- 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"
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
Return a data.frame with additional attributes:
- n.currencies
integer- Number of unique currencies in thedata.frame.- currencies
character- A vector of currency symbols in thedata.frame(e.g.,"BTC","ETH","USD").- exchange
character- A vector of exchange pairs (e.g.,"BTC => USD"). If not applicable,NULL(no entry).- date.fetch
Date- The date when the data was retrieved, set usingSys.Date().- crypto
logical-TRUEif cryptocurrencies are present, otherwiseFALSE.- date.begin
POSIXct- The oldest observation in the dataset.- date.end
POSIXct- The most recent observation in the dataset.- date.dif
numeric- The number of seconds between date.begin and date.end, equivalent ofdifftimevalue.
See also
For more details see the help vignette:
vignette("get_info_and_historic", package = "financr")
Examples
datas <- get_historic(symbols = c("VOLCAR-B.ST", "SAAB-B.ST") )
str(datas)
#> 'data.frame': 1020 obs. of 20 variables:
#> $ open : num 32.5 32.2 32.3 32.2 32.3 ...
#> $ close : num 32.3 32.3 32.3 32.3 32.3 ...
#> $ low : num 32.2 32.2 32.2 32.2 32.3 ...
#> $ high : num 32.5 32.3 32.3 32.3 32.3 ...
#> $ volume : int 0 5503 9528 3928 395 2079 26656 3851 7439 10 ...
#> $ timestamp : int 1768291200 1768291260 1768291320 1768291380 1768291440 1768291500 1768291560 1768291620 1768291680 1768291740 ...
#> $ date : POSIXct, format: "2026-01-13 08:00:00" "2026-01-13 08:01:00" ...
#> $ currency : chr "SEK" "SEK" "SEK" "SEK" ...
#> $ symbol : chr "VOLCAR-B.ST" "VOLCAR-B.ST" "VOLCAR-B.ST" "VOLCAR-B.ST" ...
#> $ shortname : chr "Volvo Car AB ser. B" "Volvo Car AB ser. B" "Volvo Car AB ser. B" "Volvo Car AB ser. B" ...
#> $ longname : chr "Volvo Car AB (publ.)" "Volvo Car AB (publ.)" "Volvo Car AB (publ.)" "Volvo Car AB (publ.)" ...
#> $ exchangename : chr "STO" "STO" "STO" "STO" ...
#> $ fullexchangename : chr "Stockholm" "Stockholm" "Stockholm" "Stockholm" ...
#> $ timezone : chr "CET" "CET" "CET" "CET" ...
#> $ gmtoffset : int 3600 3600 3600 3600 3600 3600 3600 3600 3600 3600 ...
#> $ regularmarketprice : num 32.2 32.2 32.2 32.2 32.2 ...
#> $ fiftytwoweeklow : num 15.9 15.9 15.9 15.9 15.9 ...
#> $ fiftytwoweekhigh : num 36.5 36.5 36.5 36.5 36.5 ...
#> $ regularmarketdaylow : num 31.6 31.6 31.6 31.6 31.6 ...
#> $ regularmarketdayhigh: num 32.5 32.5 32.5 32.5 32.5 ...
#> - attr(*, "n.currencies")= int 1
#> - attr(*, "currencies")= chr "SEK"
#> - attr(*, "date.fetch")= Date[1:1], format: "2026-01-13"
#> - attr(*, "date.begin")= int 1768291200
#> - attr(*, "date.end")= int 1768321740
#> - attr(*, "date.dif")= num 30540
