Skip to main content

Provides Python functions to retrieve public data from ANBIMA related to the Brazilian fixed income market.

Project description

🏛️ ANBIMA public data for Brazilian fixed income

PyPI version Build Status License: MIT

Provides Python functions to retrieve public data from ANBIMA related to the Brazilian fixed income market. The package offers streamlined access to:

  • Historical and current performance of IMA indices.
  • Portfolio compositions.
  • The term structure of Brazilian interest rates and the implied inflation calculated by ANBIMA.
  • Historical and projected values of IGP-M and IPCA inflation indices.
  • The last five daily prices of Brazilian federal government bonds traded in the secondary market.

📋 Features

  • Inflation Index Projections: Retrieve historical and consensus-based monthly projections for IGP-M and IPCA inflation indices (get_macro_index_projections).
  • Federal Bonds Data: Access recent prices, reference rates, and intraday price ranges of Brazilian federal government bonds traded in the secondary market (get_federal_bonds).
  • Yield Curve: Obtain the term structure of Brazilian interest rates with options for tabular or graphical output (get_yield_curve).
  • Daily Portfolio Performance: Fetch daily market value-based performance data for IMA family fixed income indices (get_daily_portfolio_performance).
  • Portfolio Composition: Retrieve current portfolio breakdowns for ANBIMA fixed income indices (get_portfolio_composition).
  • Index Performance Time Series: Access historical time series data of ANBIMA fixed income indices with customizable output formats including graphs (get_index_performance).

⚙️ How it works

🔧 Installation

Install the anbima-data package using one of the following options:

• PyPI (recommended)

pip install anbima-data

• Directly from GitHub

pip install git+https://github.com/seu-usuario/anbima-data.git

• Clone and install manually

git clone https://github.com/seu-usuario/anbima-data.git
cd anbima-data
pip install .

💡 Example of Usage

Below are examples demonstrating how to use the main functions provided by the package.

1. 📈 Inflation Index Projections

# 📥 Input
import anbima_data as anb

df_igpm_proj = anb.get_macro_index_projections(index="IGP-M", table="projecao_mes")

print(df_igpm_proj)
# 📤 Output

Example:
1  Mês de Coleta       Data  Projeção (%) Data de Validade*
0  Abril de 2025 2025-04-29          0.29        2025-05-05
1   Maio de 2025 2025-05-12          0.14        2025-05-13
2   Maio de 2025 2025-05-20         -0.22        2025-05-21

2. 💵 Federal Bonds Data

# 📥 Input
import anbima_data as anb

df_bond = anb.get_federal_bonds(bond="ntn-b", output="dataframe")
print(df_bond)
# 📤 Output
<DataFrame resumido  apenas algumas colunas e linhas>

Example:
Código SELIC Data Base/Emissão Data de Vencimento  Tx. Compra  Tx. Venda  \
0        760199        2000-07-15         2026-08-15      9.1260     9.0885   
1        760199        2000-07-15         2027-05-15      8.0595     8.0241   
2        760199        2000-07-15         2028-08-15      7.6046     7.5700   
3        760199        2000-07-15         2029-05-15      7.4005     7.3669   
4        760199        2000-07-15         2030-08-15      7.3901     7.3601   
..          ...               ...                ...         ...        ...   

3. 📉 Yield Curve

When the output parameter is set to 'dataframe':

# 📥 Input
import anbima_data as anb

df_yield = anb.get_yield_curve(output="dataframe")
print(df_yield)
# 📤 Output
Example:
           ETTJ_IPCA  ETTJ_Prefixados  Inflação_implícita
Vértices                                                
252          9.5662          14.4570              4.4637
378          8.6342          14.0535              4.9885
504          8.1623          13.7907              5.2036
630          7.8871          13.6674              5.3577
756          7.7103          13.6422              5.5072
...             ...              ...                 ... 

When the output parameter is set to 'chart':

# 📥 Input
import anbima_data as anb

df_yield = anb.get_yield_curve(output="chart", column_name = "ETTJ_IPCA")
print(df_yield)

📤 Output

Output gráfico do get_index_performance

4. 📊 Daily Portfolio Performance

# 📥 Input
import anbima_data as anb

df_daily = anb.get_daily_portfolio_performance(index="ima-geral")
print(df_daily)
# 📤 Output
Example:
Data Referência Referência Títulos Vencimento Código SELIC   Código ISIN  \
0       2025-05-23      TOTAL     LTN 2025-07-01       100000  BRSTNCLTN7Z6   
1       2025-05-23      TOTAL     LFT 2025-09-01       210100  BRSTNCLF1RD2   
2       2025-05-23      TOTAL     LTN 2025-10-01       100000  BRSTNCLTN863   
3       2025-05-23      TOTAL     LTN 2026-01-01       100000  BRSTNCLTN7U7   
4       2025-05-23      TOTAL     LFT 2026-03-01       210100  BRSTNCLF1RE0   
...             ...              ...                 ... 

5. 🧾 Portfolio Composition

# 📥 Input
import anbima_data as anb

