NTN-B1
CommercialName
Bases: Enum
Commercial Name Enum used to identify the kind of used NTN-B1 in the scope of the calculation (Renda+ or Educa+).
cash_flows(settlement, maturity, commercial_name)
Generate the cash flows for NTN-B1 bonds between the settlement and maturity dates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settlement
|
DateScalar
|
The settlement date (exclusive) to start generating the cash flows. |
required |
maturity
|
DateScalar
|
The maturity date of the bond. |
required |
commercial_name
|
CommercialName
|
The commercial name of the NTN-B1 bond (Renda+ or Educa+). |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: DataFrame with columns "PaymentDate" and "CashFlow". |
Returned columns
- PaymentDate: The payment date of the cash flow
- CashFlow: Cash flow value for the bond
Examples:
>>> from pyield import ntnb1
>>> r_mais = ntnb1.CommercialName.RENDA_MAIS
>>> ntnb1.cash_flows("10-05-2024", "15-12-2060", r_mais)
shape: (240, 2)
┌─────────────┬──────────┐
│ PaymentDate ┆ CashFlow │
│ --- ┆ --- │
│ date ┆ f64 │
╞═════════════╪══════════╡
│ 2041-01-15 ┆ 0.004167 │
│ 2041-02-15 ┆ 0.004167 │
│ 2041-03-15 ┆ 0.004167 │
│ 2041-04-15 ┆ 0.004167 │
│ 2041-05-15 ┆ 0.004167 │
│ … ┆ … │
│ 2060-08-15 ┆ 0.004167 │
│ 2060-09-15 ┆ 0.004167 │
│ 2060-10-15 ┆ 0.004167 │
│ 2060-11-15 ┆ 0.004167 │
│ 2060-12-15 ┆ 0.004167 │
└─────────────┴──────────┘
Source code in pyield/tn/ntnb1.py
duration(settlement, maturity, rate, commercial_name)
Calculate the Macaulay duration of the NTN-B bond in business years.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settlement
|
DateScalar
|
The settlement date of the operation. |
required |
maturity
|
DateScalar
|
The maturity date of the NTN-B bond. |
required |
rate
|
float
|
The discount rate used to calculate the duration. |
required |
commercial_name
|
CommercialName
|
The commercial name of the NTN-B1 bond (Renda+ or Educa+). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The Macaulay duration of the NTN-B bond in business years. |
Examples:
>>> from pyield import ntnb1
>>> r_mais = ntnb1.CommercialName.RENDA_MAIS
>>> ntnb1.duration("23-06-2025", "15-12-2084", 0.0686, r_mais)
47.10493458167134
Source code in pyield/tn/ntnb1.py
dv01(settlement, maturity, rate, vna, commercial_name=CommercialName.RENDA_MAIS)
Calculate the DV01 (Dollar Value of 01) for an NTN-B1 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 NTN-B. |
required |
vna
|
float
|
The nominal value of the NTN-B bond. |
required |
commercial_name
|
CommercialName
|
The commercial name of the NTN-B1 bond |
RENDA_MAIS
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The DV01 value, representing the price change for a 1 basis point increase in yield. |
Examples:
>>> from pyield import ntnb1
>>> r_mais = ntnb1.CommercialName.RENDA_MAIS
>>> ntnb1.dv01("23-06-2025", "15-12-2084", 0.0686, 4299.160173, r_mais)
0.7738490000000127
Source code in pyield/tn/ntnb1.py
payment_dates(settlement, maturity, commercial_name)
Generate all remaining amortization dates between a given date and the maturity date. The dates are inclusive. Payments are made from January 15th of the year of conversion to December 15 of maturity year.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settlement
|
DateLike
|
The settlement date (exclusive) to start generating the amortization dates. |
required |
maturity
|
DateLike
|
The maturity date. |
required |
commercial_name
|
CommercialName
|
The commercial name of the NTN-B1 bond (Renda+ or Educa+). |
required |
Returns:
| Type | Description |
|---|---|
Series
|
pl.Series: Series of coupon dates within the specified range. |
Examples:
>>> from pyield import ntnb1
>>> r_mais = ntnb1.CommercialName.RENDA_MAIS
>>> ntnb1.payment_dates("10-05-2024", "15-12-2050", r_mais)
shape: (240,)
Series: 'payment_dates' [date]
[
2031-01-15
2031-02-15
2031-03-15
2031-04-15
2031-05-15
…
2050-08-15
2050-09-15
2050-10-15
2050-11-15
2050-12-15
]
Source code in pyield/tn/ntnb1.py
price(vna, quotation)
Calculate the NTN-B1 price using Brazilian Treasury rules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vna
|
float
|
The nominal value of the NTN-B bond. |
required |
quotation
|
float
|
The NTN-B quotation in base 100. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The NTN-B1 price truncated to 6 decimal places. |
References
- SEI Proccess 17944.005214/2024-09
Examples:
>>> from pyield import ntnb1
>>> ntnb1.price(4299.160173, 99.3651 / 100)
4271.864805
>>> ntnb1.price(4315.498383, 100.6409 / 100)
4343.156412
Source code in pyield/tn/ntnb1.py
quotation(settlement, maturity, rate, commercial_name)
Calculate the NTN-B quotation in base 100 using Anbima rules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settlement
|
DateScalar
|
The settlement date of the operation. |
required |
maturity
|
DateScalar
|
The maturity date of the NTN-B bond. |
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-B. |
required |
commercial_name
|
CommercialName
|
The commercial name of the NTN-B1 bond (Renda+ or Educa+). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The NTN-B quotation truncated to 6 decimal places. |
References
- https://www.anbima.com.br/data/files/A0/02/CC/70/8FEFC8104606BDC8B82BA2A8/Metodologias%20ANBIMA%20de%20Precificacao%20Titulos%20Publicos.pdf
Examples:
>>> from pyield import ntnb1
>>> r_mais = ntnb1.CommercialName.RENDA_MAIS
>>> ntnb1.quotation("18-06-2025", "15-12-2084", 0.07010, r_mais)
0.038332