Skip to contents

B3 provides various files containing valuable information about traded assets on the exchange and over-the-counter (OTC) market. These files include historical market data, trading data, and asset registration data for stocks, derivatives, and indices. This function reads these files and parses their content according to the specifications defined in a template.

Usage

read_marketdata(meta)

Arguments

meta

A list containing the downloaded file's metadata, typically returned by download_marketdata.

Value

This function invisibly returns the parsed data.frame if successful, or NULL if an error occurred.

Details

This function reads the downloaded file and parses its content according to the specifications and schema defined in the template associated with the meta object. The template specifies the file format, column definitions, and data types.

The parsed data is then written to a partitioned dataset in Parquet format, stored in a directory structure based on the template name and data layer. This directory is located within the db subdirectory of the rb3.cachedir directory. The partitioning scheme is also defined in the template, allowing for efficient querying of the data using the arrow package.

If an error occurs during file processing, the function issues a warning, removes the downloaded file and its metadata, and returns NULL.

Examples

if (FALSE) { # \dontrun{
meta <- download_marketdata("b3-cotahist-daily", refdate = as.Date("2024-04-05"))
read_marketdata(meta)
} # }