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-08-23 --> 2024-09-22 (30 days) ──
#> 
#>  Downloading data for benchmark ticker ^BVSP
#>  (1/88) Fetching data for ABEV3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Good stuff!
#>  (2/88) Fetching data for ALPA4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Got it!
#>  (3/88) Fetching data for AMER3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Looking good!
#>  (4/88) Fetching data for ASAI3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Got it!
#>  (5/88) Fetching data for AZUL4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Boa!
#>  (6/88) Fetching data for B3SA3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Mas bah tche, que coisa linda!
#>  (7/88) Fetching data for BBAS3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Good job !
#>  (8/88) Fetching data for BBDC3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- All OK!
#>  (9/88) Fetching data for BBDC4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Well done !
#>  (10/88) Fetching data for BBSE3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Mas bah tche, que coisa linda!
#>  (11/88) Fetching data for BEEF3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- 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 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- You got it !
#>  (14/88) Fetching data for BPAN4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Good stuff!
#>  (15/88) Fetching data for BRAP4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Nice!
#>  (16/88) Fetching data for BRFS3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- You got it !
#>  (17/88) Fetching data for BRKM5.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- 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 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (20/88) Fetching data for CCRO3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (21/88) Fetching data for CIEL3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- **REMOVED** found only 10% of valid prices (thresh_bad_data = 75%)
#>  (22/88) Fetching data for CMIG4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Got it!
#>  (23/88) Fetching data for COGN3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (24/88) Fetching data for CPFE3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Got it!
#>  (25/88) Fetching data for CPLE6.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Good stuff!
#>  (26/88) Fetching data for CRFB3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Good stuff!
#>  (27/88) Fetching data for CSAN3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Nice!
#>  (28/88) Fetching data for CSNA3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- All OK!
#>  (29/88) Fetching data for CVCB3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Nice!
#>  (30/88) Fetching data for CYRE3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Youre doing good!
#>  (31/88) Fetching data for DXCO3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Got it!
#>  (32/88) Fetching data for ECOR3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Nice!
#>  (33/88) Fetching data for EGIE3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Nice!
#>  (34/88) Fetching data for ELET3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Good stuff!
#>  (35/88) Fetching data for ELET6.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- You got it !
#>  (36/88) Fetching data for EMBR3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Looking good!
#>  (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 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Got it!
#>  (39/88) Fetching data for ENGI11.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Good job !
#>  (40/88) Fetching data for EQTL3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (41/88) Fetching data for EZTC3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Got it!
#>  (42/88) Fetching data for FLRY3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Youre doing good!
#>  (43/88) Fetching data for GGBR4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- You got it !
#>  (44/88) Fetching data for GOAU4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (45/88) Fetching data for GOLL4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Youre doing good!
#>  (46/88) Fetching data for HAPV3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (47/88) Fetching data for HYPE3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Nice!
#>  (48/88) Fetching data for IGTI11.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Good job !
#>  (49/88) Fetching data for IRBR3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (50/88) Fetching data for ITSA4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Looking good!
#>  (51/88) Fetching data for ITUB4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (52/88) Fetching data for JBSS3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Good stuff!
#>  (53/88) Fetching data for JHSF3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- All OK!
#>  (54/88) Fetching data for KLBN11.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Youre doing good!
#>  (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 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Nice!
#>  (57/88) Fetching data for LWSA3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- All OK!
#>  (58/88) Fetching data for MGLU3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Looking good!
#>  (59/88) Fetching data for MRFG3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Good stuff!
#>  (60/88) Fetching data for MRVE3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Good stuff!
#>  (61/88) Fetching data for MULT3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Good job !
#>  (62/88) Fetching data for NTCO3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Well done !
#>  (63/88) Fetching data for PCAR3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Got it!
#>  (64/88) Fetching data for PETR3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Looking good!
#>  (65/88) Fetching data for PETR4.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Got it!
#>  (66/88) Fetching data for PETZ3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (67/88) Fetching data for PRIO3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Well done !
#>  (68/88) Fetching data for QUAL3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Well done !
#>  (69/88) Fetching data for RADL3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Good stuff!
#>  (70/88) Fetching data for RAIL3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Youre doing good!
#>  (71/88) Fetching data for RDOR3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Good stuff!
#>  (72/88) Fetching data for RENT3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (73/88) Fetching data for SANB11.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Good job !
#>  (74/88) Fetching data for SBSP3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Mais faceiro que guri de bombacha nova!
#>  (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 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Got it!
#>  (78/88) Fetching data for TAEE11.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Well done !
#>  (79/88) Fetching data for TIMS3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Well done !
#>  (80/88) Fetching data for TOTS3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Mais faceiro que guri de bombacha nova!
#>  (81/88) Fetching data for UGPA3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Good stuff!
#>  (82/88) Fetching data for USIM5.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Parabens , tudo certo!
#>  (83/88) Fetching data for VALE3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Looking good!
#>  (84/88) Fetching data for VBBR3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (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 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- You got it !
#>  (87/88) Fetching data for WEGE3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Time for some tea?
#>  (88/88) Fetching data for YDUQ3.SA
#> ! 	- not cached
#>  	- cache saved successfully
#>  	- got 21 valid rows (2024-08-23 --> 2024-09-20)
#>  	- got 100% of valid prices -- Nice!
#>  Binding price data
#> 
#> ── Diagnostics ─────────────────────────────────────────────────────────────────
#>  Returned dataframe with 1680 rows -- Youre doing good!
#>  Using 259.7 kB at /tmp/RtmpGaaXZg/yf_cache for 82 cache files
#>  Out of 88 requested tickers, you got 80 (91%)
# }