Skip to contents

This function will use a set collection of YF data, such as index components and will download all data from Yahoo Finance using yf_get.

Usage

yf_collection_get(
  collection,
  first_date = Sys.Date() - 30,
  last_date = Sys.Date(),
  do_parallel = FALSE,
  do_cache = TRUE,
  cache_folder = yf_cachefolder_get(),
  ...
)

Arguments

collection

A collection to fetch data (e.g. "SP500", "IBOV", "FTSE" ). See function yf_get_available_collections for finding all available collections

first_date

The first date of query (Date or character as YYYY-MM-DD)

last_date

The last date of query (Date or character as YYYY-MM-DD)

do_parallel

Flag for using parallel or not (default = FALSE). Before using parallel, make sure you call function future::plan() first. See <https://furrr.futureverse.org/> for more details.

do_cache

Use cache system? (default = TRUE)

cache_folder

Where to save cache files? (default = yfR::yf_cachefolder_get() )

...

Other arguments passed to yf_get

Value

A data frame with financial prices from collection

Examples


# \donttest{
df_yf <- yf_collection_get(collection = "IBOV",
                           first_date = Sys.Date() - 30,
                           last_date = Sys.Date()
)
#> 
#> ── Fetching price collection for IBOV ──────────────────────────────────────────
#> Error in dplyr::rename(., ticker = Ticker, company = Company, industry = Industry) : 
#>   Can't rename columns that don't exist.
#>  Column `Ticker` doesn't exist.
#>  Failed to import current composition for IBOV. Using fallback index
#>  Using fallback IBOV composition from 2024-06-24
#> 
#> ── Running yfR for 88 stocks | 2024-10-22 --> 2024-11-21 (30 days) ──
#> 
#>  Downloading data for benchmark ticker ^BVSP
#>  (1/88) Fetching data for ABEV3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good stuff!
#>  (2/88) Fetching data for ALPA4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Got it!
#>  (3/88) Fetching data for AMER3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Looking good!
#>  (4/88) Fetching data for ASAI3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Got it!
#>  (5/88) Fetching data for AZUL4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Boa!
#>  (6/88) Fetching data for B3SA3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Mas bah tche, que coisa linda!
#>  (7/88) Fetching data for BBAS3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good job !
#>  (8/88) Fetching data for BBDC3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- All OK!
#>  (9/88) Fetching data for BBDC4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Well done !
#>  (10/88) Fetching data for BBSE3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Mas bah tche, que coisa linda!
#>  (11/88) Fetching data for BEEF3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Got it!
#>  (12/88) Fetching data for BIDI11.SA
#> ! 	- not cached
#>  	- error in download..
#>  (13/88) Fetching data for BPAC11.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- You got it !
#>  (14/88) Fetching data for BPAN4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good stuff!
#>  (15/88) Fetching data for BRAP4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Nice!
#>  (16/88) Fetching data for BRFS3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- You got it !
#>  (17/88) Fetching data for BRKM5.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good job !
#>  (18/88) Fetching data for BRML3.SA
#> ! 	- not cached
#>  	- error in download..
#>  (19/88) Fetching data for CASH3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (20/88) Fetching data for CCRO3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (21/88) Fetching data for CIEL3.SA
#> ! 	- not cached
#>  	- error in download..
#>  (22/88) Fetching data for CMIG4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good stuff!
#>  (23/88) Fetching data for COGN3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Got it!
#>  (24/88) Fetching data for CPFE3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (25/88) Fetching data for CPLE6.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Got it!
#>  (26/88) Fetching data for CRFB3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good stuff!
#>  (27/88) Fetching data for CSAN3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good stuff!
#>  (28/88) Fetching data for CSNA3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Nice!
#>  (29/88) Fetching data for CVCB3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- All OK!
#>  (30/88) Fetching data for CYRE3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Nice!
#>  (31/88) Fetching data for DXCO3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Youre doing good!
#>  (32/88) Fetching data for ECOR3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Got it!
#>  (33/88) Fetching data for EGIE3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Nice!
#>  (34/88) Fetching data for ELET3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Nice!
#>  (35/88) Fetching data for ELET6.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good stuff!
#>  (36/88) Fetching data for EMBR3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- You got it !
#>  (37/88) Fetching data for ENBR3.SA
#> ! 	- not cached
#>  	- error in download..
#>  (38/88) Fetching data for ENEV3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Looking good!
#>  (39/88) Fetching data for ENGI11.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Got it!
#>  (40/88) Fetching data for EQTL3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good job !
#>  (41/88) Fetching data for EZTC3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (42/88) Fetching data for FLRY3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Got it!
#>  (43/88) Fetching data for GGBR4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Youre doing good!
#>  (44/88) Fetching data for GOAU4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- You got it !
#>  (45/88) Fetching data for GOLL4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (46/88) Fetching data for HAPV3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Youre doing good!
#>  (47/88) Fetching data for HYPE3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (48/88) Fetching data for IGTI11.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Nice!
#>  (49/88) Fetching data for IRBR3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good job !
#>  (50/88) Fetching data for ITSA4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (51/88) Fetching data for ITUB4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Looking good!
#>  (52/88) Fetching data for JBSS3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (53/88) Fetching data for JHSF3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good stuff!
#>  (54/88) Fetching data for KLBN11.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- All OK!
#>  (55/88) Fetching data for LCAM3.SA
#> ! 	- not cached
#>  	- error in download..
#>  (56/88) Fetching data for LREN3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Youre doing good!
#>  (57/88) Fetching data for LWSA3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Nice!
#>  (58/88) Fetching data for MGLU3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- All OK!
#>  (59/88) Fetching data for MRFG3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Looking good!
#>  (60/88) Fetching data for MRVE3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good stuff!
#>  (61/88) Fetching data for MULT3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good stuff!
#>  (62/88) Fetching data for NTCO3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good job !
#>  (63/88) Fetching data for PCAR3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Well done !
#>  (64/88) Fetching data for PETR3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Got it!
#>  (65/88) Fetching data for PETR4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Looking good!
#>  (66/88) Fetching data for PETZ3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Got it!
#>  (67/88) Fetching data for PRIO3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (68/88) Fetching data for QUAL3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Well done !
#>  (69/88) Fetching data for RADL3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Well done !
#>  (70/88) Fetching data for RAIL3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good stuff!
#>  (71/88) Fetching data for RDOR3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Youre doing good!
#>  (72/88) Fetching data for RENT3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good stuff!
#>  (73/88) Fetching data for SANB11.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (74/88) Fetching data for SBSP3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good job !
#>  (75/88) Fetching data for SOMA3.SA
#> ! 	- not cached
#>  	- error in download..
#>  (76/88) Fetching data for SULA11.SA
#> ! 	- not cached
#>  	- error in download..
#>  (77/88) Fetching data for SUZB3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Mais faceiro que guri de bombacha nova!
#>  (78/88) Fetching data for TAEE11.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Got it!
#>  (79/88) Fetching data for TIMS3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Well done !
#>  (80/88) Fetching data for TOTS3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Well done !
#>  (81/88) Fetching data for UGPA3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Mais faceiro que guri de bombacha nova!
#>  (82/88) Fetching data for USIM5.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Good stuff!
#>  (83/88) Fetching data for VALE3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Parabens , tudo certo!
#>  (84/88) Fetching data for VBBR3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Looking good!
#>  (85/88) Fetching data for VIIA3.SA
#> ! 	- not cached
#>  	- error in download..
#>  (86/88) Fetching data for VIVT3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (87/88) Fetching data for WEGE3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- You got it !
#>  (88/88) Fetching data for YDUQ3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 20 valid rows (2024-10-22 --> 2024-11-19)
#>  	- got 100% of valid prices -- Time for some tea?
#>  Binding price data
#> 
#> ── Diagnostics ─────────────────────────────────────────────────────────────────
#>  Returned dataframe with 1600 rows -- Nice!
#>  Using 249.8 kB at /tmp/Rtmpco0j0F/yf_cache for 81 cache files
#>  Out of 88 requested tickers, you got 80 (91%)
# }