PYield


NamePYield JSON
Version 0.7.14 PyPI version JSON
download
home_pageNone
SummaryA Python library for analysis of fixed income instruments in Brazil
upload_time2024-05-16 10:51:46
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.11-blue?logo=python&logoColor=white)](https://python.org "Go to Python homepage")
[![License](https://img.shields.io/badge/License-MIT-blue)](#license)

# PYield: Brazilian Fixed Income Toolkit

## Introduction

Welcome to PYield, a Python library designed for the analysis of fixed income instruments in Brazil. This library is tailored for financial analysts, researchers, and enthusiasts interested in the Brazilian fixed income market. Leveraging the power of popular Python libraries like Pandas and Requests, PYield simplifies the process of obtaining and processing data from key sources such as ANBIMA, BCB, IBGE and B3.

## 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
```

## How to use PYield

### Business Days Tools (Brazilian holidays are automatically considered)
```python
>>> import pyield as yd

# Count the number of business days between two dates
# Start date is included, end date is excluded
>>> yd.count_bdays(start='2023-12-29', end='2024-01-02')
1

# Get the next business day after a given date (offset=1)
>>> yd.offset_bdays(dates="2023-12-29", offset=1)
Timestamp('2024-01-02 00:00:00')

# Get the next business day if it is not a business day (offset=0)
>>> yd.offset_bdays(dates="2023-12-30", offset=0)
Timestamp('2024-01-02 00:00:00')

# Since 2023-12-29 is a business day, it returns the same date (offset=0)
>>> yd.offset_bdays(dates="2023-12-29", offset=0)
Timestamp('2023-12-29 00:00:00')

# Generate a pandas series with the business days between two dates
>>> yd.generate_bdays(start='2023-12-29', end='2024-01-03')
0   2023-12-29
1   2024-01-02
2   2024-01-03
dtype: datetime64[ns]
```

### Futures Data
```python
# Fetch current DI Futures data from B3 (15 minutes delay)
>>> yd.fetch_asset(asset_code="DI1")
TradeTime      TickerSymbol ExpirationDate BDaysToExp ... MaxRate LastAskRate LastBidRate CurrentRate
2024-04-21 13:37:39       DI1K24     2024-05-02          7 ... 0.10660     0.10652     0.10660  0.10660
2024-04-21 13:37:39       DI1M24     2024-06-03         28 ... 0.10518     0.10510     0.10516  0.10518
2024-04-21 13:37:39       DI1N24     2024-07-01         48 ... 0.10480     0.10456     0.10462  0.10460
                ...          ...            ...        ... ...     ...         ...         ...      ...
2024-04-21 13:37:39       DI1F37     2037-01-02       3183 ...    <NA>        <NA>     0.11600     <NA>
2024-04-21 13:37:39       DI1F38     2038-01-04       3432 ...    <NA>        <NA>     0.11600     <NA>
2024-04-21 13:37:39       DI1F39     2039-01-03       3683 ...    <NA>        <NA>        <NA>     <NA>

# Fetch historical DI Futures data from B3
>>> yd.fetch_asset(asset_code="DI1", reference_date='2024-03-08')
TradeDate  TickerSymbol ExpirationDate BDaysToExp ... LastRate LastAskRate LastBidRate SettlementRate
2024-03-08       DI1J24     2024-04-01         15 ...   10.952      10.952      10.956         10.956
2024-03-08       DI1K24     2024-05-02         37 ...   10.776      10.774      10.780         10.777
2024-03-08       DI1M24     2024-06-03         58 ...   10.604      10.602      10.604         10.608
       ...          ...            ...        ... ...      ...         ...         ...            ...
2024-03-08       DI1F37     2037-01-02       3213 ...     <NA>        <NA>        <NA>         10.859
2024-03-08       DI1F38     2038-01-04       3462 ...     <NA>        <NA>        <NA>         10.859
2024-03-08       DI1F39     2039-01-03       3713 ...     <NA>        <NA>        <NA>         10.85
```

### Treasury Bonds Data
```python
# Fetch a DataFrame with the NTN-B data from ANBIMA
# Anbima data is available for the last 5 working days
# Obs: Anbima members have access to the full history
>>> yd.fetch_asset(asset_code="NTN-B", reference_date='2024-04-12')

BondType ReferenceDate MaturityDate BidRate AskRate IndicativeRate       Price
   NTN-B    2024-04-12   2024-08-15 0.07540 0.07504        0.07523 4,271.43565
   NTN-B    2024-04-12   2025-05-15 0.05945 0.05913        0.05930 4,361.34391
   NTN-B    2024-04-12   2026-08-15 0.05927 0.05897        0.05910 4,301.40082
     ...           ...          ...     ...     ...            ...         ...
   NTN-B    2024-04-12   2050-08-15 0.06039 0.06006        0.06023 4,299.28233
   NTN-B    2024-04-12   2055-05-15 0.06035 0.05998        0.06017 4,367.13360
   NTN-B    2024-04-12   2060-08-15 0.06057 0.06016        0.06036 4,292.26323
```

### Spreads Calculation
```python
# Calculate the spread between two DI Futures contracts and the pre-fix bonds
>>> yd.calculate_spreads(spread_type="di_vs_pre", reference_date="2024-4-11")

BondType ReferenceDate MaturityDate  DISpread
     LTN    2024-04-11   2024-07-01    -20.28
     LTN    2024-04-11   2024-10-01    -10.19
     LTN    2024-04-11   2025-01-01    -15.05
   ...      ...           ...           ...
   NTN-F    2024-04-11   2031-01-01     -0.66
   NTN-F    2024-04-11   2033-01-01     -5.69
   NTN-F    2024-04-11   2035-01-01     -1.27
```

### Indicators Data
```python
# Fetch the SELIC target rate from the Central Bank of Brazil
>>> yd.fetch_indicator(indicator_code="SELIC", reference_date='2024-04-12')
0.1075  # 10.75%

# Fetch the IPCA monthly inflation rate from IBGE
>>> yd.fetch_indicator(indicator_code="IPCA", reference_date='2024-03-18')
0.16  # 0.16%

# If no data is yet available for the indicator, the function returns None
>>> yd.fetch_indicator(indicator_code="IPCA", reference_date='2024-04-10')
None
```

### Projections Data
```python
# Fetch current month projection for IPCA from IBGE API
>>> ipca = yd.fetch_projection(projection_code="IPCA_CM")
>>> print(ipca)
IndicatorProjection(
    last_updated=Timestamp('2024-04-19 18:55:00'),
    reference_month_ts=Timestamp('2024-04-01 00:00:00'),
    reference_month_br='ABR/2024',
    projected_value=0.0035  # 0.35%
)
>>> ipca.projected_value
0.0035  # 0.35%
```


            

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/cb/e4/277a6a4ab61c6f0ab0dc694e5ea6a382d1b8469be9a4036ad3f66c0736a0/pyield-0.7.14.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.11-blue?logo=python&logoColor=white)](https://python.org \"Go to Python homepage\")\n[![License](https://img.shields.io/badge/License-MIT-blue)](#license)\n\n# PYield: Brazilian Fixed Income Toolkit\n\n## Introduction\n\nWelcome to PYield, a Python library designed for the analysis of fixed income instruments in Brazil. This library is tailored for financial analysts, researchers, and enthusiasts interested in the Brazilian fixed income market. Leveraging the power of popular Python libraries like Pandas and Requests, PYield simplifies the process of obtaining and processing data from key sources such as ANBIMA, BCB, IBGE and B3.\n\n## 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\n## How to use PYield\n\n### Business Days Tools (Brazilian holidays are automatically considered)\n```python\n>>> import pyield as yd\n\n# Count the number of business days between two dates\n# Start date is included, end date is excluded\n>>> yd.count_bdays(start='2023-12-29', end='2024-01-02')\n1\n\n# Get the next business day after a given date (offset=1)\n>>> yd.offset_bdays(dates=\"2023-12-29\", offset=1)\nTimestamp('2024-01-02 00:00:00')\n\n# Get the next business day if it is not a business day (offset=0)\n>>> yd.offset_bdays(dates=\"2023-12-30\", offset=0)\nTimestamp('2024-01-02 00:00:00')\n\n# Since 2023-12-29 is a business day, it returns the same date (offset=0)\n>>> yd.offset_bdays(dates=\"2023-12-29\", offset=0)\nTimestamp('2023-12-29 00:00:00')\n\n# Generate a pandas series with the business days between two dates\n>>> yd.generate_bdays(start='2023-12-29', end='2024-01-03')\n0   2023-12-29\n1   2024-01-02\n2   2024-01-03\ndtype: datetime64[ns]\n```\n\n### Futures Data\n```python\n# Fetch current DI Futures data from B3 (15 minutes delay)\n>>> yd.fetch_asset(asset_code=\"DI1\")\nTradeTime      TickerSymbol ExpirationDate BDaysToExp ... MaxRate LastAskRate LastBidRate CurrentRate\n2024-04-21 13:37:39       DI1K24     2024-05-02          7 ... 0.10660     0.10652     0.10660  0.10660\n2024-04-21 13:37:39       DI1M24     2024-06-03         28 ... 0.10518     0.10510     0.10516  0.10518\n2024-04-21 13:37:39       DI1N24     2024-07-01         48 ... 0.10480     0.10456     0.10462  0.10460\n                ...          ...            ...        ... ...     ...         ...         ...      ...\n2024-04-21 13:37:39       DI1F37     2037-01-02       3183 ...    <NA>        <NA>     0.11600     <NA>\n2024-04-21 13:37:39       DI1F38     2038-01-04       3432 ...    <NA>        <NA>     0.11600     <NA>\n2024-04-21 13:37:39       DI1F39     2039-01-03       3683 ...    <NA>        <NA>        <NA>     <NA>\n\n# Fetch historical DI Futures data from B3\n>>> yd.fetch_asset(asset_code=\"DI1\", reference_date='2024-03-08')\nTradeDate  TickerSymbol ExpirationDate BDaysToExp ... LastRate LastAskRate LastBidRate SettlementRate\n2024-03-08       DI1J24     2024-04-01         15 ...   10.952      10.952      10.956         10.956\n2024-03-08       DI1K24     2024-05-02         37 ...   10.776      10.774      10.780         10.777\n2024-03-08       DI1M24     2024-06-03         58 ...   10.604      10.602      10.604         10.608\n       ...          ...            ...        ... ...      ...         ...         ...            ...\n2024-03-08       DI1F37     2037-01-02       3213 ...     <NA>        <NA>        <NA>         10.859\n2024-03-08       DI1F38     2038-01-04       3462 ...     <NA>        <NA>        <NA>         10.859\n2024-03-08       DI1F39     2039-01-03       3713 ...     <NA>        <NA>        <NA>         10.85\n```\n\n### Treasury Bonds Data\n```python\n# Fetch a DataFrame with the NTN-B data from ANBIMA\n# Anbima data is available for the last 5 working days\n# Obs: Anbima members have access to the full history\n>>> yd.fetch_asset(asset_code=\"NTN-B\", reference_date='2024-04-12')\n\nBondType ReferenceDate MaturityDate BidRate AskRate IndicativeRate       Price\n   NTN-B    2024-04-12   2024-08-15 0.07540 0.07504        0.07523 4,271.43565\n   NTN-B    2024-04-12   2025-05-15 0.05945 0.05913        0.05930 4,361.34391\n   NTN-B    2024-04-12   2026-08-15 0.05927 0.05897        0.05910 4,301.40082\n     ...           ...          ...     ...     ...            ...         ...\n   NTN-B    2024-04-12   2050-08-15 0.06039 0.06006        0.06023 4,299.28233\n   NTN-B    2024-04-12   2055-05-15 0.06035 0.05998        0.06017 4,367.13360\n   NTN-B    2024-04-12   2060-08-15 0.06057 0.06016        0.06036 4,292.26323\n```\n\n### Spreads Calculation\n```python\n# Calculate the spread between two DI Futures contracts and the pre-fix bonds\n>>> yd.calculate_spreads(spread_type=\"di_vs_pre\", reference_date=\"2024-4-11\")\n\nBondType ReferenceDate MaturityDate  DISpread\n     LTN    2024-04-11   2024-07-01    -20.28\n     LTN    2024-04-11   2024-10-01    -10.19\n     LTN    2024-04-11   2025-01-01    -15.05\n   ...      ...           ...           ...\n   NTN-F    2024-04-11   2031-01-01     -0.66\n   NTN-F    2024-04-11   2033-01-01     -5.69\n   NTN-F    2024-04-11   2035-01-01     -1.27\n```\n\n### Indicators Data\n```python\n# Fetch the SELIC target rate from the Central Bank of Brazil\n>>> yd.fetch_indicator(indicator_code=\"SELIC\", reference_date='2024-04-12')\n0.1075  # 10.75%\n\n# Fetch the IPCA monthly inflation rate from IBGE\n>>> yd.fetch_indicator(indicator_code=\"IPCA\", reference_date='2024-03-18')\n0.16  # 0.16%\n\n# If no data is yet available for the indicator, the function returns None\n>>> yd.fetch_indicator(indicator_code=\"IPCA\", reference_date='2024-04-10')\nNone\n```\n\n### Projections Data\n```python\n# Fetch current month projection for IPCA from IBGE API\n>>> ipca = yd.fetch_projection(projection_code=\"IPCA_CM\")\n>>> print(ipca)\nIndicatorProjection(\n    last_updated=Timestamp('2024-04-19 18:55:00'),\n    reference_month_ts=Timestamp('2024-04-01 00:00:00'),\n    reference_month_br='ABR/2024',\n    projected_value=0.0035  # 0.35%\n)\n>>> ipca.projected_value\n0.0035  # 0.35%\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2023 Carlos Carvalho\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "A Python library for analysis of fixed income instruments in Brazil",
    "version": "0.7.14",
    "project_urls": {
        "Source": "https://github.com/crdcj/PYield"
    },
    "split_keywords": [
        "fixed-income",
        " brazil",
        " finance",
        " analysis",
        " bonds"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "866e2f587aee96542be0554da67d36d59a5f85306e4a39e58f2615b515b13cc2",
                "md5": "eaeb18815e746f46e9c2b28c8b80564b",
                "sha256": "cdf22a3dcd114d52f2e9a88c1e3f228d32b53936e7de0a03ce0bc1d18e07dc64"
            },
            "downloads": -1,
            "filename": "pyield-0.7.14-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "eaeb18815e746f46e9c2b28c8b80564b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 35583,
            "upload_time": "2024-05-16T10:51:43",
            "upload_time_iso_8601": "2024-05-16T10:51:43.201241Z",
            "url": "https://files.pythonhosted.org/packages/86/6e/2f587aee96542be0554da67d36d59a5f85306e4a39e58f2615b515b13cc2/pyield-0.7.14-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cbe4277a6a4ab61c6f0ab0dc694e5ea6a382d1b8469be9a4036ad3f66c0736a0",
                "md5": "ed91491cd4d367e91fb8e0ac5a200d75",
                "sha256": "1347f229b834f73aad7cdce37726494f48cc21e584cffb057c78a16f2eb18b22"
            },
            "downloads": -1,
            "filename": "pyield-0.7.14.tar.gz",
            "has_sig": false,
            "md5_digest": "ed91491cd4d367e91fb8e0ac5a200d75",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 156903,
            "upload_time": "2024-05-16T10:51:46",
            "upload_time_iso_8601": "2024-05-16T10:51:46.242379Z",
            "url": "https://files.pythonhosted.org/packages/cb/e4/277a6a4ab61c6f0ab0dc694e5ea6a382d1b8469be9a4036ad3f66c0736a0/pyield-0.7.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-16 10:51:46",
    "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: 0.36971s