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
|
pd.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.py
ipca_projection()
Retrieves the current IPCA projection from the ANBIMA website.
This function makes an HTTP request to the ANBIMA website, extracts HTML tables containing economic indicators, and specifically processes the IPCA projection data.
Process
- Accesses the ANBIMA indicators webpage
- Extracts the third table that contains the IPCA projection
- Locates the row labeled as "IPCA1"
- Extracts the projection value and converts it to decimal format
- Extracts and formats the reference month of the projection
- Extracts the date and time of the last update
Returns:
Name | Type | Description |
---|---|---|
IndicatorProjection |
IndicatorProjection
|
An object containing: - reference_period (pd.Period): Reference period of the projection - projected_value (float): Projected IPCA value as a decimal number - last_updated (pd.Timestamp): Date and time of the last data update |
Raises:
Type | Description |
---|---|
RequestException
|
If there are connection issues with the ANBIMA site |
ValueError
|
If the expected data is not found in the page structure |
Error
|
If the 'pt_BR.UTF-8' locale is not available on the system |
Notes
- The function requires internet connection to access the ANBIMA website
- The structure of the ANBIMA page may change, which could affect the function
- Temporarily changes the locale to pt_BR.UTF-8 to process dates in Portuguese
Source code in pyield/anbima/ipca.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
|
pd.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.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
|
pd.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)
Retrieve TPF secondary market data from ANBIMA.
This function fetches indicative rates and other data for Brazilian government
bonds from ANBIMA. By default, it attempts to retrieve data from a local
cache for performance. If fetch_from_source
is True, it tries to fetch the data
directly from the ANBIMA website.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
date
|
DateScalar
|
The reference date for the data (e.g., '2024-06-14'). |
required |
bond_type
|
str
|
Filters results by a specific bond type (e.g., 'LTN', 'NTN-B'). Defaults to None, returning all bond types. |
None
|
fetch_from_source
|
bool
|
If True, forces the function to bypass the cache and fetch data directly from the source. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: A DataFrame containing the requested bond data. An empty |
DataFrame
|
DataFrame is returned if no data is available for the specified date |
DataFrame
|
(e.g., weekends, holidays, or future dates). |
Examples:
>>> from pyield import anbima
>>> anbima.tpf_data(date="22-08-2025")
ReferenceDate BondType MaturityDate IndicativeRate Price
0 2025-08-22 LFT 2025-09-01 0.000165 17200.957952
1 2025-08-22 LFT 2026-03-01 -0.000116 17202.058818
2 2025-08-22 LFT 2026-09-01 -0.000107 17202.901668
3 2025-08-22 LFT 2027-03-01 0.000302 17193.200289
4 2025-08-22 LFT 2027-09-01 0.000411 17186.767105
...
DataFrame 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 para o 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
- Data for the last 5 business days is available on the public ANBIMA website.
- Historical data (older than 5 business days) is only available via the RTM network. If you are not connected to RTM, requests for older dates will return an empty DataFrame.
Source code in pyield/anbima/tpf.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 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 |
|
tpf_fixed_rate_maturities(date)
Retrieve pre-defined maturity dates for LTN and NTN-F bonds.
This function fetches pre-defined maturity dates for 'LTN' (prefixadas) and 'NTN-F' (indexadas ao CDI) bond types from the cached ANBIMA dataset for a given reference date.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
date
|
DateScalar
|
The reference date for maturity dates. |
required |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: A Series containing unique maturity dates for 'LTN' and 'NTN-F' bonds, sorted in ascending order. |