pyield 0.42.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. pyield-0.42.5/.gitignore +21 -0
  2. pyield-0.42.5/LICENSE +21 -0
  3. pyield-0.42.5/PKG-INFO +240 -0
  4. pyield-0.42.5/README.md +195 -0
  5. pyield-0.42.5/pyield/__about__.py +1 -0
  6. pyield-0.42.5/pyield/__init__.py +38 -0
  7. pyield-0.42.5/pyield/anbima/__init__.py +16 -0
  8. pyield-0.42.5/pyield/anbima/difusao.py +246 -0
  9. pyield-0.42.5/pyield/anbima/ettj_intraday.py +143 -0
  10. pyield-0.42.5/pyield/anbima/ettj_last.py +123 -0
  11. pyield-0.42.5/pyield/anbima/ima.py +206 -0
  12. pyield-0.42.5/pyield/anbima/imaq.py +308 -0
  13. pyield-0.42.5/pyield/anbima/tpf.py +456 -0
  14. pyield-0.42.5/pyield/b3/__init__.py +12 -0
  15. pyield-0.42.5/pyield/b3/common.py +85 -0
  16. pyield-0.42.5/pyield/b3/di1.py +450 -0
  17. pyield-0.42.5/pyield/b3/di_over.py +76 -0
  18. pyield-0.42.5/pyield/b3/futures/__init__.py +5 -0
  19. pyield-0.42.5/pyield/b3/futures/core.py +138 -0
  20. pyield-0.42.5/pyield/b3/futures/historical/core.py +17 -0
  21. pyield-0.42.5/pyield/b3/futures/historical/historical_b3.py +221 -0
  22. pyield-0.42.5/pyield/b3/futures/historical/historical_bmf.py +322 -0
  23. pyield-0.42.5/pyield/b3/futures/intraday.py +206 -0
  24. pyield-0.42.5/pyield/b3/price_report.py +341 -0
  25. pyield-0.42.5/pyield/bc/__init__.py +30 -0
  26. pyield-0.42.5/pyield/bc/auction.py +507 -0
  27. pyield-0.42.5/pyield/bc/ptax_api.py +281 -0
  28. pyield-0.42.5/pyield/bc/rates.py +427 -0
  29. pyield-0.42.5/pyield/bc/repo.py +234 -0
  30. pyield-0.42.5/pyield/bc/trades_intraday.py +272 -0
  31. pyield-0.42.5/pyield/bc/trades_monthly.py +233 -0
  32. pyield-0.42.5/pyield/bc/vna.py +102 -0
  33. pyield-0.42.5/pyield/bday/__init__.py +9 -0
  34. pyield-0.42.5/pyield/bday/core.py +538 -0
  35. pyield-0.42.5/pyield/bday/holidays/__init__.py +3 -0
  36. pyield-0.42.5/pyield/bday/holidays/br_holidays_new.txt +1374 -0
  37. pyield-0.42.5/pyield/bday/holidays/br_holidays_old.txt +1295 -0
  38. pyield-0.42.5/pyield/bday/holidays/brholidays.py +63 -0
  39. pyield-0.42.5/pyield/clock.py +23 -0
  40. pyield-0.42.5/pyield/conftest.py +24 -0
  41. pyield-0.42.5/pyield/converters.py +76 -0
  42. pyield-0.42.5/pyield/data_cache.py +84 -0
  43. pyield-0.42.5/pyield/fwd.py +274 -0
  44. pyield-0.42.5/pyield/interpolator.py +269 -0
  45. pyield-0.42.5/pyield/ipca/__init__.py +15 -0
  46. pyield-0.42.5/pyield/ipca/historical.py +205 -0
  47. pyield-0.42.5/pyield/ipca/projected.py +117 -0
  48. pyield-0.42.5/pyield/py.typed +0 -0
  49. pyield-0.42.5/pyield/retry.py +68 -0
  50. pyield-0.42.5/pyield/tn/__init__.py +5 -0
  51. pyield-0.42.5/pyield/tn/auctions.py +461 -0
  52. pyield-0.42.5/pyield/tn/benchmark.py +144 -0
  53. pyield-0.42.5/pyield/tn/lft.py +174 -0
  54. pyield-0.42.5/pyield/tn/ltn.py +275 -0
  55. pyield-0.42.5/pyield/tn/ntnb.py +780 -0
  56. pyield-0.42.5/pyield/tn/ntnb1.py +345 -0
  57. pyield-0.42.5/pyield/tn/ntnbprinc.py +78 -0
  58. pyield-0.42.5/pyield/tn/ntnc.py +313 -0
  59. pyield-0.42.5/pyield/tn/ntnf.py +848 -0
  60. pyield-0.42.5/pyield/tn/pre.py +185 -0
  61. pyield-0.42.5/pyield/tn/tools.py +91 -0
  62. pyield-0.42.5/pyield/types.py +65 -0
  63. pyield-0.42.5/pyproject.toml +65 -0
