Skip to contents

Downloads market data based on a template and parameter combinations, then reads the data into a database.

Usage

fetch_marketdata(template, do_cache = FALSE, throttle = FALSE, ...)

Arguments

template

A character string specifying the market data template to use

do_cache

A logical value indicating whether to cache the downloaded files (default is FALSE). If TRUE, the downloaded files will be cached for future use. This can be useful for avoiding repeated downloads of the same data.

throttle

A logical value indicating whether to throttle the download requests (default is FALSE). If TRUE, a 1-second delay is introduced between requests to avoid overwhelming the server.

...

Named arguments that will be expanded into a grid of all combinations to fetch data for

Details

This function performs two main steps:

  1. Downloads market data files by creating all combinations of the provided parameters and calling download_marketdata() for each combination

  2. Processes the downloaded files by reading them into a database using read_marketdata()

Progress indicators are displayed during both steps, and warnings are shown for combinations that failed to download or produced invalid files.

The throttle parameter is useful for avoiding server overload and ensuring that the requests are sent at a reasonable rate. If set to TRUE, a 1-second delay is introduced between each download request.

Examples

if (FALSE) { # \dontrun{
fetch_marketdata("b3-cotahist-yearly", year = 2020:2024)
fetch_marketdata("b3-cotahist-daily", refdate = bizseq("2025-01-01", "2025-03-10", "Brazil/B3"))
fetch_marketdata("b3-reference-rates",
  refdate = bizseq("2025-01-01", "2025-03-10", "Brazil/B3"),
  curve_name = c("DIC", "DOC", "PRE")
)
fetch_marketdata("b3-indexes-historical-data",
  throttle = TRUE, index = c("IBOV", "IBXX", "IBXL"),
  year = 2000:2025
)
} # }