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, adj_maturities=False)
Retrieve indicative rates for bonds from ANBIMA data.
This function fetches indicative rates for bonds from ANBIMA, initially attempting to retrieve data from a cached dataset. If the data is not available in the cache, it fetches it directly from the ANBIMA website.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
date
|
DateScalar
|
The reference date for the rates. |
required |
bond_type
|
str
|
Filter rates by bond type. Defaults to None, which returns rates for all bond types. |
None
|
adj_maturities
|
bool
|
Adjust maturity dates to the next business day. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: A DataFrame with the following columns: - BondType: The type of bond. - MaturityDate: The maturity date of the bond. - IndicativeRate: The indicative rate of the bond. - Price: The price (PU) of the bond. |
Source code in pyield/anbima/tpf.py
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. |
Source code in pyield/anbima/tpf.py
tpf_web_data(date, bond_type=None)
Fetch and process TPF secondary market data directly from the ANBIMA website. Only the last 5 days of data are available in the ANBIMA website.
This function retrieves bond market data from the ANBIMA website for a specified reference date. It handles different file formats based on the date and attempts to download the data from both member and non-member URLs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
date
|
DateScalar
|
The reference date for the data. |
required |
bond_type
|
str
|
Filter data by bond type. Defaults to None, which returns data for all bond types. |
None
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: A DataFrame containing bond market data. Returns an empty DataFrame if data is not available for the specified date (weekends, holidays, or unavailable data). |