LTN
data(date)
Fetch the LTN Anbima indicative rates for the given reference date.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
date
|
DateScalar
|
The reference date for fetching the data. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: DataFrame with columns "MaturityDate" and "IndicativeRate". |
Examples:
>>> from pyield import ltn
>>> ltn.data("23-08-2024")
ReferenceDate BondType MaturityDate IndicativeRate Price
0 2024-08-23 LTN 2024-10-01 0.104416 989.415342
1 2024-08-23 LTN 2025-01-01 0.107171 964.293046
2 2024-08-23 LTN 2025-04-01 0.110866 938.943013
3 2024-08-23 LTN 2025-07-01 0.113032 913.849158
4 2024-08-23 LTN 2025-10-01 0.114374 887.394285
5 2024-08-23 LTN 2026-01-01 0.114654 863.026594
6 2024-08-23 LTN 2026-04-01 0.114997 840.232741
7 2024-08-23 LTN 2026-07-01 0.115265 818.020491
8 2024-08-23 LTN 2026-10-01 0.115357 795.185488
9 2024-08-23 LTN 2027-07-01 0.115335 733.981131
10 2024-08-23 LTN 2028-01-01 0.115694 693.647778
11 2024-08-23 LTN 2028-07-01 0.116417 655.6398
12 2024-08-23 LTN 2030-01-01 0.117436 554.331151
Source code in pyield/tn/ltn.py
di_spreads(date)
Calculates the DI spread for the LTN based on ANBIMA's indicative rates.
This function fetches the indicative rates for the NTN-F bonds and the DI futures rates and calculates the spread between these rates in basis points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
date
|
DateScalar
|
The reference date for the spread calculation. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: DataFrame with the columns "MaturityDate" and "DISpread" (in bps). |
Examples:
>>> from pyield import ltn
>>> spreads = ltn.di_spreads("22-08-2024")
>>> spreads["DISpread"] = spreads["DISpread"] * 10000 # Convert to bps
>>> spreads
MaturityDate DISpread
0 2024-10-01 -3.06
1 2025-01-01 -9.95
2 2025-04-01 -8.28
3 2025-07-01 -6.1
4 2025-10-01 -2.57
5 2026-01-01 -1.57
6 2026-04-01 -0.86
7 2026-07-01 2.83
8 2026-10-01 4.17
9 2027-07-01 3.72
10 2028-01-01 6.19
11 2028-07-01 8.68
12 2030-01-01 14.96
Source code in pyield/tn/ltn.py
dv01(settlement, maturity, rate)
Calculate the DV01 (Dollar Value of 01) for an LTN in R$.
Represents the price change in R$ for a 1 basis point (0.01%) increase in yield.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
settlement
|
DateScalar
|
The settlement date in 'DD-MM-YYYY' format or a pandas Timestamp. |
required |
maturity
|
DateScalar
|
The maturity date in 'DD-MM-YYYY' format or a pandas Timestamp. |
required |
rate
|
float
|
The discount rate used to calculate the present value of the cash flows, which is the yield to maturity (YTM) of the LTN. |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The DV01 value, representing the price change for a 1 basis point increase in yield. |
Examples:
Source code in pyield/tn/ltn.py
historical_premium(date, maturity)
Calculate the premium of the LTN bond over the DI Future rate for a given date.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
date
|
DateScalar
|
The reference date to fetch the rates. |
required |
maturity
|
DateScalar
|
The maturity date of the LTN bond. |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The premium of the LTN bond over the DI Future rate for the given date. If the data is not available, returns NaN. |
Examples:
>>> from pyield import ltn
>>> ltn.historical_premium("22-08-2024", "01-01-2030")
1.0120718007994287
Source code in pyield/tn/ltn.py
maturities(date)
Fetch the bond maturities available for the given reference date.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
date
|
DateScalar
|
The reference date for fetching the data. |
required |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: A Series of bond maturities available for the reference date. |
Examples:
>>> from pyield import ltn
>>> ltn.maturities("22-08-2024")
0 2024-10-01
1 2025-01-01
2 2025-04-01
3 2025-07-01
4 2025-10-01
5 2026-01-01
6 2026-04-01
7 2026-07-01
8 2026-10-01
9 2027-07-01
10 2028-01-01
11 2028-07-01
12 2030-01-01
dtype: datetime64[ns]
Source code in pyield/tn/ltn.py
premium(ltn_rate, di_rate)
Calculate the premium of the LTN bond over the DI Future rate using provided rates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ltn_rate
|
float
|
The annualized LTN rate. |
required |
di_rate
|
float
|
The annualized DI Future rate. |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The premium of the LTN bond over the DI Future rate. |
Examples:
Reference date: 22-08-2024 LTN rate for 01-01-2030: 0.118746 DI (JAN30) Settlement rate: 0.11725
Source code in pyield/tn/ltn.py
price(settlement, maturity, rate)
Calculate the LTN price using Anbima rules.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
settlement
|
DateScalar
|
The settlement date in 'DD-MM-YYYY' format or a pandas Timestamp. |
required |
maturity
|
DateScalar
|
The maturity date in 'DD-MM-YYYY' format or a pandas Timestamp. |
required |
rate
|
float
|
The discount rate used to calculate the present value of the cash flows, which is the yield to maturity (YTM) of the NTN-F. |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The LTN price using Anbima rules. |
References
- https://www.anbima.com.br/data/files/A0/02/CC/70/8FEFC8104606BDC8B82BA2A8/Metodologias%20ANBIMA%20de%20Precificacao%20Titulos%20Publicos.pdf
Examples: