Anbima Data
intraday_ettj()
Retrieves and processes the intraday Brazilian yield curve data from ANBIMA.
This function fetches the most recent intraday yield curve data published by ANBIMA, containing real rates (IPCA-indexed), nominal rates, and implied inflation at various vertices (time points). The curve is published at around 12:30 PM BRT.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pl.DataFrame: A DataFrame containing the intraday ETTJ data. |
DataFrame columns
- date: Reference date of the yield curve
- vertex: Time point in business days
- nominal_rate: Zero-coupon nominal interest rate
- real_rate: Zero-coupon real interest rate (IPCA-indexed)
- implied_inflation: Implied inflation rate (break-even inflation)
Note
All rates are expressed in decimal format (e.g., 0.12 for 12%).
Source code in pyield/anbima/ettj_intraday.py
last_ettj()
Retrieves and processes the latest Brazilian yield curve data from ANBIMA.
This function fetches the most recent yield curve data published by ANBIMA, containing real rates (IPCA-indexed), nominal rates, and implied inflation at various vertices (time points).
Returns:
| Type | Description |
|---|---|
DataFrame
|
pl.DataFrame: A DataFrame containing the latest ETTJ data. |
DataFrame columns
- date: Reference date of the yield curve
- vertex: Time point in business days
- nominal_rate: Zero-coupon nominal interest rate
- real_rate: Zero-coupon real interest rate (IPCA-indexed)
- implied_inflation: Implied inflation rate (break-even inflation)
Note
All rates are expressed in decimal format (e.g., 0.12 for 12%).
Source code in pyield/anbima/ettj_last.py
last_ima(ima_type=None)
Fetch and process the last IMA market data available from ANBIMA.
This function processes the data into a structured DataFrame. It handles conversion of date formats, renames columns to English, and converts certain numeric columns to integer types. In the event of an error during data fetching or processing, an empty DataFrame is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ima_type
|
str
|
Type of IMA index to filter the data. If None, all IMA indexes are returned. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pl.DataFrame: A DataFrame containing the IMA data. |
DataFrame columns
- Date: reference date of the data.
- IMAType: type of IMA index.
- BondType: type of bond.
- Maturity: bond maturity date.
- SelicCode: bond code in the SELIC system.
- ISIN: international Securities Identification Number.
- BDToMat: business days to maturity.
- Duration: duration of the bond in business years (252 days/year).
- IndicativeRate: indicative rate.
- Price: bond price.
- InterestPrice: interest price.
- DV01: DV01 in R$.
- PMR: average repurchase term.
- Weight: weight of the bond in the index.
- Convexity: convexity of the bond.
- TheoreticalQuantity: theoretical quantity.
- NumberOfOperations: number of operations.
- NegotiatedQuantity: negotiated quantity.
- NegotiatedValue: negotiated value.
- MarketQuantity: market quantity.
- MarketDV01: market DV01 in R$.
- MarketValue: market value in R$.
Raises:
| Type | Description |
|---|---|
Exception
|
Logs error and returns an empty DataFrame if any error occurs during fetching or processing. |
Source code in pyield/anbima/ima.py
tpf_data(date, bond_type=None, fetch_from_source=False)
Recupera os dados do mercado secundário de TPF da ANBIMA.
Esta função busca taxas indicativas e outros dados de títulos públicos brasileiros. A obtenção dos dados segue uma hierarquia de fontes para otimizar o desempenho e o acesso.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
DateScalar
|
A data de referência para os dados (ex: '2024-06-14'). |
required |
bond_type
|
str
|
Filtra os resultados por um tipo de título específico (ex: 'LTN', 'NTN-B'). Por padrão, retorna todos os tipos. |
None
|
fetch_from_source
|
bool
|
Se True, força a função a ignorar o cache e buscar os dados diretamente da fonte (ANBIMA). Padrão é False. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pl.DataFrame: Um DataFrame contendo os dados solicitados. Retorna um DataFrame vazio se não houver dados para a data especificada (ex: finais de semana, feriados ou datas futuras). |
Examples:
>>> from pyield import anbima
>>> anbima.tpf_data(date="22-08-2025")
shape: (49, 14)
┌───────────────┬──────────┬───────────┬───────────────┬───┬───────────┬───────────┬────────────────┬──────────┐
│ ReferenceDate ┆ BondType ┆ SelicCode ┆ IssueBaseDate ┆ … ┆ BidRate ┆ AskRate ┆ IndicativeRate ┆ DIRate │
│ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │
│ date ┆ str ┆ i64 ┆ date ┆ ┆ f64 ┆ f64 ┆ f64 ┆ f64 │
╞═══════════════╪══════════╪═══════════╪═══════════════╪═══╪═══════════╪═══════════╪════════════════╪══════════╡
│ 2025-08-22 ┆ LFT ┆ 210100 ┆ 2000-07-01 ┆ … ┆ 0.000198 ┆ 0.0001 ┆ 0.000165 ┆ 0.14906 │
│ 2025-08-22 ┆ LFT ┆ 210100 ┆ 2000-07-01 ┆ … ┆ -0.000053 ┆ -0.000156 ┆ -0.000116 ┆ 0.14843 │
│ 2025-08-22 ┆ LFT ┆ 210100 ┆ 2000-07-01 ┆ … ┆ -0.000053 ┆ -0.000143 ┆ -0.000107 ┆ 0.1436 │
│ 2025-08-22 ┆ LFT ┆ 210100 ┆ 2000-07-01 ┆ … ┆ 0.000309 ┆ 0.000292 ┆ 0.000302 ┆ 0.138189 │
│ 2025-08-22 ┆ LFT ┆ 210100 ┆ 2000-07-01 ┆ … ┆ 0.000421 ┆ 0.000399 ┆ 0.000411 ┆ 0.134548 │
│ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │
│ 2025-08-22 ┆ NTN-F ┆ 950199 ┆ 2016-01-15 ┆ … ┆ 0.139379 ┆ 0.139163 ┆ 0.139268 ┆ 0.13959 │
│ 2025-08-22 ┆ NTN-F ┆ 950199 ┆ 2018-01-05 ┆ … ┆ 0.134252 ┆ 0.134018 ┆ 0.13414 ┆ 0.1327 │
│ 2025-08-22 ┆ NTN-F ┆ 950199 ┆ 2020-01-10 ┆ … ┆ 0.13846 ┆ 0.138355 ┆ 0.13841 ┆ 0.13626 │
│ 2025-08-22 ┆ NTN-F ┆ 950199 ┆ 2022-01-07 ┆ … ┆ 0.139503 ┆ 0.139321 ┆ 0.139398 ┆ 0.13807 │
│ 2025-08-22 ┆ NTN-F ┆ 950199 ┆ 2024-01-05 ┆ … ┆ 0.140673 ┆ 0.140566 ┆ 0.140633 ┆ 0.13845 │
└───────────────┴──────────┴───────────┴───────────────┴───┴───────────┴───────────┴────────────────┴──────────┘
Data columns
- BondType: Tipo do título público (e.g., 'LTN', 'NTN-B').
- ReferenceDate: Data de referência dos dados.
- SelicCode: Código do título no SELIC.
- IssueBaseDate: Data base ou de emissão do título.
- MaturityDate: Data de vencimento do título.
- BDToMat: Número de dias úteis entre a data de referência e o vencimento.
- Duration: Macaulay Duration do título em anos.
- DV01: Variação financeira no preço do título (em BRL) para uma mudança de 1 basis point (0,01%) na taxa de juros.
- DV01USD: O mesmo que DV01, mas convertido para USD pela PTAX do dia.
- Price: Preço Unitário (PU) do título na data de referência.
- BidRate: Taxa de compra em formato decimal (e.g., 0.10 para 10%).
- AskRate: Taxa de venda em formato decimal.
- IndicativeRate: Taxa indicativa em formato decimal.
- DIRate: Taxa DI interpolada (flatforward) no vencimento do título.
- StdDev: Desvio padrão da taxa indicativa.
- LowerBoundRateD0: Limite inferior do intervalo indicativo para D+0.
- UpperBoundRateD0: Limite superior do intervalo indicativo para D+0.
- LowerBoundRateD1: Limite inferior do intervalo indicativo para D+1.
- UpperBoundRateD1: Limite superior do intervalo indicativo para D+1.
- Criteria: Critério utilizado pela ANBIMA para o cálculo.
Notes
A fonte dos dados segue a seguinte hierarquia:
- Cache Local (Padrão): Fornece acesso rápido a dados históricos
desde 01/01/2020. É utilizado por padrão (
fetch_from_source=False). - Site Público da ANBIMA: Acessado quando
fetch_from_source=True, disponibiliza os dados dos últimos 5 dias úteis. - Rede RTM da ANBIMA: Acessada quando
fetch_from_source=Truepara datas com mais de 5 dias úteis. O acesso ao histórico completo requer uma conexão à rede RTM. Sem ela, a consulta para datas antigas retornará um DataFrame vazio.
Source code in pyield/anbima/tpf.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
tpf_difusao(data_referencia)
Obtém a TPF Difusão da Anbima para uma data de referência específica.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_referencia
|
str | date | datetime
|
Data de referência (ex: "DD/MM/AAAA"). |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pl.DataFrame: DataFrame com os dados. Retorna um DataFrame vazio se não houver dados ou em caso de erro. |
Output Columns
- data_hora_referencia (datetime): Data e hora de referência da taxa.
- provedor (string): Provedor dos dados.
- titulo (string): Nome do título (ex: LFT, LTN).
- data_vencimento (date): Data de vencimento do título.
- codigo_isin (string): Código ISIN do título.
- dias_uteis (int): Dias úteis entre a data de referência e o vencimento.
- taxa_indicativa_anterior (float): Taxa indicativa de fechamento D-1 (decimal).
- taxa_venda (float): Taxa de oferta de venda (Ask rate) (decimal).
- taxa_compra (float): Taxa de oferta de compra (Bid rate) (decimal).
- taxa_media (float): Média entre a taxa de compra e venda (decimal).
- taxa_ultima (float): Última taxa negociada (decimal).
Source code in pyield/anbima/difusao.py
tpf_maturities(date, bond_type)
Retrieve existing maturity dates for a given bond type on a specific date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
DateScalar
|
The reference date for maturity dates. |
required |
bond_type
|
str
|
The bond type to filter by (e.g., 'PRE' for both 'LTN' and 'NTN-F', or specify 'LTN' or 'NTN-F' directly). |
required |
Returns:
| Type | Description |
|---|---|
Series
|
pl.Series: A Series containing unique maturity dates for the specified bond type(s). |
Examples:
>>> from pyield import anbima
>>> anbima.tpf_maturities(date="22-08-2025", bond_type="PRE")
shape: (18,)
Series: 'MaturityDate' [date]
[
2025-10-01
2026-01-01
2026-04-01
2026-07-01
2026-10-01
…
2030-01-01
2031-01-01
2032-01-01
2033-01-01
2035-01-01
]