df_portfolio = anb.get_portfolio_composition(index="IMA-GERAL")
print(df_portfolio)
# 📤 Output
Example:
data_inicio   data_fim     indice       tipo_titulo peso_indice  data_vencimento
0   2025-05-05 2025-05-15  IMA-GERAL         LFT         7.14      2027-03-01
1   2025-05-05 2025-05-15  IMA-GERAL         LFT         7.00      2027-03-01
2   2025-05-05 2025-05-15  IMA-GERAL         LFT         6.09      2027-09-01
3   2025-05-05 2025-05-15  IMA-GERAL         LFT         5.98      2027-09-01
4   2025-05-05 2025-05-15  IMA-GERAL         LFT         4.61      2029-03-01
..         ...        ...        ...         ...          ...             ...

6. 📆 Index Performance Time Series (get_index_performance)

When the output parameter is set to 'dataframe':

# 📥 Input
import anbima_data as anb

df_performance = anb.get_index_performance(
    index="IMA-GERAL",
    start_date="01/01/2024",
    end_date="31/01/2024",
    output="dataframe"
)
print(df_performance)
# 📤 Output
Example:
               variacao_diaria  variacao_mensal  numero_indice  variacao_ult12m  \
2024-05-06            -0.08             0.29        8085.72            10.71   
2024-05-07             0.11             0.40        8094.56            10.83   
2024-05-08            -0.00             0.40        8094.29            10.85   
2024-05-09             0.07             0.47        8100.00            10.96   
2024-05-10            -0.03             0.44        8097.37            10.75   
...                     ...              ...            ...              ...     

When the output parameter is set to 'chart':

# 📥 Input
import anbima_data as anb

df_performance_graph = anb.get_index_performance(
    index = "IMA-GERAL"
    start_date = "06/05/2024" 
    end_date = "23/05/2025"
    output="graph",
    column_name = "variacao_ult12m"
)
print(df_performance_graph)

📤 Output

Output gráfico do get_index_performance


🧭 Disclaimer & Purpose

The purpose of the anbima-data package is purely educational, academic, and informative. It was created to facilitate access to reliable and publicly available financial data for students, researchers, investors, and the general public.

This package does not:

  • Perform financial analysis or forecasting;
  • Provide investment advice;
  • Guarantee the accuracy or completeness of the data;
  • Sell any services or financial products.

All decisions based on the data retrieved using this package are the sole responsibility of the user. Always consult a licensed professional for financial advice.

This package is open-source, free to use, and does not include any monetization or commercial intent.

🧭 Aviso Legal e Propósito

O pacote anbima-data tem caráter puramente educacional, acadêmico e informativo. Foi criado para facilitar o acesso a dados financeiros confiáveis e de domínio público por estudantes, pesquisadores, investidores e o público em geral.

Este pacote não:

  • Realiza análises ou previsões financeiras;
  • Oferece recomendações de investimento;
  • Garante a precisão ou completude dos dados;
  • Comercializa serviços ou produtos financeiros.

Todas as decisões baseadas nos dados obtidos com este pacote são de responsabilidade exclusiva do usuário. Sempre consulte profissionais licenciados para orientações financeiras.

Este pacote é open-source, gratuito e não possui fins comerciais ou de monetização.


⚠️ Aviso sobre os dados públicos utilizados

Este pacote faz uso de dados públicos provenientes de fonte oficial da ANBIMA (fonte: https://www.anbima.com.br/pt_br/pagina-inicial.htm#).

Embora o código esteja licenciado sob os termos da licença MIT e seja de uso livre, os dados acessados podem estar sujeitos a restrições específicas de uso, como proibição de revenda ou redistribuição para fins comerciais.

Recomenda-se consultar os termos de uso das fontes originais antes de utilizar os dados para finalidades além de estudos, projetos acadêmicos ou uso pessoal.

O autor deste pacote não se responsabiliza por qualquer uso inadequado ou indevido das informações acessadas.

⚠️ Notice About Public Data

This package uses publicly available financial data from official sources of ANBIMA (source: https://www.anbima.com.br/pt_br/pagina-inicial.htm#).

While the source code is licensed under the MIT License and is free to use, the data itself may be subject to specific usage restrictions, including limitations on resale or commercial redistribution.

Users are encouraged to review the original providers’ terms of use before using the data for purposes beyond personal, academic, or research use.

The author assumes no responsibility for any improper or unauthorized use of the retrieved data.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anbima_data-0.1.0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anbima_data-0.1.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file anbima_data-0.1.0.tar.gz.

File metadata

  • Download URL: anbima_data-0.1.0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for anbima_data-0.1.0.tar.gz
Algorithm Hash digest
SHA256 17193903ae9db91012dbc2bec69a732174cf1079339e7645eba4b11fcda85446
MD5 c35721d371518322c1198db32564136d
BLAKE2b-256 2b0dfd14c815882d9a760fe07cce37d57cf1b17cc6ceb30d351b5f4fcbd136fd

See more details on using hashes here.

File details

Details for the file anbima_data-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: anbima_data-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for anbima_data-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 576904951ee20207b450dba5a1e07202ff4f045d9cdc10a297a7e3139bca948e
MD5 50c5c70aadc9447f95d302dfdad06959
BLAKE2b-256 670ba05511d6b1ab90f79eedc01bdbe78d49eb1b5a3fc17700496b0eddd6ddee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page