PRE
di_spreads(date, bps=False)
Calcula o DI Spread para títulos prefixados (LTN e NTN-F) em uma data de referência.
spread = taxa indicativa do PRE - taxa de ajuste do DI
Quando bps=False a coluna retorna essa diferença em formato decimal
(ex: 0.000439 ≈ 4.39 bps). Quando bps=True o valor é automaticamente
multiplicado por 10_000 e exibido diretamente em basis points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
DateScalar
|
Data de referência para buscar as taxas. |
required |
bps
|
bool
|
Se True, retorna DISpread já convertido em basis points. Default False. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pl.DataFrame com colunas: - BondType - MaturityDate - DISpread (decimal ou bps conforme parâmetro) |
Examples:
>>> from pyield import pre
>>> pre.di_spreads("30-05-2025", bps=True)
shape: (18, 3)
┌──────────┬──────────────┬──────────┐
│ BondType ┆ MaturityDate ┆ DISpread │
│ --- ┆ --- ┆ --- │
│ str ┆ date ┆ f64 │
╞══════════╪══════════════╪══════════╡
│ LTN ┆ 2025-07-01 ┆ 4.39 │
│ LTN ┆ 2025-10-01 ┆ -9.0 │
│ LTN ┆ 2026-01-01 ┆ -4.88 │
│ LTN ┆ 2026-04-01 ┆ -4.45 │
│ LTN ┆ 2026-07-01 ┆ 0.81 │
│ … ┆ … ┆ … │
│ NTN-F ┆ 2027-01-01 ┆ -3.31 │
│ NTN-F ┆ 2029-01-01 ┆ 14.21 │
│ NTN-F ┆ 2031-01-01 ┆ 21.61 │
│ NTN-F ┆ 2033-01-01 ┆ 11.51 │
│ NTN-F ┆ 2035-01-01 ┆ 22.0 │
└──────────┴──────────────┴──────────┘
Source code in pyield/tn/pre.py
spot_rates(date)
Create the PRE curve (zero coupon rates) for Brazilian fixed rate bonds.
This function combines LTN rates (which are already zero coupon) with spot rates derived from NTN-F bonds using the bootstrap method.
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", "BDToMat", and "SpotRate". Contains zero coupon rates for all available maturities. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any maturity date cannot be processed or business days cannot be calculated. |
Examples:
>>> from pyield import pre
>>> pre.spot_rates("18-06-2025")
MaturityDate BDToMat SpotRate
0 2025-07-01 8 0.14835
1 2025-10-01 74 0.147463
2 2026-01-01 138 0.147752
3 2026-04-01 199 0.147947
4 2026-07-01 260 0.147069
5 2026-10-01 325 0.144733
6 2027-01-01 387 0.142496
7 2027-04-01 447 0.140924
8 2027-07-01 510 0.139024
9 2028-01-01 638 0.136595
10 2028-07-01 762 0.135664
11 2029-01-01 886 0.136484
12 2030-01-01 1135 0.137279
13 2031-01-01 1387 0.138154
14 2032-01-01 1639 0.13876
15 2033-01-01 1891 0.1393
16 2035-01-01 2390 0.141068