Brazilian Monthly Banking Statistics by Municipality (ESTBAN)

Download, read and tidy the ESTBAN (Estatistica Bancaria Mensal por Municipio, Monthly Banking Statistics by Municipality) files published by the Brazilian Central Bank (Banco Central do Brasil) for every bank branch and municipality in Brazil. Each file reports balance-sheet accounts of the COSIF (Plano Contabil das Instituicoes do Sistema Financeiro Nacional, the chart of accounts of the Brazilian financial system) such as credit operations, deposits and savings. Files are fetched from the official site < https://www.bcb.gov.br/estatisticas/estatisticabancariamunicipios> with an idempotent local cache, read from their Latin-1 encoded CSV (comma-separated values) layout into tibbles, optionally filtered by state, and aggregated by municipality. Includes tools to detect and impute institution-month non-reports (an institution present in the file with every account equal to zero), which would otherwise be mistaken for zero balances.


estbanr estbanr logo

R-CMD-check CRAN status Dev version

estbanr downloads, reads and tidies ESTBAN (Estatística Bancária Mensal por Município), the monthly banking statistics that the Brazilian Central Bank publishes for every bank branch and municipality in Brazil: about 45 balance-sheet accounts of the COSIF chart (credit operations, financing, rural credit, savings and time deposits, ...) since 1988. It is the only public source of credit and deposits at the municipal level.

Step Function
Find the file name for a month (the naming changed over the years) estban_url()
Download with an idempotent local cache estban_download()
Read the Latin-1 CSV into a typed tibble, optionally one state estban_read()
Download and read a range of months estban_fetch()
Column layout and COSIF account dictionary estban_columns(), estban_verbetes()
Detect and impute non-reported institution-months estban_flag_nonreport(), estban_impute_nonreport()
Aggregate to the municipality (wide or long) estban_by_municipality()
❕ Disclaimer
This package is a client for public files published by the Banco Central do Brasil (BCB), which is the institution responsible for the data. Function names and arguments are in English; column names follow the source files (Portuguese, converted to snake_case), and account descriptions are in Portuguese as published. The official page is Estatística Bancária por Município.

Installation

# From CRAN (when available):
install.packages("estbanr")

# Development version:
# remotes::install_github("StrategicProjects/estbanr")

Quick start

library(estbanr)

# Persistent cache (optional; the default is a folder under tempdir())
options(estbanr.cache_dir = "~/data/estban")

# One year of Pernambuco, one row per branch
x <- estban_fetch(202301, 202312, uf = "PE")

# Which account is which
v <- estban_verbetes()
v[v$code %in% c(160, 420, 432), c("name", "codes", "side")]

# Municipal totals, with non-reported institution-months interpolated
m <- estban_by_municipality(x)
m[, c("municipio", "ref", "verbete_160_operacoes_de_credito")]

Everything can be tried offline with the small real extract shipped in inst/extdata/ (Pernambuco and Paraíba, January 2024):

f <- system.file("extdata", "202401_ESTBAN_AG_sample.CSV", package = "estbanr")
estban_read(f, uf = "PE")

Why the non-report tools exist

Once in a while a bank's monthly return does not make it into the ESTBAN file: the bank is still listed, with every account equal to zero in every branch of the country (Banco Santander, January to March 2025, is a documented case). Summed into a municipal series that looks like a credit collapse followed by a rebound. estban_flag_nonreport() finds those institution-months and estban_impute_nonreport() fills interior gaps by linear interpolation, never extrapolating at the edges. See vignette("nonreport-imputation").

Related packages by the same group

tesouror (National Treasury APIs), pixr (Pix open data), comexr (foreign trade), tceper (Pernambuco Court of Accounts), ibger (IBGE aggregates).

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("estbanr")

0.1.1 by Andre Leite, 20 days ago


https://strategicprojects.github.io/estbanr/, https://github.com/StrategicProjects/estbanr


Report a bug at https://github.com/StrategicProjects/estbanr/issues


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


Authors: Andre Leite [aut, cre] , Marcos Wasiliew [aut] , Hugo Vasconcelos [aut] , Carlos Amorim [aut] , Diogo Bezerra [aut] , Júlia Nascimento Barreto [aut]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports cli, dplyr, httr2, readr, rlang, stats, stringi, tibble, utils

Suggests knitr, rmarkdown, testthat, withr


See at CRAN