Downloads and caches financial market datasets from B3 (Brazilian Stock Exchange) based on predefined templates. Handles file downloading and caching.
Value
Returns a meta object containing the downloaded file's metadata:
template - Name of the template used
download_checksum - Unique hash code for the download
download_args - Arguments passed via ...
downloaded - Path to the downloaded file
created - Timestamp of file creation
A meta object containing the downloaded file's metadata.
This meta object is used with the read_marketdata
function to read the downloaded file.
Details
The function follows this workflow:
Checks if requested data exists in cache
Downloads data if needed (based on template specifications)
Manages file compression and storage
Maintains metadata for tracking and verification
Files are organized in the rb3.cachedir
as follows:
Metadata: JSON files in 'meta/' directory, named by download_checksum
Data: Gzipped files in 'raw/' directory, named by file's checksum
Templates are YAML documents that define:
Download parameters and methods
Data reading instructions
Dataset structure (columns, types)
Templates can be found using list_templates()
and retrieved with template_retrieve()
.
See also
list_templates
for listing available data templatestemplate_retrieve
for retrieving specific template details
Examples
if (FALSE) { # \dontrun{
# Download daily market data
meta <- download_marketdata("b3-cotahist-daily",
refdate = as.Date("2024-04-05"))
read_marketdata(meta)
# Download reference rates
meta <- download_marketdata("b3-reference-rates",
refdate = as.Date("2024-04-05"),
curve_name = "PRE")
read_marketdata(meta)
} # }