get_institutions: Download and Process Brazilian Financial Institutions Data...

View source: R/get_institutions.R

get_institutionsR Documentation

Download and Process Brazilian Financial Institutions Data from Bacen

Description

[Stable]

This function downloads financial institutions data from the Brazilian Central Bank (Bacen) website for specified institution types and date ranges. The data is downloaded as ZIP files, extracted, and can be optionally cleaned up.

Usage

get_institutions(
  institution,
  years,
  months,
  out_dir,
  cleanup_zip = TRUE,
  verbose = TRUE
)

Arguments

institution

Character vector. Type(s) of financial institutions to download. Valid options are:

  • "CONGLOMERADOS"

  • "BANCOS"

  • "COOPERATIVAS"

  • "ADMCONSORCIO"

  • "SOCIEDADES"

Default is "COOPERATIVAS". Case-insensitive. Check the details on Bacen's website.

years

Numeric vector. Year(s) to download, e.g. c(2020:2023) or c(2020, 2022).

months

Numeric vector. Month(s) to download, values between 1 and 12, e.g. c(1:12) or c(6, 12).

out_dir

Character. Directory path where downloaded files will be saved. Default is "data". The directory will be created if it doesn't exist.

cleanup_zip

Logical. If TRUE, removes ZIP files after extraction. Default is TRUE.

verbose

Logical. If TRUE, displays progress messages and warnings. Default is TRUE.

Details

The function performs the following steps:

  • Validates institution types against known valid options

  • Generates every combination of years x months as year-month strings

  • Downloads ZIP files for each institution and month from BCB website

  • Extracts the downloaded ZIP files to the output directory

  • Optionally removes ZIP files after extraction

  • Displays progress information if verbose = TRUE

For CONGLOMERADOS, the file suffix on BCB's server changed from the plural "CONGLOMERADOS" to the singular "CONGLOMERADO" starting in months after 2022 (e.g. ⁠.../202208CONGLOMERADOS.zip⁠ vs. ⁠.../202607CONGLOMERADO.zip⁠). This is handled internally and is transparent to the caller.

Institution type mappings:

  • CONGLOMERADOS: Conglomerados

  • BANCOS: Bancos comerciais, múltiplos e caixa

  • COOPERATIVAS: Cooperativas de crédito

  • ADMCONSORCIO: Consórcios administrativos

  • SOCIEDADES: Bancos de investimentos, desenvolvimento e sociedades corretoras

Value

Invisible NULL. The function is called for its side effects (downloading and extracting files to the specified directory).

See Also

https://www.bcb.gov.br/estabilidadefinanceira/relacao_instituicoes_funcionamento

Examples

# Download cooperative credit unions data for 2023
get_institutions(
  institution = "COOPERATIVAS",
  years = 2023,
  months = 11:12,
  out_dir = tempdir()
)

# Download multiple institution types
get_institutions(
  institution = c("BANCOS", "COOPERATIVAS"),
  years = 2022,
  months = 1:12,
  out_dir = tempdir()
)

# Skip downloading, just use existing files
get_institutions(
  institution = "BANCOS",
  years = 2022,
  months = 1:12,
  out_dir = tempdir(),
  verbose = FALSE
)


bacenR documentation built on Oct. 24, 2026, 1:07 a.m.