Access to Brazilian Macroeconomic and Financial Time Series.
brfinance ππ§π·
brfinance is an R package that provides simplified access to Brazilian macroeconomic time series from the Central Bank of Brazil, along with practical financial calculators.
If you work with Brazilian data, interest rates, inflation, or financial math, this package is for you.
Why brfinance?
With brfinance, you can:
- Access official Brazilian macroeconomic time series from the Central Bank of Brazil (SGS)
- Retrieve clean and standardized time series (
date+value) - Plot key indicators with one line of code
- Run financial calculations (NPV, IRR, PV, FV, PMT, rates)
No manual API handling. No data wrangling required.
Installation
install.packages("brfinance")
# Or development version from GitHub
install.packages("devtools")
devtools::install_github("efram2/brfinance")
library(brfinance)
π Quick Start
Inflation (IPCA)
plot_inflation_rate(
get_inflation_rate("2020", "2024")
)
SELIC interest rate
plot_selic_rate(
get_selic_rate(2020, 2024)
)
Unemployment rate
plot_unemployment(
get_unemployment("2019", "2024")
)
Compare multiple indicators in one chart
You can compare different economic indicators using: 1. raw values 2. indexed series (base = first observation) 3. percentage change from the first observation
- Want to analyze how different economic indicators evolve together?
- Use plot_series_comparison() to compare multiple time series in a single, clean visualization.
plot_series_comparison(
data_list = list(
"SELIC" = get_selic_rate(2020, 2024),
"IPCA" = get_inflation_rate("2020", "2024"),
"Unemployment" = get_unemployment("2020", "2024")
),
y_vars = rep("value", 3),
date_vars = rep("date", 3),
scale_type = "index",
title = "Brazilian Economic Indicators",
subtitle = "Indexed comparison (base = first observation)"
)
Financial Calculators (minimalista)
# Net Present Value
calc_npv(0.1, c(-1000, 300, 400, 500))
# Internal Rate of Return
calc_irr(c(-1000, 300, 400, 500))
# Loan payment
calc_pmt(rate = 0.02, n = 24, pv = 10000)
Function Reference
Data retrieval functions (get_*)
get_inflation_rate()β Retrieves Brazilβs official inflation rate (IPCA)get_selic_rate()β Retrieves the SELIC interest rateget_cdi_rate()β Retrieves the CDI interest rateget_exchange_rate()β Retrieves official exchange ratesget_gdp_growth()β Retrieves GDP growth ratesget_unemployment()β Retrieves unemployment rate from PNAD ContΓnua
All get_* functions support flexible date inputs: "YYYY", "YYYY-MM", or "YYYY-MM-DD".
Plotting functions (plot_*)
plot_inflation_rate()β Plots IPCA inflation over timeplot_selic_rate()β Plots the SELIC interest rateplot_cdi_rate()β Plots the CDI interest rateplot_exchange_rate()β Plots exchange rate time seriesplot_gdp_growth()β Plots GDP growth over timeplot_unemployment()β Plots unemployment rate time seriesplot_series_comparison()β Compares multiple economic indicators in one chart
Financial calculators (calc_*)
calc_pv()β Present Valuecalc_fv()β Future Valuecalc_npv()β Net Present Valuecalc_irr()β Internal Rate of Returncalc_pmt()β Loan payment calculationcalc_rate()β Interest rate calculationcalc_nper()β Number of periodscalc_compound_interest()β Compound interest calculationcalc_continuous_interest()β Continuous compoundingcalc_rule72()β Rule of 72 approximationcalc_rule114()β Rule of 114 approximation
Language Support
All main functions support bilingual output:
- language = βengβ (default): Returns English column names and labels
- language = βptβ: Returns Portuguese column names and labels
Data sources
All data are retrieved from official Brazilian institutions:
- Central Bank of Brazil (BCB) via the SGS API
Contribution
Suggestions, feature requests, and pull requests are welcome!