PYield


NamePYield JSON
Version 0.40.5 PyPI version JSON
download
home_pageNone
SummaryA Python library for analysis of fixed income instruments in Brazil
upload_time2025-10-29 22:53:05
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseMIT License Copyright (c) 2023 Carlos Carvalho Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords fixed-income brazil finance analysis bonds
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI version](https://img.shields.io/pypi/v/pyield.svg)](https://pypi.python.org/pypi/pyield)
[![Made with Python](https://img.shields.io/badge/Python->=3.12-blue?logo=python&logoColor=white)](https://python.org "Go to Python homepage")
[![License](https://img.shields.io/badge/License-MIT-blue)](https://github.com/crdcj/PYield/blob/main/LICENSE)

# PYield: Brazilian Fixed Income Toolkit

PYield is a Python library designed for the analysis of Brazilian fixed income instruments. Leveraging the power of popular Python libraries like Polars, Pandas, Numpy and Requests, PYield simplifies the process of obtaining and processing data from key sources such as ANBIMA, BCB, IBGE and B3.

---
### ✅ Polars migration from version 0.40.0 onwards:

All public functions now return **Polars DataFrames or Series** as the canonical format. This provides stronger typing, faster execution and more reliable date/rate handling. The last version to return Pandas objects by default was **0.39.xx**.

Need Pandas? Convert explicitly:
```python
df_pandas = df.to_pandas(use_pyarrow_extension_array=True)
series_pandas = s.to_pandas(use_pyarrow_extension_array=True)
```
The internal typing relies on PyArrow-backed dtypes for consistency across numeric and date operations.

## Documentation

Visit the [full documentation for PYield](https://crdcj.github.io/PYield/).

## Key Features

- **Data Collection**: Automated fetching of data from ANBIMA and B3.
- **Data Processing**: Efficient processing and normalization of fixed income data.
- **Analysis Tools**: Built-in functions for common analysis tasks in fixed income markets.
- **Easy Integration**: Seamless integration with pandas data analysis workflows.
- **Type Hints**: Full support for static type checking, enhancing development experience and code quality.

## Installation

You can install PYield using pip:
```sh
pip install pyield
```
## Custom Types

### DateScalar
`DateScalar` and `DateArray` are internal type unions used across PYield to accept flexible date inputs. Supported scalar Python / library date types:

- `str` (formats: `DD-MM-YYYY`, `DD/MM/YYYY`, `YYYY-MM-DD`)
- `datetime.date`
- `datetime.datetime`
- `pandas.Timestamp`
- `numpy.datetime64`

### DateArray
Accepted collection types (homogeneous date-like values):

- `list[DateScalar]`
- `tuple[DateScalar, ...]`
- `pandas.Series`
- `pandas.DatetimeIndex`
- `numpy.ndarray`
- `polars.Series`

Other helper unions:

`FloatArray`:
- `list[float]` | `tuple[float, ...]` | `numpy.ndarray` | `pandas.Series` | `polars.Series`

`IntegerScalar`:
- `int` | `numpy.integer`

`IntegerArray`:
- `list[int]` | `tuple[int, ...]` | `numpy.ndarray` | `pandas.Series` | `polars.Series`

Referencing these unions in function docstrings means you can pass any of the listed types interchangeably; conversion is handled internally.

### Date String Formats
Accepted string date formats:

- Day-first (Brazilian): `DD-MM-YYYY` (e.g., `31-05-2024`)
- Day-first (slash): `DD/MM/YYYY` (e.g., `31/05/2024`)
- ISO: `YYYY-MM-DD` (e.g., `2024-05-31`)

Rules:
- No ambiguous autodetection: `2024-05-06` is always interpreted as ISO (`YYYY-MM-DD`).
- A collection of strings must not mix different styles; the first non-null value defines the format.
- Nulls are preserved; empty collections are not allowed.

Recommendation:
Always parse external inputs explicitly when constructing your own pipelines:
```python
import pandas as pd
dt_val = pd.to_datetime("31-05-2024", format="%d-%m-%Y")
iso_val = pd.to_datetime("2024-05-31", format="%Y-%m-%d")
```

### Null & Empty Input Handling

PYield uses an internal helper (`has_null_args`) for early detection of missing inputs. The default propagation policy is: return **`None`** for missing scalar inputs and preserve nulls inside collections. This avoids implicit imputation and makes failure modes explicit.

Summary:
- Scalar functions (dates, prices, quotations, spreads, durations): return `None` when any required argument is missing or empty.
- Collection (vectorized) functions: if the entire relevant input is missing/empty, return an empty Polars `DataFrame`/`Series` (or `None` for purely scalar semantics). Individual null elements propagate as `null` values in the resulting Polars Series/DataFrame.
- Empty collections where a shape is mandatory (e.g. an empty date array for conversion) raise `ValueError` rather than returning a silently empty result.
- Date string collections must share a single format; the first non-null defines it.
- Numeric computations only produce `NaN` when an internal arithmetic step yields an undefined value (rare — typical missing input short-circuits to `None`).

Examples:
```python
>>> from pyield import ntnb, bday
# Missing settlement -> None
>>> ntnb.quotation(None, "15-05-2035", 0.06149)
None

# Null start date in business day count -> None
>>> bday.count(None, "01-01-2025")
None

# Null in array input propagates element-wise
>>> bday.count(["01-01-2024", None], "01-02-2024")
shape: (2,)
Series: 'bdays' [i64]
[
    22
    null
]
```
## How to use PYield
### Brazilian Treasury Bonds Tools
```python
>>> from pyield import ltn, ntnb, ntnf

# Get ANBIMA LTN data for a given date
>>> ltn.data("23-08-2024")
shape: (13, 14)
┌──────────────┬─────────┬──────────┬──────────────┬───┬─────────┬─────────┬───────────────┬────────┐
│ ReferenceDate│ BondType│ SelicCode│ IssueBaseDate│ … │ BidRate │ AskRate │ IndicativeRate│ DIRate │
│ ---          │ ---     │ ---      │ ---          │   │ ---     │ ---     │ ---           │ ---    │
│ date         │ str     │ i64      │ date         │   │ f64     │ f64     │ f64           │ f64    │
├──────────────┼─────────┼──────────┼──────────────┼───┼─────────┼─────────┼───────────────┼────────┤
│ 2024-08-23   │ LTN     │ 100000   │ 2022-07-08   │ … │ 0.10459 │ 0.104252│ 0.104416      │ 0.10472│
│ 2024-08-23   │ LTN     │ 100000   │ 2018-02-01   │ … │ 0.107366│ 0.107016│ 0.107171      │ 0.10823│
│ 2024-08-23   │ LTN     │ 100000   │ 2023-01-06   │ … │ 0.110992│ 0.110746│ 0.110866      │ 0.11179│
│ …            │ …       │ …        │ …            │ … │ …       │ …       │ …             │ …      │
└──────────────┴─────────┴──────────┴──────────────┴───┴─────────┴─────────┴───────────────┴────────┘

# Calculate the quotation of an NTN-B bond (base 100, truncated to 4 decimals)
>>> ntnb.quotation("31-05-2024", "15-05-2035", 0.061490)
99.3651
>>> ntnb.quotation("31-05-2024", "15-08-2060", 0.061878)
99.5341

# DI Spreads: IndicativeRate - SettlementRate (bps=True multiplies by 10_000)
>>> ntnf.di_spreads("30-05-2025", bps=True)
shape: (5, 3)
┌─────────┬─────────────┬──────────┐
│ BondType│ MaturityDate│ DISpread │
│ ---     │ ---         │ ---      │
│ str     │ date        │ f64      │
├─────────┼─────────────┼──────────┤
│ 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     │
└─────────┴─────────────┴──────────┘
```

### Business Days Tools (Brazilian holidays automatically considered)
```python
>>> from pyield import bday
# Count business days (start inclusive, end exclusive)
>>> bday.count("29-12-2023", "02-01-2024")
1

# Next business day after given date (offset=1)
>>> bday.offset("29-12-2023", 1)
datetime.date(2024, 1, 2)

# Adjust to next business day when not a business day (offset=0)
>>> bday.offset("30-12-2023", 0)
datetime.date(2024, 1, 2)

# Returns same date if already business day (offset=0)
>>> bday.offset("29-12-2023", 0)
datetime.date(2023, 12, 29)

# Generate business day series
>>> bday.generate(start="22-12-2023", end="02-01-2024")
shape: (6,)
Series: '' [date]
[
    2023-12-22
    2023-12-26
    2023-12-27
    2023-12-28
    2023-12-29
    2024-01-02
]
```

### Futures Data
```python
>>> from pyield.b3.futures import futures

# Fetch DI1 futures (historical)
>>> futures("DI1", "31-05-2024")
shape: (40, 20)
┌────────────┬──────────────┬───────────────┬────────────┬───┬──────────────┬──────────┬───────────────┬─────────────┐
│ TradeDate  ┆ TickerSymbol ┆ ExpirationDate┆ BDaysToExp ┆ … ┆ CloseBidRate ┆ CloseRate┆ SettlementRate┆ ForwardRate │
│ ---        ┆ ---          ┆ ---           ┆ ---        ┆   ┆ ---          ┆ ---      ┆ ---           ┆ ---         │
│ date       ┆ str          ┆ date          ┆ i64        ┆   ┆ f64          ┆ f64      ┆ f64           ┆ f64         │
├────────────┼──────────────┼───────────────┼────────────┼───┼──────────────┼──────────┼───────────────┼─────────────┤
│ 2024-05-31 ┆ DI1M24       ┆ 2024-06-03    ┆ 1          ┆ … ┆ 0.10404      ┆ 0.10404  ┆ 0.10399       ┆ 0.10399     │
│ 2024-05-31 ┆ DI1N24       ┆ 2024-07-01    ┆ 21         ┆ … ┆ 0.1039       ┆ 0.10386  ┆ 0.1039        ┆ 0.103896    │
│ 2024-05-31 ┆ DI1Q24       ┆ 2024-08-01    ┆ 44         ┆ … ┆ 0.10374      ┆ 0.10374  ┆ 0.1037        ┆ 0.103517    │
│ …          ┆ …            ┆ …             ┆ …          ┆ … ┆ …            ┆ …        ┆ …             ┆ …           │
└────────────┴──────────────┴───────────────┴────────────┴───┴──────────────┴──────────┴───────────────┴─────────────┘
```

### Indicators Data
```python
>>> from pyield import bc

# SELIC Over series (no data on Sunday)
>>> bc.selic_over_series("26-01-2025").head(5)
shape: (5, 2)
┌────────────┬────────┐
│ Date       ┆ Value  │
│ ---        ┆ ---    │
│ date       ┆ f64    │
├────────────┼────────┤
│ 2025-01-27 ┆ 0.1215 │
│ 2025-01-28 ┆ 0.1215 │
│ 2025-01-29 ┆ 0.1215 │
│ 2025-01-30 ┆ 0.1315 │
│ 2025-01-31 ┆ 0.1315 │
└────────────┴────────┘

# SELIC Over for a single date
>>> bc.selic_over("31-05-2024")
0.104  # 10.40%
```

### Projections Data
```python
>>> from pyield import ipca
# Fetch current month projection for IPCA
>>> proj = ipca.projected_rate()
>>> proj
IndicatorProjection(last_updated=..., reference_period=..., projected_value=...)
>>> proj.projected_value
0.0035  # 0.35%
```

### Interpolation Tools
Interpolate interest rates for specific business days using the Interpolator class.
```python
>>> from pyield import Interpolator
# Initialize the Interpolator with known business days and interest rates.
>>> known_bdays = [30, 60, 90]
>>> known_rates = [0.045, 0.05, 0.055]
>>> linear_interpolator = Interpolator("linear", known_bdays, known_rates)
>>> linear_interpolator(45)  # Interpolate the interest rate for a given number of business days.
0.0475

# Use the flat forward method for interpolation.
>>> ff_interpolator = Interpolator("flat_forward", known_bdays, known_rates)
>>> ff_interpolator(45)
0.04833068080970859
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "PYield",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "fixed-income, brazil, finance, analysis, bonds",
    "author": null,
    "author_email": "Carlos Carvalho <cr.cj@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/43/9e/98c284541ff3bece9a9ce66796cc078ef624fc8e7d86457181c11e84359b/pyield-0.40.5.tar.gz",
    "platform": null,
    "description": "[![PyPI version](https://img.shields.io/pypi/v/pyield.svg)](https://pypi.python.org/pypi/pyield)\n[![Made with Python](https://img.shields.io/badge/Python->=3.12-blue?logo=python&logoColor=white)](https://python.org \"Go to Python homepage\")\n[![License](https://img.shields.io/badge/License-MIT-blue)](https://github.com/crdcj/PYield/blob/main/LICENSE)\n\n# PYield: Brazilian Fixed Income Toolkit\n\nPYield is a Python library designed for the analysis of Brazilian fixed income instruments. Leveraging the power of popular Python libraries like Polars, Pandas, Numpy and Requests, PYield simplifies the process of obtaining and processing data from key sources such as ANBIMA, BCB, IBGE and B3.\n\n---\n### \u2705 Polars migration from version 0.40.0 onwards:\n\nAll public functions now return **Polars DataFrames or Series** as the canonical format. This provides stronger typing, faster execution and more reliable date/rate handling. The last version to return Pandas objects by default was **0.39.xx**.\n\nNeed Pandas? Convert explicitly:\n```python\ndf_pandas = df.to_pandas(use_pyarrow_extension_array=True)\nseries_pandas = s.to_pandas(use_pyarrow_extension_array=True)\n```\nThe internal typing relies on PyArrow-backed dtypes for consistency across numeric and date operations.\n\n## Documentation\n\nVisit the [full documentation for PYield](https://crdcj.github.io/PYield/).\n\n## Key Features\n\n- **Data Collection**: Automated fetching of data from ANBIMA and B3.\n- **Data Processing**: Efficient processing and normalization of fixed income data.\n- **Analysis Tools**: Built-in functions for common analysis tasks in fixed income markets.\n- **Easy Integration**: Seamless integration with pandas data analysis workflows.\n- **Type Hints**: Full support for static type checking, enhancing development experience and code quality.\n\n## Installation\n\nYou can install PYield using pip:\n```sh\npip install pyield\n```\n## Custom Types\n\n### DateScalar\n`DateScalar` and `DateArray` are internal type unions used across PYield to accept flexible date inputs. Supported scalar Python / library date types:\n\n- `str` (formats: `DD-MM-YYYY`, `DD/MM/YYYY`, `YYYY-MM-DD`)\n- `datetime.date`\n- `datetime.datetime`\n- `pandas.Timestamp`\n- `numpy.datetime64`\n\n### DateArray\nAccepted collection types (homogeneous date-like values):\n\n- `list[DateScalar]`\n- `tuple[DateScalar, ...]`\n- `pandas.Series`\n- `pandas.DatetimeIndex`\n- `numpy.ndarray`\n- `polars.Series`\n\nOther helper unions:\n\n`FloatArray`:\n- `list[float]` | `tuple[float, ...]` | `numpy.ndarray` | `pandas.Series` | `polars.Series`\n\n`IntegerScalar`:\n- `int` | `numpy.integer`\n\n`IntegerArray`:\n- `list[int]` | `tuple[int, ...]` | `numpy.ndarray` | `pandas.Series` | `polars.Series`\n\nReferencing these unions in function docstrings means you can pass any of the listed types interchangeably; conversion is handled internally.\n\n### Date String Formats\nAccepted string date formats:\n\n- Day-first (Brazilian): `DD-MM-YYYY` (e.g., `31-05-2024`)\n- Day-first (slash): `DD/MM/YYYY` (e.g., `31/05/2024`)\n- ISO: `YYYY-MM-DD` (e.g., `2024-05-31`)\n\nRules:\n- No ambiguous autodetection: `2024-05-06` is always interpreted as ISO (`YYYY-MM-DD`).\n- A collection of strings must not mix different styles; the first non-null value defines the format.\n- Nulls are preserved; empty collections are not allowed.\n\nRecommendation:\nAlways parse external inputs explicitly when constructing your own pipelines:\n```python\nimport pandas as pd\ndt_val = pd.to_datetime(\"31-05-2024\", format=\"%d-%m-%Y\")\niso_val = pd.to_datetime(\"2024-05-31\", format=\"%Y-%m-%d\")\n```\n\n### Null & Empty Input Handling\n\nPYield uses an internal helper (`has_null_args`) for early detection of missing inputs. The default propagation policy is: return **`None`** for missing scalar inputs and preserve nulls inside collections. This avoids implicit imputation and makes failure modes explicit.\n\nSummary:\n- Scalar functions (dates, prices, quotations, spreads, durations): return `None` when any required argument is missing or empty.\n- Collection (vectorized) functions: if the entire relevant input is missing/empty, return an empty Polars `DataFrame`/`Series` (or `None` for purely scalar semantics). Individual null elements propagate as `null` values in the resulting Polars Series/DataFrame.\n- Empty collections where a shape is mandatory (e.g. an empty date array for conversion) raise `ValueError` rather than returning a silently empty result.\n- Date string collections must share a single format; the first non-null defines it.\n- Numeric computations only produce `NaN` when an internal arithmetic step yields an undefined value (rare \u2014 typical missing input short-circuits to `None`).\n\nExamples:\n```python\n>>> from pyield import ntnb, bday\n# Missing settlement -> None\n>>> ntnb.quotation(None, \"15-05-2035\", 0.06149)\nNone\n\n# Null start date in business day count -> None\n>>> bday.count(None, \"01-01-2025\")\nNone\n\n# Null in array input propagates element-wise\n>>> bday.count([\"01-01-2024\", None], \"01-02-2024\")\nshape: (2,)\nSeries: 'bdays' [i64]\n[\n    22\n    null\n]\n```\n## How to use PYield\n### Brazilian Treasury Bonds Tools\n```python\n>>> from pyield import ltn, ntnb, ntnf\n\n# Get ANBIMA LTN data for a given date\n>>> ltn.data(\"23-08-2024\")\nshape: (13, 14)\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 ReferenceDate\u2502 BondType\u2502 SelicCode\u2502 IssueBaseDate\u2502 \u2026 \u2502 BidRate \u2502 AskRate \u2502 IndicativeRate\u2502 DIRate \u2502\n\u2502 ---          \u2502 ---     \u2502 ---      \u2502 ---          \u2502   \u2502 ---     \u2502 ---     \u2502 ---           \u2502 ---    \u2502\n\u2502 date         \u2502 str     \u2502 i64      \u2502 date         \u2502   \u2502 f64     \u2502 f64     \u2502 f64           \u2502 f64    \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 2024-08-23   \u2502 LTN     \u2502 100000   \u2502 2022-07-08   \u2502 \u2026 \u2502 0.10459 \u2502 0.104252\u2502 0.104416      \u2502 0.10472\u2502\n\u2502 2024-08-23   \u2502 LTN     \u2502 100000   \u2502 2018-02-01   \u2502 \u2026 \u2502 0.107366\u2502 0.107016\u2502 0.107171      \u2502 0.10823\u2502\n\u2502 2024-08-23   \u2502 LTN     \u2502 100000   \u2502 2023-01-06   \u2502 \u2026 \u2502 0.110992\u2502 0.110746\u2502 0.110866      \u2502 0.11179\u2502\n\u2502 \u2026            \u2502 \u2026       \u2502 \u2026        \u2502 \u2026            \u2502 \u2026 \u2502 \u2026       \u2502 \u2026       \u2502 \u2026             \u2502 \u2026      \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\n# Calculate the quotation of an NTN-B bond (base 100, truncated to 4 decimals)\n>>> ntnb.quotation(\"31-05-2024\", \"15-05-2035\", 0.061490)\n99.3651\n>>> ntnb.quotation(\"31-05-2024\", \"15-08-2060\", 0.061878)\n99.5341\n\n# DI Spreads: IndicativeRate - SettlementRate (bps=True multiplies by 10_000)\n>>> ntnf.di_spreads(\"30-05-2025\", bps=True)\nshape: (5, 3)\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 BondType\u2502 MaturityDate\u2502 DISpread \u2502\n\u2502 ---     \u2502 ---         \u2502 ---      \u2502\n\u2502 str     \u2502 date        \u2502 f64      \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 NTN-F   \u2502 2027-01-01  \u2502 -3.31    \u2502\n\u2502 NTN-F   \u2502 2029-01-01  \u2502 14.21    \u2502\n\u2502 NTN-F   \u2502 2031-01-01  \u2502 21.61    \u2502\n\u2502 NTN-F   \u2502 2033-01-01  \u2502 11.51    \u2502\n\u2502 NTN-F   \u2502 2035-01-01  \u2502 22.0     \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\n### Business Days Tools (Brazilian holidays automatically considered)\n```python\n>>> from pyield import bday\n# Count business days (start inclusive, end exclusive)\n>>> bday.count(\"29-12-2023\", \"02-01-2024\")\n1\n\n# Next business day after given date (offset=1)\n>>> bday.offset(\"29-12-2023\", 1)\ndatetime.date(2024, 1, 2)\n\n# Adjust to next business day when not a business day (offset=0)\n>>> bday.offset(\"30-12-2023\", 0)\ndatetime.date(2024, 1, 2)\n\n# Returns same date if already business day (offset=0)\n>>> bday.offset(\"29-12-2023\", 0)\ndatetime.date(2023, 12, 29)\n\n# Generate business day series\n>>> bday.generate(start=\"22-12-2023\", end=\"02-01-2024\")\nshape: (6,)\nSeries: '' [date]\n[\n    2023-12-22\n    2023-12-26\n    2023-12-27\n    2023-12-28\n    2023-12-29\n    2024-01-02\n]\n```\n\n### Futures Data\n```python\n>>> from pyield.b3.futures import futures\n\n# Fetch DI1 futures (historical)\n>>> futures(\"DI1\", \"31-05-2024\")\nshape: (40, 20)\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 TradeDate  \u2506 TickerSymbol \u2506 ExpirationDate\u2506 BDaysToExp \u2506 \u2026 \u2506 CloseBidRate \u2506 CloseRate\u2506 SettlementRate\u2506 ForwardRate \u2502\n\u2502 ---        \u2506 ---          \u2506 ---           \u2506 ---        \u2506   \u2506 ---          \u2506 ---      \u2506 ---           \u2506 ---         \u2502\n\u2502 date       \u2506 str          \u2506 date          \u2506 i64        \u2506   \u2506 f64          \u2506 f64      \u2506 f64           \u2506 f64         \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 2024-05-31 \u2506 DI1M24       \u2506 2024-06-03    \u2506 1          \u2506 \u2026 \u2506 0.10404      \u2506 0.10404  \u2506 0.10399       \u2506 0.10399     \u2502\n\u2502 2024-05-31 \u2506 DI1N24       \u2506 2024-07-01    \u2506 21         \u2506 \u2026 \u2506 0.1039       \u2506 0.10386  \u2506 0.1039        \u2506 0.103896    \u2502\n\u2502 2024-05-31 \u2506 DI1Q24       \u2506 2024-08-01    \u2506 44         \u2506 \u2026 \u2506 0.10374      \u2506 0.10374  \u2506 0.1037        \u2506 0.103517    \u2502\n\u2502 \u2026          \u2506 \u2026            \u2506 \u2026             \u2506 \u2026          \u2506 \u2026 \u2506 \u2026            \u2506 \u2026        \u2506 \u2026             \u2506 \u2026           \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\n### Indicators Data\n```python\n>>> from pyield import bc\n\n# SELIC Over series (no data on Sunday)\n>>> bc.selic_over_series(\"26-01-2025\").head(5)\nshape: (5, 2)\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 Date       \u2506 Value  \u2502\n\u2502 ---        \u2506 ---    \u2502\n\u2502 date       \u2506 f64    \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 2025-01-27 \u2506 0.1215 \u2502\n\u2502 2025-01-28 \u2506 0.1215 \u2502\n\u2502 2025-01-29 \u2506 0.1215 \u2502\n\u2502 2025-01-30 \u2506 0.1315 \u2502\n\u2502 2025-01-31 \u2506 0.1315 \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\n# SELIC Over for a single date\n>>> bc.selic_over(\"31-05-2024\")\n0.104  # 10.40%\n```\n\n### Projections Data\n```python\n>>> from pyield import ipca\n# Fetch current month projection for IPCA\n>>> proj = ipca.projected_rate()\n>>> proj\nIndicatorProjection(last_updated=..., reference_period=..., projected_value=...)\n>>> proj.projected_value\n0.0035  # 0.35%\n```\n\n### Interpolation Tools\nInterpolate interest rates for specific business days using the Interpolator class.\n```python\n>>> from pyield import Interpolator\n# Initialize the Interpolator with known business days and interest rates.\n>>> known_bdays = [30, 60, 90]\n>>> known_rates = [0.045, 0.05, 0.055]\n>>> linear_interpolator = Interpolator(\"linear\", known_bdays, known_rates)\n>>> linear_interpolator(45)  # Interpolate the interest rate for a given number of business days.\n0.0475\n\n# Use the flat forward method for interpolation.\n>>> ff_interpolator = Interpolator(\"flat_forward\", known_bdays, known_rates)\n>>> ff_interpolator(45)\n0.04833068080970859\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Carlos Carvalho  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "A Python library for analysis of fixed income instruments in Brazil",
    "version": "0.40.5",
    "project_urls": {
        "Source": "https://github.com/crdcj/PYield"
    },
    "split_keywords": [
        "fixed-income",
        " brazil",
        " finance",
        " analysis",
        " bonds"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e3f7d1e7a82a4f9a7c53000ba71aa4944b08a0ee8d4520e4ea5436ad4b670c09",
                "md5": "e75020b4ea424e6e5f57b17c1948e029",
                "sha256": "2b5b9dd32032cd9c50cc410e423c2b7dd1c669d273f436a776258ba5c05b9bf0"
            },
            "downloads": -1,
            "filename": "pyield-0.40.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e75020b4ea424e6e5f57b17c1948e029",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 139103,
            "upload_time": "2025-10-29T22:53:03",
            "upload_time_iso_8601": "2025-10-29T22:53:03.291452Z",
            "url": "https://files.pythonhosted.org/packages/e3/f7/d1e7a82a4f9a7c53000ba71aa4944b08a0ee8d4520e4ea5436ad4b670c09/pyield-0.40.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "439e98c284541ff3bece9a9ce66796cc078ef624fc8e7d86457181c11e84359b",
                "md5": "bec7ee21767cefef14cc296c519f0f97",
                "sha256": "9daf9dff767cfc14ee159755feea52d01a147df99538486fcf8baa784370e659"
            },
            "downloads": -1,
            "filename": "pyield-0.40.5.tar.gz",
            "has_sig": false,
            "md5_digest": "bec7ee21767cefef14cc296c519f0f97",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 104655,
            "upload_time": "2025-10-29T22:53:05",
            "upload_time_iso_8601": "2025-10-29T22:53:05.588702Z",
            "url": "https://files.pythonhosted.org/packages/43/9e/98c284541ff3bece9a9ce66796cc078ef624fc8e7d86457181c11e84359b/pyield-0.40.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-29 22:53:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "crdcj",
    "github_project": "PYield",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pyield"
}
        
Elapsed time: 1.95736s