PYield 0.25.1__tar.gz → 0.25.2__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 (34) hide show
  1. {pyield-0.25.1 → pyield-0.25.2}/PKG-INFO +2 -2
  2. {pyield-0.25.1 → pyield-0.25.2}/README.md +1 -1
  3. pyield-0.25.2/pyield/__about__.py +1 -0
  4. {pyield-0.25.1 → pyield-0.25.2}/pyield/b3_futures/historical.py +4 -3
  5. {pyield-0.25.1 → pyield-0.25.2}/pyield/b3_futures/intraday.py +17 -12
  6. {pyield-0.25.1 → pyield-0.25.2}/pyield/di.py +2 -2
  7. pyield-0.25.1/pyield/__about__.py +0 -1
  8. {pyield-0.25.1 → pyield-0.25.2}/.gitignore +0 -0
  9. {pyield-0.25.1 → pyield-0.25.2}/LICENSE +0 -0
  10. {pyield-0.25.1 → pyield-0.25.2}/pyield/__init__.py +0 -0
  11. {pyield-0.25.1 → pyield-0.25.2}/pyield/anbima.py +0 -0
  12. {pyield-0.25.1 → pyield-0.25.2}/pyield/b3_futures/__init__.py +0 -0
  13. {pyield-0.25.1 → pyield-0.25.2}/pyield/b3_futures/common.py +0 -0
  14. {pyield-0.25.1 → pyield-0.25.2}/pyield/b3_futures/xml.py +0 -0
  15. {pyield-0.25.1 → pyield-0.25.2}/pyield/bday.py +0 -0
  16. {pyield-0.25.1 → pyield-0.25.2}/pyield/bonds/__init__.py +0 -0
  17. {pyield-0.25.1 → pyield-0.25.2}/pyield/bonds/bond_tools.py +0 -0
  18. {pyield-0.25.1 → pyield-0.25.2}/pyield/bonds/lft.py +0 -0
  19. {pyield-0.25.1 → pyield-0.25.2}/pyield/bonds/ltn.py +0 -0
  20. {pyield-0.25.1 → pyield-0.25.2}/pyield/bonds/ntnb.py +0 -0
  21. {pyield-0.25.1 → pyield-0.25.2}/pyield/bonds/ntnf.py +0 -0
  22. {pyield-0.25.1 → pyield-0.25.2}/pyield/conftest.py +0 -0
  23. {pyield-0.25.1 → pyield-0.25.2}/pyield/data_cache.py +0 -0
  24. {pyield-0.25.1 → pyield-0.25.2}/pyield/date_converter.py +0 -0
  25. {pyield-0.25.1 → pyield-0.25.2}/pyield/holidays/__init__.py +0 -0
  26. {pyield-0.25.1 → pyield-0.25.2}/pyield/holidays/br_holidays_new.txt +0 -0
  27. {pyield-0.25.1 → pyield-0.25.2}/pyield/holidays/br_holidays_old.txt +0 -0
  28. {pyield-0.25.1 → pyield-0.25.2}/pyield/holidays/brholidays.py +0 -0
  29. {pyield-0.25.1 → pyield-0.25.2}/pyield/indicators.py +0 -0
  30. {pyield-0.25.1 → pyield-0.25.2}/pyield/interpolator.py +0 -0
  31. {pyield-0.25.1 → pyield-0.25.2}/pyield/projections.py +0 -0
  32. {pyield-0.25.1 → pyield-0.25.2}/pyield/py.typed +0 -0
  33. {pyield-0.25.1 → pyield-0.25.2}/pyield/tools.py +0 -0
  34. {pyield-0.25.1 → pyield-0.25.2}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: PYield
3
- Version: 0.25.1
3
+ Version: 0.25.2
4
4
  Summary: A Python library for analysis of fixed income instruments in Brazil
5
5
  Project-URL: Source, https://github.com/crdcj/PYield
6
6
  Author-email: Carlos Carvalho <cr.cj@outlook.com>
@@ -169,7 +169,7 @@ dtype: datetime64[ns]
169
169
  >>> import pyield as yd
170
170
  # Fetch current DI Futures data from B3 (15 minutes delay)
171
171
  >>> yd.futures(contract_code="DI1")
172
- TradeTime TickerSymbol ExpirationDate BDaysToExp ... MaxRate LastAskRate LastBidRate CurrentRate
172
+ TradeTime TickerSymbol ExpirationDate BDaysToExp ... MaxRate LastAskRate LastBidRate LastRate
173
173
  2024-04-21 13:37:39 DI1K24 2024-05-02 7 ... 0.10660 0.10652 0.10660 0.10660
174
174
  2024-04-21 13:37:39 DI1M24 2024-06-03 28 ... 0.10518 0.10510 0.10516 0.10518
175
175
  2024-04-21 13:37:39 DI1N24 2024-07-01 48 ... 0.10480 0.10456 0.10462 0.10460
@@ -129,7 +129,7 @@ dtype: datetime64[ns]
129
129
  >>> import pyield as yd
130
130
  # Fetch current DI Futures data from B3 (15 minutes delay)
131
131
  >>> yd.futures(contract_code="DI1")
