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