@@ -0,0 +1,21 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+
4
+ # Distribution / packaging
5
+ build/
6
+ dist/
7
+
8
+ # uv
9
+ uv.lock
10
+
11
+ # Environments
12
+ .env
13
+ .venv
14
+
15
+ # Dev folder
16
+ dev/
17
+
18
+ site/
19
+
20
+ # Claude md file
21
+ CLAUDE.md
pyield-0.42.5/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Carlos Carvalho
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
pyield-0.42.5/PKG-INFO ADDED
@@ -0,0 +1,240 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyield
3
+ Version: 0.42.5
4
+ Summary: A Python library for analysis of fixed income instruments in Brazil
5
+ Project-URL: Homepage, https://github.com/crdcj/PYield
6
+ Project-URL: Documentation, https://crdcj.github.io/PYield
7
+ Project-URL: Source, https://github.com/crdcj/PYield
8
+ Project-URL: Bug Tracker, https://github.com/crdcj/PYield/issues
9
+ Author-email: Carlos Carvalho <cr.cj@outlook.com>
10
+ License: MIT License
11
+
12
+ Copyright (c) 2023 Carlos Carvalho
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+ License-File: LICENSE
32
+ Keywords: analysis,bonds,brazil,finance,fixed-income
33
+ Classifier: Intended Audience :: Financial and Insurance Industry
34
+ Classifier: License :: OSI Approved :: MIT License
35
+ Classifier: Operating System :: OS Independent
36
+ Classifier: Programming Language :: Python :: 3
37
+ Classifier: Topic :: Office/Business :: Financial :: Investment
38
+ Requires-Python: >=3.12
39
+ Requires-Dist: lxml>=6.0.0
40
+ Requires-Dist: polars[pyarrow]>=1.33.0
41
+ Requires-Dist: python-dateutil>=2.8.0
42
+ Requires-Dist: requests>=2.31.0
43
+ Requires-Dist: tenacity>=9.0.0
44
+ Description-Content-Type: text/markdown
45
+
46
+ [![PyPI version](https://img.shields.io/pypi/v/pyield.svg)](https://pypi.python.org/pypi/pyield)
47
+ [![Made with Python](https://img.shields.io/badge/Python->=3.12-blue?logo=python&logoColor=white)](https://python.org "Go to Python homepage")
48
+ [![License](https://img.shields.io/badge/License-MIT-blue)](https://github.com/crdcj/PYield/blob/main/LICENSE)
49
+
50
+ # PYield: Brazilian Fixed Income Toolkit
51
+
52
+ PYield is a Python library for analyzing Brazilian fixed income instruments. It fetches and processes data from ANBIMA, BCB, IBGE and B3, returning Polars DataFrames for fast, type-safe data pipelines.
53
+
54
+ ## Installation
55
+
56
+ ```sh
57
+ pip install pyield
58
+ ```
59
+
60
+ ## Quick Start
61
+
62
+ ```python
63
+ import pyield as yd
64
+
65
+ # Business days (foundation of all calculations)
66
+ yd.bday.count("02-01-2025", "15-01-2025") # -> 9
67
+ yd.bday.offset("29-12-2023", 1) # -> datetime.date(2024, 1, 2)
68
+
69
+ # DI Futures curve
70
+ df = yd.futures("31-05-2024", "DI1")
71
+ # Columns: TradeDate, TickerSymbol, ExpirationDate, BDaysToExp, SettlementRate, ...
72
+
73
+ # Rate interpolation (flat forward, 252 bdays/year convention)
74
+ interp = yd.Interpolator("flat_forward", df["BDaysToExp"], df["SettlementRate"])
75
+ interp(45) # -> 0.04833...
76
+ interp([30, 60]) # -> pl.Series with interpolated rates
77
+
78
+ # Treasury bond pricing
79
+ yd.ntnb.quotation("31-05-2024", "15-05-2035", 0.061490) # -> 99.3651
80
+
81
+ # BCB indicators
82
+ yd.bc.selic_over("31-05-2024") # -> 0.000414...
83
+ ```
84
+
85
+ A Colab notebook with more examples is available:
86
+
87
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/crdcj/PYield/blob/main/examples/pyield_quickstart.ipynb)
88
+
89
+ ## Core Building Blocks
90
+
91
+ ### Business Days (`bday`)
92
+
93
+ The `bday` module is the foundation of PYield. All date calculations (pricing, duration, forward rates) depend on accurate business day counting with Brazilian holidays.
94
+
95
+ ```python
96
+ from pyield import bday
97
+
98
+ # Count business days (start inclusive, end exclusive)
99
+ bday.count("29-12-2023", "02-01-2024") # -> 1
100
+
101
+ # Offset by N business days
102
+ bday.offset("29-12-2023", 1) # -> datetime.date(2024, 1, 2)
103
+
104
+ # Adjust non-business day to next business day
105
+ bday.offset("30-12-2023", 0) # -> datetime.date(2024, 1, 2)
106
+
107
+ # Generate business day range
108
+ bday.generate("22-12-2023", "02-01-2024")
109
+ # -> Series: [2023-12-22, 2023-12-26, 2023-12-27, 2023-12-28, 2023-12-29, 2024-01-02]
110
+
111
+ # Check if date is business day
112
+ bday.is_business_day("25-12-2023") # -> False (Christmas)
113
+ ```
114
+
115
+ All functions support vectorized operations with lists, Series, or arrays.
116
+
117
+ ### Rate Interpolation (`Interpolator`)
118
+
119
+ The `Interpolator` class interpolates interest rates using the 252 business days/year convention standard in Brazil.
120
+
121
+ ```python
122
+ from pyield import Interpolator
123
+
124
+ known_bdays = [30, 60, 90]
125
+ known_rates = [0.045, 0.05, 0.055]
126
+
127
+ # Flat forward interpolation (market standard)
128
+ interp = Interpolator("flat_forward", known_bdays, known_rates)
129
+ interp(45) # -> 0.04833...
130
+
131
+ # Linear interpolation
132
+ linear = Interpolator("linear", known_bdays, known_rates)
133
+ linear(45) # -> 0.0475
134
+
135
+ # Vectorized
136
+ interp([15, 45, 75]) # -> pl.Series with 3 rates
137
+
138
+ # Extrapolation (disabled by default, returns NaN)
139
+ interp(100) # -> nan
140
+ Interpolator("flat_forward", known_bdays, known_rates, extrapolate=True)(100) # -> 0.055
141
+ ```
142
+
143
+ ### Forward Rates (`forward`, `forwards`)
144
+
145
+ Calculate forward rates from spot curves:
146
+
147
+ ```python
148
+ from pyield import forward, forwards
149
+
150
+ # Single forward rate between two points
151
+ forward(bday1=10, bday2=20, rate1=0.05, rate2=0.06) # -> 0.0700952...
152
+
153
+ # Vectorized forward curve from spot rates
154
+ bdays = [10, 20, 30]
155
+ rates = [0.05, 0.06, 0.07]
156
+ forwards(bdays, rates) # -> Series: [0.05, 0.070095, 0.090284]
157
+ ```
158
+
159
+ ## Modules Overview
160
+
161
+ | Module | Purpose |
162
+ |--------|---------|
163
+ | `bday` | Business day calendar with Brazilian holidays |
164
+ | `futures` | B3 futures data (DI1, DDI, FRC, DAP, DOL, WDO, IND, WIN) |
165
+ | `Interpolator` | Rate interpolation (flat_forward, linear) |
166
+ | `forward` / `forwards` | Forward rate calculation |
167
+ | `ltn`, `ntnb`, `ntnf`, `lft`, `ntnc` | Treasury bond pricing and analytics |
168
+ | `anbima` | ANBIMA data (TPF prices, yield curves, IMA indices) |
169
+ | `bc` | BCB indicators (SELIC, PTAX, repo rates, VNA) |
170
+ | `ipca` | Inflation data (historical and projections) |
171
+ | `today` / `now` | Current date/time in Brazil (America/Sao_Paulo) |
172
+
173
+ ## Treasury Bonds
174
+
175
+ ```python
176
+ from pyield import ltn, ntnb, ntnf
177
+
178
+ # Fetch ANBIMA indicative rates
179
+ ltn.data("23-08-2024") # -> DataFrame with LTN bonds
180
+ ntnb.data("23-08-2024") # -> DataFrame with NTN-B bonds
181
+
182
+ # Calculate bond quotation (base 100)
183
+ ntnb.quotation("31-05-2024", "15-05-2035", 0.061490) # -> 99.3651
184
+ ntnb.quotation("31-05-2024", "15-08-2060", 0.061878) # -> 99.5341
185
+
186
+ # DI spreads (bps=True multiplies by 10,000)
187
+ ntnf.di_spreads("30-05-2025", bps=True)
188
+ # -> DataFrame: BondType, MaturityDate, DISpread
189
+ ```
190
+
191
+ ## Futures Data
192
+
193
+ ```python
194
+ from pyield import futures
195
+
196
+ # DI1 (Interbank Deposit Futures)
197
+ futures("31-05-2024", "DI1")
198
+
199
+ # Other contracts: DDI, FRC, DAP, DOL, WDO, IND, WIN
200
+ futures("31-05-2024", "DAP")
201
+
202
+ # Intraday data (when market is open)
203
+ futures("16-01-2025", "DI1") # Returns live data if called during trading hours
204
+ ```
205
+
206
+ ## Date Handling
207
+
208
+ PYield accepts flexible date inputs (`DateLike`):
209
+ - Strings: `"31-05-2024"`, `"31/05/2024"`, `"2024-05-31"`
210
+ - `datetime.date`, `datetime.datetime`
211
+ - `pandas.Timestamp`, `numpy.datetime64`
212
+
213
+ Scalar functions return `datetime.date`. Vectorized functions return `polars.Series`.
214
+
215
+ Null handling: scalar functions return `float('nan')` for missing inputs (propagates through calculations). Vectorized functions propagate `null` element-wise.
216
+
217
+ ```python
218
+ from pyield import ntnb, bday
219
+
220
+ ntnb.quotation(None, "15-05-2035", 0.06149) # -> nan
221
+ bday.count(["01-01-2024", None], "01-02-2024") # -> Series: [22, null]
222
+ ```
223
+
224
+ ## Polars Migration (v0.40.0+)
225
+
226
+ All functions return **Polars DataFrames/Series**. To convert to Pandas:
227
+
228
+ ```python
229
+ df_pandas = df.to_pandas(use_pyarrow_extension_array=True)
230
+ ```
231
+
232
+ ## Documentation
233
+
234
+ Full documentation: [crdcj.github.io/PYield](https://crdcj.github.io/PYield/)
235
+
236
+ ## Tests
237
+
238
+ ```sh
239
+ pytest pyield --doctest-modules
240
+ ```
@@ -0,0 +1,195 @@
1
+ [![PyPI version](https://img.shields.io/pypi/v/pyield.svg)](https://pypi.python.org/pypi/pyield)
2
+ [![Made with Python](https://img.shields.io/badge/Python->=3.12-blue?logo=python&logoColor=white)](https://python.org "Go to Python homepage")
3
+ [![License](https://img.shields.io/badge/License-MIT-blue)](https://github.com/crdcj/PYield/blob/main/LICENSE)
4
+
5
+ # PYield: Brazilian Fixed Income Toolkit
6
+
7
+ PYield is a Python library for analyzing Brazilian fixed income instruments. It fetches and processes data from ANBIMA, BCB, IBGE and B3, returning Polars DataFrames for fast, type-safe data pipelines.
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ pip install pyield
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```python
18
+ import pyield as yd
19
+
20
+ # Business days (foundation of all calculations)
21
+ yd.bday.count("02-01-2025", "15-01-2025") # -> 9
22
+ yd.bday.offset("29-12-2023", 1) # -> datetime.date(2024, 1, 2)
23
+
24
+ # DI Futures curve
25
+ df = yd.futures("31-05-2024", "DI1")
26
+ # Columns: TradeDate, TickerSymbol, ExpirationDate, BDaysToExp, SettlementRate, ...
27
+
28
+ # Rate interpolation (flat forward, 252 bdays/year convention)
29
+ interp = yd.Interpolator("flat_forward", df["BDaysToExp"], df["SettlementRate"])
30
+ interp(45) # -> 0.04833...
31
+ interp([30, 60]) # -> pl.Series with interpolated rates
32
+
33
+ # Treasury bond pricing
34
+ yd.ntnb.quotation("31-05-2024", "15-05-2035", 0.061490) # -> 99.3651
35
+
36
+ # BCB indicators
37
+ yd.bc.selic_over("31-05-2024") # -> 0.000414...
38
+ ```
39
+
40
+ A Colab notebook with more examples is available:
41
+
42
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/crdcj/PYield/blob/main/examples/pyield_quickstart.ipynb)
43
+
44
+ ## Core Building Blocks
45
+
46
+ ### Business Days (`bday`)
47
+
48
+ The `bday` module is the foundation of PYield. All date calculations (pricing, duration, forward rates) depend on accurate business day counting with Brazilian holidays.
49
+
50
+ ```python
51
+ from pyield import bday
52
+
53
+ # Count business days (start inclusive, end exclusive)
54
+ bday.count("29-12-2023", "02-01-2024") # -> 1
55
+
56
+ # Offset by N business days
57
+ bday.offset("29-12-2023", 1) # -> datetime.date(2024, 1, 2)
58
+
59
+ # Adjust non-business day to next business day
60
+ bday.offset("30-12-2023", 0) # -> datetime.date(2024, 1, 2)
61
+
62
+ # Generate business day range
63
+ bday.generate("22-12-2023", "02-01-2024")
64
+ # -> Series: [2023-12-22, 2023-12-26, 2023-12-27, 2023-12-28, 2023-12-29, 2024-01-02]
65
+
66
+ # Check if date is business day
67
+ bday.is_business_day("25-12-2023") # -> False (Christmas)
68
+ ```
69
+
70
+ All functions support vectorized operations with lists, Series, or arrays.
71
+
72
+ ### Rate Interpolation (`Interpolator`)
73
+
74
+ The `Interpolator` class interpolates interest rates using the 252 business days/year convention standard in Brazil.
75
+
76
+ ```python
77
+ from pyield import Interpolator
78
+
79
+ known_bdays = [30, 60, 90]
80
+ known_rates = [0.045, 0.05, 0.055]
81
+
82
+ # Flat forward interpolation (market standard)
83
+ interp = Interpolator("flat_forward", known_bdays, known_rates)
84
+ interp(45) # -> 0.04833...
85
+
86
+ # Linear interpolation
87
+ linear = Interpolator("linear", known_bdays, known_rates)
88
+ linear(45) # -> 0.0475
89
+
90
+ # Vectorized
91
+ interp([15, 45, 75]) # -> pl.Series with 3 rates
92
+
93
+ # Extrapolation (disabled by default, returns NaN)
94
+ interp(100) # -> nan
95
+ Interpolator("flat_forward", known_bdays, known_rates, extrapolate=True)(100) # -> 0.055
96
+ ```
97
+
98
+ ### Forward Rates (`forward`, `forwards`)
99
+
100
+ Calculate forward rates from spot curves:
101
+
102
+ ```python
103
+ from pyield import forward, forwards
104
+
105
+ # Single forward rate between two points
106
+ forward(bday1=10, bday2=20, rate1=0.05, rate2=0.06) # -> 0.0700952...
107
+
108
+ # Vectorized forward curve from spot rates
109
+ bdays = [10, 20, 30]
110
+ rates = [0.05, 0.06, 0.07]
111
+ forwards(bdays, rates) # -> Series: [0.05, 0.070095, 0.090284]
112
+ ```
113
+
114
+ ## Modules Overview
115
+
116
+ | Module | Purpose |
117
+ |--------|---------|
118
+ | `bday` | Business day calendar with Brazilian holidays |
119
+ | `futures` | B3 futures data (DI1, DDI, FRC, DAP, DOL, WDO, IND, WIN) |
120
+ | `Interpolator` | Rate interpolation (flat_forward, linear) |
121
+ | `forward` / `forwards` | Forward rate calculation |
122
+ | `ltn`, `ntnb`, `ntnf`, `lft`, `ntnc` | Treasury bond pricing and analytics |
123
+ | `anbima` | ANBIMA data (TPF prices, yield curves, IMA indices) |
124
+ | `bc` | BCB indicators (SELIC, PTAX, repo rates, VNA) |
125
+ | `ipca` | Inflation data (historical and projections) |
126
+ | `today` / `now` | Current date/time in Brazil (America/Sao_Paulo) |
127
+
128
+ ## Treasury Bonds
129
+
130
+ ```python
131
+ from pyield import ltn, ntnb, ntnf
132
+
133
+ # Fetch ANBIMA indicative rates
134
+ ltn.data("23-08-2024") # -> DataFrame with LTN bonds
135
+ ntnb.data("23-08-2024") # -> DataFrame with NTN-B bonds
136
+
137
+ # Calculate bond quotation (base 100)
138
+ ntnb.quotation("31-05-2024", "15-05-2035", 0.061490) # -> 99.3651
139
+ ntnb.quotation("31-05-2024", "15-08-2060", 0.061878) # -> 99.5341
140
+
141
+ # DI spreads (bps=True multiplies by 10,000)
142
+ ntnf.di_spreads("30-05-2025", bps=True)
143
+ # -> DataFrame: BondType, MaturityDate, DISpread
144
+ ```
145
+
146
+ ## Futures Data
147
+
148
+ ```python
149
+ from pyield import futures
150
+
151
+ # DI1 (Interbank Deposit Futures)
152
+ futures("31-05-2024", "DI1")
153
+
154
+ # Other contracts: DDI, FRC, DAP, DOL, WDO, IND, WIN
155
+ futures("31-05-2024", "DAP")
156
+
157
+ # Intraday data (when market is open)
158
+ futures("16-01-2025", "DI1") # Returns live data if called during trading hours
159
+ ```
160
+
161
+ ## Date Handling
162
+
163
+ PYield accepts flexible date inputs (`DateLike`):
164
+ - Strings: `"31-05-2024"`, `"31/05/2024"`, `"2024-05-31"`
165
+ - `datetime.date`, `datetime.datetime`
166
+ - `pandas.Timestamp`, `numpy.datetime64`
167
+
168
+ Scalar functions return `datetime.date`. Vectorized functions return `polars.Series`.
169
+
170
+ Null handling: scalar functions return `float('nan')` for missing inputs (propagates through calculations). Vectorized functions propagate `null` element-wise.
171
+
172
+ ```python
173
+ from pyield import ntnb, bday
174
+
175
+ ntnb.quotation(None, "15-05-2035", 0.06149) # -> nan
176
+ bday.count(["01-01-2024", None], "01-02-2024") # -> Series: [22, null]
177
+ ```
178
+
179
+ ## Polars Migration (v0.40.0+)
180
+
181
+ All functions return **Polars DataFrames/Series**. To convert to Pandas:
182
+
183
+ ```python
184
+ df_pandas = df.to_pandas(use_pyarrow_extension_array=True)
185
+ ```
186
+
187
+ ## Documentation
188
+
189
+ Full documentation: [crdcj.github.io/PYield](https://crdcj.github.io/PYield/)
190
+
191
+ ## Tests
192
+
193
+ ```sh
194
+ pytest pyield --doctest-modules
195
+ ```
@@ -0,0 +1 @@
1
+ __version__ = "0.42.5"
@@ -0,0 +1,38 @@
1
+ import logging
2
+
3
+ from pyield import anbima, b3, bc, bday, ipca, tn
4
+ from pyield.__about__ import __version__
5
+ from pyield.b3 import di1, futures
6
+ from pyield.clock import now, today
7
+ from pyield.fwd import forward, forwards
8
+ from pyield.interpolator import Interpolator
9
+ from pyield.tn import lft, ltn, ntnb, ntnb1, ntnbprinc, ntnc, ntnf, pre
10
+
11
+ __all__ = [
12
+ "__version__",
13
+ "anbima",
14
+ "bc",
15
+ "b3",
16
+ "ipca",
17
+ "tn",
18
+ "bday",
19
+ "di1",
20
+ "forwards",
21
+ "forward",
22
+ "futures",
23
+ "Interpolator",
24
+ "today",
25
+ "now",
26
+ "lft",
27
+ "ltn",
28
+ "ntnb",
29
+ "ntnbprinc",
30
+ "ntnb1",
31
+ "ntnc",
32
+ "ntnf",
33
+ "pre",
34
+ "bday",
35
+ ]
36
+
37
+ # Configura o logger do pacote principal com um NullHandler
38
+ logging.getLogger(__name__).addHandler(logging.NullHandler())
@@ -0,0 +1,16 @@
1
+ from pyield.anbima.difusao import tpf_difusao
2
+ from pyield.anbima.ettj_intraday import intraday_ettj
3
+ from pyield.anbima.ettj_last import last_ettj
4
+ from pyield.anbima.ima import last_ima
5
+ from pyield.anbima.imaq import imaq
6
+ from pyield.anbima.tpf import tpf_data, tpf_maturities
7
+
8
+ __all__ = [
9
+ "last_ima",
10
+ "imaq",
11
+ "tpf_data",
12
+ "tpf_maturities",
13
+ "last_ettj",
14
+ "intraday_ettj",
15
+ "tpf_difusao",
16
+ ]