132
- TradeTime TickerSymbol ExpirationDate BDaysToExp ... MaxRate LastAskRate LastBidRate CurrentRate
132
+ TradeTime TickerSymbol ExpirationDate BDaysToExp ... MaxRate LastAskRate LastBidRate LastRate
133
133
  2024-04-21 13:37:39 DI1K24 2024-05-02 7 ... 0.10660 0.10652 0.10660 0.10660
134
134
  2024-04-21 13:37:39 DI1M24 2024-06-03 28 ... 0.10518 0.10510 0.10516 0.10518
135
135
  2024-04-21 13:37:39 DI1N24 2024-07-01 48 ... 0.10480 0.10456 0.10462 0.10460
@@ -0,0 +1 @@
1
+ __version__ = "0.25.2"
@@ -247,9 +247,10 @@ def process_df(
247
247
 
248
248
  # Calculate DV01 for DI1 contracts
249
249
  if asset_code == "DI1":
250
- byears = df["BDaysToExp"] / 252
251
- dv01_price = 100_000 / ((1 + df["SettlementRate"] + 0.0001) ** byears)
252
- df["DV01"] = (df["SettlementPrice"] - dv01_price).astype("Float64")
250
+ duration = df["BDaysToExp"] / 252
251
+ modified_duration = duration / (1 + df["SettlementRate"])
252
+ df["DV01"] = 0.0001 * modified_duration * df["SettlementPrice"]
253
+ df["DV01"] = df["DV01"].astype("Float64")
253
254
 
254
255
  return df
255
256
 
@@ -60,14 +60,14 @@ def _rename_columns(df: pd.DataFrame) -> pd.DataFrame:
60
60
  "minPric": "MinRate",
61
61
  "maxPric": "MaxRate",
62
62
  "avrgPric": "AvgRate",
63
- "curPrc": "CurrentRate",
63
+ "curPrc": "LastRate",
64
64
  "grssAmt": "FinancialVolume",
65
65
  "mtrtyCode": "ExpirationDate",
66
66
  "opnCtrcts": "OpenContracts",
67
67
  "tradQty": "TradeCount",
68
68
  "traddCtrctsQty": "TradeVolume",
69
- "buyOffer.price": "CurrentAskRate",
70
- "sellOffer.price": "CurrentBidRate",
69
+ "buyOffer.price": "LastAskRate",
70
+ "sellOffer.price": "LastBidRate",
71
71
  }
72
72
  # Check which columns are present in the DataFrame before renaming
73
73
  rename_dict = {c: all_columns[c] for c in all_columns if c in df.columns}
@@ -115,12 +115,17 @@ def _process_df(raw_df: pd.DataFrame) -> pd.DataFrame:
115
115
  df[rate_cols] = df[rate_cols].div(100).round(5)
116
116
 
117
117
  # Adjust DI1 futures contracts
118
- if "DI1" in df["TickerSymbol"].iloc[0]:
118
+ contract_type = df["TickerSymbol"].iloc[0][:3]
119
+ if contract_type in {"DI1", "DAP"}:
119
120
  byears = df["BDaysToExp"] / 252
120
- df["CurrentPrice"] = 100_000 / ((1 + df["CurrentRate"]) ** (byears))
121
- df["CurrentPrice"] = df["CurrentPrice"].round(2).astype("Float64")
122
- dv01_price = 100_000 / ((1 + df["CurrentRate"] + 0.0001) ** byears)
123
- df["DV01"] = (df["CurrentPrice"] - dv01_price).astype("Float64")
121
+ df["LastPrice"] = 100_000 / ((1 + df["LastRate"]) ** (byears))
122
+ df["LastPrice"] = df["LastPrice"].round(2).astype("Float64")
123
+
124
+ if contract_type == "DI1":
125
+ duration = df["BDaysToExp"] / 252
126
+ modified_duration = duration / (1 + df["LastRate"])
127
+ df["DV01"] = 0.0001 * modified_duration * df["LastPrice"]
128
+ df["DV01"] = df["DV01"].astype("Float64")
124
129
 
125
130
  return df
126
131
 
@@ -154,10 +159,10 @@ def _select_and_reorder_columns(df: pd.DataFrame) -> pd.DataFrame:
154
159
  "MinRate",
155
160
  "AvgRate",
156
161
  "MaxRate",
157
- "CurrentAskRate",
158
- "CurrentBidRate",
159
- "CurrentRate",
160
- "CurrentPrice",
162
+ "LastAskRate",
163
+ "LastBidRate",
164
+ "LastRate",
165
+ "LastPrice",
161
166
  ]
162
167
  reordered_columns = [col for col in all_columns if col in df.columns]
163
168
  return df[reordered_columns].copy()
@@ -156,9 +156,9 @@ class DIFutures:
156
156
  "MaxRate",
157
157
  "CloseRate",
158
158
  "SettlementRate",
159
- "CurrentRate",
159
+ "LastRate",
160
160
  "SettlementPrice",
161
- "CurrentPrice",
161
+ "LastPrice",
162
162
  ]
163
163
  selected_cols = [col for col in cols if col in df.columns]
164
164
  df = df[selected_cols].copy()
@@ -1 +0,0 @@
1
- __version__ = "0.25.1"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes