This library was developed for economic analysis in the Brazilian scenario (Investments, micro and macroeconomic indicators)
Install using pip
pip install pybacen
from pybacen.bacen import time_series # Source: SGS - Sistema Gerenciador de Séries Temporais - v2.1 (Bacen - Banco Central)
# To consult the Bacen code, use it as a parameter when consulting the time series
list_code_bacen = time_series.read_bacen_code(search_text='%CDI%ANUALIZADA%252%', period= 'D', unit= '% a.a.')
list_code_bacen
COD_BACEN | NM_SERIE | UNIDADE | PERIODICIDADE | FONTE | ESPECIAL | |
---|---|---|---|---|---|---|
4015 | 4389 | Taxa de juros - CDI anualizada base 252 | % a.a. | D | BCB-Demab | N |
ts = time_series.read_time_series(bacen_code= 4389, start='2021-11-04', end='2021-11-04', as_index=True)
ts
valor | |
---|---|
date | |
2021-11-04 | 7.65 |
from pybacen.yahoo_finance import stocks # Source: Yahoo Finance - Stock Quote
# Ibovespa - 2021-11-05
sq = stocks.read_stock_quote(stock_code='^BVSP', start= '2021-11-05', end= '2021-11-05', as_index= True)
sq
open | high | low | close | volume | adjclose | |
---|---|---|---|---|---|---|
date | ||||||
2021-11-05 | 103412.0 | 105555.0 | 103412.0 | 104824.0 | 12595000.0 | 104824.0 |
Using pandas datareader requires the following packages:
- pandas>=1.0
- requests>=2.19.0
python -m pip install pip install pybacen
or
git clone https://github.com/RPCastro07/pybacen.git
cd pybacen
python setup.py install