This vignette is about the functions with the prefix
‘last_’.
Fetching the API
Retrieve market summary insights.
library(financr)
datas <- last_market_summary(region = "US")
str(datas)
#> 'data.frame': 15 obs. of 38 variables:
#> $ fullexchangename : chr "SNP" "DJI" "Nasdaq GIDS" "Chicago Options" ...
#> $ symbol : chr "^GSPC" "^DJI" "^IXIC" "^RUT" ...
#> $ gmtoffsetmilliseconds : int -18000000 -18000000 -18000000 -18000000 -18000000 -18000000 -18000000 0 -21600000 0 ...
#> $ language : chr "en-US" "en-US" "en-US" "en-US" ...
#> $ regularmarkettime_raw : POSIXct, format: "2026-01-13 21:46:18" "2026-01-13 21:46:18" ...
#> $ regularmarkettime_fmt : chr "4:46PM EST" "4:46PM EST" "5:15PM EST" "4:30PM EST" ...
#> $ regularmarketchangepercent_raw: num -0.1939 -0.803 -0.1013 -0.0982 -0.0818 ...
#> $ regularmarketchangepercent_fmt: num -0.19 -0.8 -0.1 -0.1 -0.08 -0.1 0.6 -0.24 -0.38 -0.29 ...
#> $ quotetype : chr "INDEX" "INDEX" "INDEX" "INDEX" ...
#> $ typedisp : chr "Index" "Index" "Index" "Index" ...
#> $ tradeable : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
#> $ regularmarketpreviousclose_raw: num 6977.3 49590.2 23733.9 2635.7 61.1 ...
#> $ regularmarketpreviousclose_fmt: num 6977.3 49590.2 23733.9 2635.7 61.1 ...
#> $ exchangetimezonename : chr "America/New_York" "America/New_York" "America/New_York" "America/New_York" ...
#> $ regularmarketchange_raw : num -13.53 -398.21 -24.03 -2.59 -0.05 ...
#> $ regularmarketchange_fmt : num -13.53 -398.21 -24.03 -2.59 -0.05 ...
#> $ cryptotradeable : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
#> $ firsttradedatemilliseconds : num -1.33e+12 6.94e+11 3.46e+10 5.58e+11 9.67e+11 ...
#> $ exchangedatadelayedby : int 0 0 0 15 10 10 10 0 0 0 ...
#> $ exchangetimezoneshortname : chr "EST" "EST" "EST" "EST" ...
#> $ hasprepostmarketdata : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
#> $ marketstate : chr "POST" "POST" "POST" "POST" ...
#> $ regularmarketprice_raw : num 6963.7 49192 23709.9 2633.1 61.1 ...
#> $ regularmarketprice_fmt : num 6963.7 49192 23709.9 2633.1 61.1 ...
#> $ custompricealertconfidence : chr "LOW" "LOW" "LOW" "LOW" ...
#> $ market : chr "us_market" "us_market" "us_market" "us_market" ...
#> $ quotesourcename : chr "Delayed Quote" "Delayed Quote" "Delayed Quote" "Delayed Quote" ...
#> $ pricehint : int 2 2 2 2 NA NA NA 4 4 4 ...
#> $ exchange : chr "SNP" "DJI" "NIM" "WCB" ...
#> $ sourceinterval : int 15 120 15 15 30 15 15 15 15 15 ...
#> $ region : chr "US" "US" "US" "US" ...
#> $ shortname : chr "S&P 500" "Dow 30" "Nasdaq" "Russell 2000" ...
#> $ triggerable : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
#> $ longname : chr "S&P 500" "Dow Jones Industrial Average" "NASDAQ Composite" "Russell 2000 Index" ...
#> $ headsymbolasstring : chr NA NA NA NA ...
#> $ headsymbol : logi NA NA NA NA TRUE TRUE ...
#> $ contractsymbol : logi NA NA NA NA FALSE FALSE ...
#> $ currency : chr NA NA NA NA ...
#> - attr(*, "n.currencies")= int 3
#> - attr(*, "currencies")= chr [1:3] NA "USD" "JPY"
#> - attr(*, "date.fetch")= Date[1:1], format: "2026-01-13"Or retrieve currencies and their latest ‘USD’ values, e.g. currencies with a 3-letters ISO code that begin with ‘Z’.
changes_z <- last_currencies(keep = "^Z", get_changes = T)
str(changes_z)
#> 'data.frame': 2 obs. of 20 variables:
#> $ symbol : chr "ZAR" "ZMW"
#> $ shortname : chr "ZAR" "ZMW"
#> $ longname : chr "South African Rand" "ZMW"
#> $ locallongname : chr "South African Rand" "ZMW"
#> $ currency : chr "USD" "USD"
#> $ exchangename : chr "CCY" "CCY"
#> $ instrumenttype : chr "CURRENCY" "CURRENCY"
#> $ firsttradedate : POSIXct, format: "2003-12-01" "2013-01-03"
#> $ gmtoffset : int 0 0
#> $ timezone : chr "GMT" "GMT"
#> $ exchangetimezonename: chr "Europe/London" "Europe/London"
#> $ regularmarketprice : num 0.061 0.0515
#> $ regularmarketdayhigh: num 0.0611 0.0515
#> $ regularmarketdaylow : num 0.061 0.0511
#> $ fiftytwoweekhigh : num 0.0648 0.0518
#> $ fiftytwoweeklow : num 0.0502 0.0345
#> $ previousclose : num 0.061 0.0514
#> $ regular_timezone : chr "GMT" "GMT"
#> $ to : chr "USD" "USD"
#> $ timestamp : POSIXct, format: "2026-01-13 22:59:37" "2026-01-13 21:45:14"
#> - attr(*, "n.currencies")= int 1
#> - attr(*, "currencies")= chr "USD"
#> - attr(*, "exchange")= chr " => USD"
#> - attr(*, "date.fetch")= Date[1:1], format: "2026-01-13"
#> - attr(*, "date.begin")= POSIXct[1:1], format: "2026-01-13 21:45:14"
#> - attr(*, "date.end")= POSIXct[1:1], format: "2026-01-13 22:59:37"
#> - attr(*, "date.dif")= num 1.24Scraping on Yahoo Finance
Some functions rely on web scraping (Yahoo Finance webpages), such as
last_indices() and last_crypto() which
respectively provide the latest financial values (in USD) for over 40
global market indices and 100 cryptocurrencies.
last_indices() return a data.frame with the
latest financial value of major world financial indices.
indices <- last_indices()
str(indices)
#> 'data.frame': 41 obs. of 11 variables:
#> $ symbol : chr "^GSPC" "^DJI" "^IXIC" "^NYA" ...
#> $ name : chr "S&P 500" "Dow Jones Industrial Average" "NASDAQ Composite" "NYSE Composite Index" ...
#> $ change : num -13.5 -398.2 -24 -40.5 142.2 ...
#> $ change_percent: num -0.19 -0.8 -0.1 -0.18 1.95 -0.19 -0.1 5.69 -0.03 0.06 ...
#> $ volume : num 3.22e+09 5.50e+08 8.44e+09 0.00 0.00 ...
#> $ day_range1 : num 6939 49056 23608 22604 7302 ...
#> $ day_range2 : num 6986 49617 23813 22751 7491 ...
#> $ x52_wk_range1 : num 4835 36612 14784 16820 4335 ...
#> $ x52_wk_range2 : num 6986 49633 24020 22751 7553 ...
#> $ price : num 6964 49192 23710 22655 7444 ...
#> $ currency : chr "USD" "USD" "USD" "USD" ...
#> - attr(*, "n.currencies")= int 1
#> - attr(*, "currencies")= chr "USD"
#> - attr(*, "date.fetch")= Date[1:1], format: "2026-01-13"last_crypto() return a data.frame of 100
crypto-currencies values in USD ($).
krypt <- last_crypto()
str(krypt)
#> 'data.frame': 100 obs. of 15 variables:
#> $ symbol : chr "BTC-USD" "ETH-USD" "USDT-USD" "XRP-USD" ...
#> $ name : chr "Bitcoin USD" "Ethereum USD" "Tether USDt USD" "XRP USD" ...
#> $ change : num 4443.42 234.15 0 0.12 40.72 ...
#> $ change_percent : num 4.87 7.57 0.06 5.8 4.5 5.47 0 7.48 1.91 1.35 ...
#> $ market_cap : num 1.91e+12 4.02e+11 1.87e+11 1.32e+11 1.30e+11 ...
#> $ volume : num 5.28e+10 2.64e+10 1.08e+11 3.57e+09 3.23e+09 ...
#> $ volume_in_currency_24hr : num 5.28e+10 2.64e+10 1.08e+11 3.57e+09 3.23e+09 ...
#> $ total_volume_all_currencies_24hr: num 5.28e+10 2.64e+10 1.08e+11 3.57e+09 3.23e+09 ...
#> $ circulating_supply : num 2.00e+07 1.21e+08 1.87e+11 6.07e+10 1.38e+08 ...
#> $ x52_wk_change_percent : num -5.53 -4.07 -0.08 -23.1 29.6 ...
#> $ x52_wk_range1 : num 74436.68 1386.8 1 1.53 509.84 ...
#> $ x52_wk_range2 : num 1.26e+05 4.95e+03 1.01 3.65 1.37e+03 ...
#> $ price : num 95604.54 3327.3 1 2.17 945.86 ...
#> $ from : chr "BTC" "ETH" "USDT" "XRP" ...
#> $ to : chr "USD" "USD" "USD" "USD" ...
#> - attr(*, "n.currencies")= int 101
#> - attr(*, "currencies")= chr [1:101] "BTC" "ETH" "USDT" "XRP" ...
#> - attr(*, "exchange")= chr [1:100] "BTC => USD" "ETH => USD" "USDT => USD" "XRP => USD" ...
#> - attr(*, "date.fetch")= Date[1:1], format: "2026-01-13"
#> - attr(*, "crypto")= logi TRUE