Macroeconomic Expectations Data in R using the Central Bank of Brazil API

Provides quick and easy access to market expectations data to the main macroeconomic indicators in the Focus report, made available by the Central Bank of Brazil through the Expectations System data API < https://dadosabertos.bcb.gov.br/>. This package offers an R interface to the API and other advantages, such as using a caching system and the option to use all the machine's cores (parallel computing).


meedr

CRANstatus R-CMD-check Travis buildstatus AppVeyor buildstatus CRANdownloads

The goal of meedr is to provide quick and easy access to market expectations data to the main macroeconomic indicators in the Focus report, made available by the Central Bank of Brazil through the Expectations System data API. This data comes from several financial institutions, such as: banks, brokers, funds, consultancies, etc.

The meedr package offers an R interface to the API and other advantages:

  • Use of a caching system with package memoise to speed up repeated requests of data;
  • User can utilize all cores of the machine (parallel computing) when fetching a large batch of time series.

Check the meedr pkgdown page for more general information ;)

Installation

You can install the released version of meedr from CRAN with:

install.packages("meedr")

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("schoulten/meedr")

Features

Example

These are some basic examples of using the package:

get_monthly()

library(meedr)

# Monthly market expectations for IPCA indicator
ipca <- meedr::get_monthly(
  indicator      = "IPCA",
  first_date     = Sys.Date()-30,
  reference_date = format(Sys.Date(), "%m/%Y"),
  be_quiet       = TRUE
  )

head(ipca, 5)
#> # A tibble: 5 x 11
#>   indicator date       reference_date  mean median    sd coef_var   min   max
#>   <chr>     <date>     <chr>          <dbl>  <dbl> <dbl>    <dbl> <dbl> <dbl>
#> 1 IPCA      2021-07-16 07/2021         0.66   0.71  0.17     26.3  0.13  0.94
#> 2 IPCA      2021-07-16 07/2021         0.72   0.77  0.15     20.3  0.13  0.93
#> 3 IPCA      2021-07-15 07/2021         0.65   0.7   0.18     27.5  0.13  0.94
#> 4 IPCA      2021-07-15 07/2021         0.72   0.77  0.15     21.2  0.13  0.94
#> 5 IPCA      2021-07-14 07/2021         0.64   0.68  0.18     28.4  0.13  0.94
#> # ... with 2 more variables: n_respondents <int>, basis <int>

get_quarterly()

# Quarterly market expectations for GDP indicator
meedr::get_quarterly(
  indicator      = "PIB Total",
  first_date     = "2021-01-01",
  reference_date = paste0(lubridate::quarter(Sys.Date()), "/", lubridate::year(Sys.Date())),
  be_quiet       = TRUE
  )

get_annual()

# Annual market expectations for SELIC and exchange rate (BRL) indicator
meedr::get_annual(
  indicator      = c("Meta para taxa over-selic", "Taxa de câmbio"),
  reference_date = format(Sys.Date(), "%Y"),
  be_quiet       = TRUE
  )

get_inflation_12m()

# Inflation over the next 12 months
# First, and a suggestion, run this for using parallel computing:
future::plan(future::multisession, workers = floor(future::availableCores()/2))
meedr::get_inflation_12m(
  indicator   = c("IGP-DI", "IGP-M", "INPC", "IPA-DI", "IPA-M", "IPCA", "IPCA-15", "IPC-FIPE"),
  smoothed    = "yes",
  be_quiet    = FALSE, # display messages
  do_parallel = TRUE # turn on parallel computing
  )

get_monthly_top5()

# Monthly market expectations for IGP-M indicator (Top 5 Focus)
meedr::get_monthly_top5(
  indicator  = "IGP-M",
  first_date = NULL, # get all data to current date
  calc_type  = "long",
  be_quiet   = TRUE
  )

get_annual_top5()

# Annual market expectations for SELIC indicator (Top 5 Focus)
meedr::get_annual_top5(
  indicator   = "Meta para taxa over-selic",
  detail      = "Fim do ano",
  be_quiet    = TRUE,
  use_memoise = FALSE # disable caching system
  )

Related works

Check out some similar works:

  • rbcb: R interface to Brazilian Central Bank web services by @wilsonfreitas

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("meedr")

0.0.2 by Fernando da Silva, 5 years ago


https://fortietwo.com/meedr/, https://github.com/schoulten/meedr


Report a bug at https://github.com/schoulten/meedr/issues


Browse source code at https://github.com/cran/meedr


Authors: Fernando da Silva [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports dplyr, furrr, future, httr, jsonlite, memoise, purrr, lubridate

Suggests testthat, knitr, rmarkdown, utf8


See at CRAN