Retrieves financial data from Yahoo Finance. Get historical or latest values of financial assets or currencies exchanges rates, latest insights, assets association (related to each other), etc.
Functions are divided into three main families:
- ‘search_’: Search for assets using free-text queries
- ‘get_’: Retrieve financial values and insights, given symbols
- ‘last_’: Get market summaries, latest values of major assets, world-level indices, currencies and cryptocurrencies
Installation
Install the development version of financr with:
devtools::install_github("clement-LVD/financr")Examples
See the example Vignette.
Get ticker symbol from free-texts. Given keyword(s) such as companies names, search symbols with search_assets().
library(financr)
indices <- search_assets(c("Dow jones"
, "euronext")
, type = "index" )
str(indices)
#> 'data.frame': 9 obs. of 10 variables:
#> $ symbol : chr "^DJI" "^DWRTF" "^DWCPF" "^REIT" ...
#> $ shortname : chr "Dow Jones Industrial Average" "Dow Jones U.S. Select REIT Inde" "Dow Jones U.S. Completion Total" "Dow Jones Equity All REIT Total" ...
#> $ longname : chr "Dow Jones Industrial Average" "Dow Jones U.S. Select REIT Inde" "Dow Jones U.S. Completion Total Stock Market Index" "Dow Jones Equity All REIT Total" ...
#> $ exchange : chr "DJI" "DJI" "DJI" "DJI" ...
#> $ exchdisp : chr "Dow Jones" "Dow Jones" "Dow Jones" "Dow Jones" ...
#> $ quotetype : chr "INDEX" "INDEX" "INDEX" "INDEX" ...
#> $ typedisp : chr "Index" "Index" "Index" "Index" ...
#> $ score : num 35415 20667 20294 20184 20005 ...
#> $ isyahoofinance: logi TRUE TRUE TRUE TRUE TRUE TRUE ...
#> $ searched : chr "dow jones" "dow jones" "dow jones" "dow jones" ...
#> - attr(*, "date.fetch")= Date[1:1], format: "2026-01-13"Optionally use the ‘get_values’ parameter to add latest prices to these results.
indices2 <- search_assets(
c("Dow jones", "euronext")
, type = "index"
, get_values = TRUE )
str(indices2)
#> 'data.frame': 8 obs. of 28 variables:
#> $ symbol : chr "^DJI" "^DWCPF" "^DWRTF" "^N100" ...
#> $ shortname : chr "Dow Jones Industrial Average" "Dow Jones U.S. Completion Total" "Dow Jones U.S. Select REIT Inde" "Euronext 100 Index" ...
#> $ longname : chr "Dow Jones Industrial Average" "Dow Jones U.S. Completion Total Stock Market Index" "Dow Jones U.S. Select REIT Inde" "Euronext 100 Index" ...
#> $ exchange : chr "DJI" "DJI" "DJI" "PAR" ...
#> $ exchdisp : chr "Dow Jones" "Dow Jones" "Dow Jones" "Paris" ...
#> $ quotetype : chr "INDEX" "INDEX" "INDEX" "INDEX" ...
#> $ typedisp : chr "Index" "Index" "Index" "Index" ...
#> $ score : num 35415 20294 20667 20004 20004 ...
#> $ isyahoofinance : logi TRUE TRUE TRUE TRUE TRUE TRUE ...
#> $ searched : chr "dow jones" "dow jones" "dow jones" "euronext" ...
#> $ currency : chr "USD" "USD" "USD" "EUR" ...
#> $ exchangename : chr "DJI" "DJI" "DJI" "PAR" ...
#> $ fullexchangename : chr "DJI" "DJI" "DJI" "Paris" ...
#> $ instrumenttype : chr "INDEX" "INDEX" "INDEX" "INDEX" ...
#> $ firsttradedate : POSIXct, format: "1992-01-02 15:30:00" "2006-08-24 15:30:00" ...
#> $ regularmarkettime : POSIXct, format: "2026-01-13 22:46:18" "2026-01-13 23:13:42" ...
#> $ hasprepostmarketdata: logi FALSE FALSE FALSE FALSE FALSE FALSE ...
#> $ gmtoffset : int -18000 -18000 -18000 3600 3600 3600 3600 3600
#> $ timezone : chr "EST" "EST" "EST" "CET" ...
#> $ exchangetimezonename: chr "America/New_York" "America/New_York" "America/New_York" "Europe/Paris" ...
#> $ regularmarketprice : num 49192 2610 298 1782 1193 ...
#> $ fiftytwoweekhigh : num 49633 2622 298 1784 1193 ...
#> $ fiftytwoweeklow : num 36612 1748 294 1337 1193 ...
#> $ regularmarketdayhigh: num 49617 2622 298 1784 1193 ...
#> $ regularmarketdaylow : num 49056 2600 294 1776 1193 ...
#> $ regularmarketvolume : int 549959677 0 0 0 0 NA 0 0
#> $ chartpreviousclose : num 49590 2611 296 1780 1191 ...
#> $ previousclose : num 49590 2611 296 1780 1191 ...
#> - attr(*, "n.currencies")= int 2
#> - attr(*, "currencies")= chr [1:2] "USD" "EUR"
#> - attr(*, "date.fetch")= Date[1:1], format: "2026-01-13"
#> - attr(*, "date.begin")= POSIXct[1:1], format: "2026-01-13 18:05:02"
#> - attr(*, "date.end")= POSIXct[1:1], format: "2026-01-13 23:13:42"
#> - attr(*, "date.dif")= num 5.14Exploring the results of search_assets() is a way to find the symbol of an asset. search_assets_quick() is a variant.
Get historical financial data. Given ticker symbol(s), get historical financial data with financr::get_historic(). Default interval is daily values.
histo <- get_historic(
c("SAAB-B.ST", "VOLV-B.ST")
, .verbose = FALSE)
str(histo)
#> 'data.frame': 1020 obs. of 20 variables:
#> $ open : num 698 694 691 686 686 ...
#> $ close : num 694 691 686 686 685 ...
#> $ low : num 693 688 686 684 680 ...
#> $ high : num 701 695 691 689 686 ...
#> $ volume : int 0 54694 44645 48274 68934 34643 25208 20831 28716 37439 ...
#> $ timestamp : int 1768291200 1768291260 1768291320 1768291380 1768291440 1768291500 1768291560 1768291620 1768291680 1768291740 ...
#> $ date : POSIXct, format: "2026-01-13 09:00:00" "2026-01-13 09:01:00" ...
#> $ currency : chr "SEK" "SEK" "SEK" "SEK" ...
#> $ symbol : chr "SAAB-B.ST" "SAAB-B.ST" "SAAB-B.ST" "SAAB-B.ST" ...
#> $ shortname : chr "SAAB AB ser. B" "SAAB AB ser. B" "SAAB AB ser. B" "SAAB AB ser. B" ...
#> $ longname : chr "Saab AB (publ)" "Saab AB (publ)" "Saab AB (publ)" "Saab 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 704 704 704 704 704 ...
#> $ fiftytwoweeklow : num 208 208 208 208 208 208 208 208 208 208 ...
#> $ fiftytwoweekhigh : num 710 710 710 710 710 ...
#> $ regularmarketdaylow : num 680 680 680 680 680 ...
#> $ regularmarketdayhigh: num 710 710 710 710 710 ...
#> - 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 30540Vignettes
Yahoo Finance API Licence. This package retrieves data from Yahoo Finance, a property of Yahoo Inc. Users must comply with Yahoo Finance’s API terms. See more informations on the legal Vignette.
