PYield 0.9.1__tar.gz → 0.9.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.
- {pyield-0.9.1 → pyield-0.9.2}/PKG-INFO +1 -1
- pyield-0.9.2/pyield/__about__.py +1 -0
- {pyield-0.9.1 → pyield-0.9.2}/pyield/bday.py +2 -2
- {pyield-0.9.1 → pyield-0.9.2}/pyield/fetchers/anbima.py +5 -2
- {pyield-0.9.1 → pyield-0.9.2}/pyield/fetchers/indicators.py +6 -6
- {pyield-0.9.1 → pyield-0.9.2}/pyield/fetchers/projections.py +3 -3
- {pyield-0.9.1 → pyield-0.9.2}/pyield/ntnb.py +6 -14
- {pyield-0.9.1 → pyield-0.9.2}/pyield/spreads.py +2 -2
- {pyield-0.9.1 → pyield-0.9.2}/pyproject.toml +1 -1
- pyield-0.9.1/pyield/__about__.py +0 -1
- {pyield-0.9.1 → pyield-0.9.2}/LICENSE +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/README.md +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/pyield/__init__.py +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/pyield/date_validator.py +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/pyield/fetchers/__init__.py +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/pyield/fetchers/futures/__init__.py +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/pyield/fetchers/futures/common.py +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/pyield/fetchers/futures/historical.py +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/pyield/fetchers/futures/intraday.py +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/pyield/fetchers/futures/xml.py +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/pyield/holidays/__init__.py +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/pyield/holidays/br_holidays_new.txt +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/pyield/holidays/br_holidays_old.txt +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/pyield/holidays/holidays_manager.py +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/pyield/interpolators.py +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/pyield/py.typed +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/tests/__init__.py +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/tests/data/SPRD231222.zip +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/tests/data/SPRD240426.zip +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/tests/test_bday.py +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/tests/test_futures.py +0 -0
- {pyield-0.9.1 → pyield-0.9.2}/tests/test_futures_xml.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.9.2"
|
|
@@ -176,9 +176,9 @@ def offset(
|
|
|
176
176
|
# Force to datetime[ns] if the input was a single date
|
|
177
177
|
result = result.as_unit("ns")
|
|
178
178
|
else:
|
|
179
|
-
|
|
179
|
+
result_dti = pd.to_datetime(offsetted_dates_np)
|
|
180
180
|
# Force the result to be a Series if the input was not a single date
|
|
181
|
-
result = pd.Series(
|
|
181
|
+
result = pd.Series(result_dti).astype("datetime64[ns]")
|
|
182
182
|
|
|
183
183
|
return result
|
|
184
184
|
|
|
@@ -10,7 +10,10 @@ ANBIMA_URL = "https://www.anbima.com.br/informacoes/merc-sec/arqs/"
|
|
|
10
10
|
# URL example: https://www.anbima.com.br/informacoes/merc-sec/arqs/ms240614.txt
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
def _get_file_content(
|
|
13
|
+
def _get_file_content(
|
|
14
|
+
reference_date: pd.Timestamp,
|
|
15
|
+
remote_access: dict | None = None,
|
|
16
|
+
) -> str:
|
|
14
17
|
url_date = reference_date.strftime("%y%m%d")
|
|
15
18
|
filename = f"ms{url_date}.txt"
|
|
16
19
|
|
|
@@ -90,7 +93,7 @@ def _process_raw_df(df_raw: pd.DataFrame) -> pd.DataFrame:
|
|
|
90
93
|
def anbima(
|
|
91
94
|
reference_date: str | pd.Timestamp | None = None,
|
|
92
95
|
bond_type: str | list[str] | None = None,
|
|
93
|
-
remote_access: dict = None,
|
|
96
|
+
remote_access: dict | None = None,
|
|
94
97
|
) -> pd.DataFrame:
|
|
95
98
|
"""
|
|
96
99
|
Fetches indicative treasury rates from ANBIMA for a specified reference date.
|
|
@@ -10,17 +10,17 @@ def indicator(
|
|
|
10
10
|
indicator_type: Literal["IPCA_MR", "SELIC_TARGET", "DI", "VNA_LFT"],
|
|
11
11
|
reference_date: str | pd.Timestamp | None = None,
|
|
12
12
|
) -> float | None:
|
|
13
|
-
|
|
14
|
-
if
|
|
13
|
+
ind_type = str(indicator_type).upper()
|
|
14
|
+
if ind_type == "IPCA_MR":
|
|
15
15
|
return ipca_monthly_rate(reference_date)
|
|
16
|
-
elif
|
|
16
|
+
elif ind_type == "SELIC_TARGET":
|
|
17
17
|
return selic_target(reference_date)
|
|
18
|
-
elif
|
|
18
|
+
elif ind_type == "DI":
|
|
19
19
|
return di(reference_date)
|
|
20
|
-
elif
|
|
20
|
+
elif ind_type == "VNA_LFT":
|
|
21
21
|
return vna_lft(reference_date)
|
|
22
22
|
else:
|
|
23
|
-
raise ValueError(f"Invalid indicator type: {
|
|
23
|
+
raise ValueError(f"Invalid indicator type: {ind_type}")
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
def ipca_monthly_rate(reference_date: str | pd.Timestamp | None = None) -> float | None:
|
|
@@ -17,11 +17,11 @@ class IndicatorProjection:
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def projection(projection_type: Literal["IPCA_CM"]) -> IndicatorProjection:
|
|
20
|
-
|
|
21
|
-
if
|
|
20
|
+
proj_type = str(projection_type).upper()
|
|
21
|
+
if proj_type == "IPCA_CM":
|
|
22
22
|
return ipca_current_month()
|
|
23
23
|
else:
|
|
24
|
-
raise ValueError(f"Invalid projection type: {
|
|
24
|
+
raise ValueError(f"Invalid projection type: {proj_type}")
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
def ipca_current_month() -> IndicatorProjection:
|
|
@@ -87,14 +87,12 @@ def coupon_dates_map(
|
|
|
87
87
|
# Generate coupon dates
|
|
88
88
|
dates = pd.date_range(start=first_coupon_date, end=end, freq="3MS")
|
|
89
89
|
|
|
90
|
-
# Convert to pandas Series since pd.date_range returns a DatetimeIndex
|
|
91
|
-
dates = pd.Series(dates)
|
|
92
|
-
|
|
93
90
|
# Offset dates by 14 in order to have day 15 of the month
|
|
94
91
|
dates += pd.Timedelta(days=14)
|
|
95
92
|
|
|
96
93
|
# First coupon date must be after the reference date
|
|
97
|
-
|
|
94
|
+
dates = dates[dates >= start]
|
|
95
|
+
return pd.Series(dates).reset_index(drop=True)
|
|
98
96
|
|
|
99
97
|
|
|
100
98
|
def coupon_dates(
|
|
@@ -128,14 +126,8 @@ def coupon_dates(
|
|
|
128
126
|
# Move the coupon date back 6 months
|
|
129
127
|
coupon_date -= pd.DateOffset(months=6)
|
|
130
128
|
|
|
131
|
-
#
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
# Sort the coupon dates in ascending order
|
|
135
|
-
coupon_dates = coupon_dates.sort_values(ignore_index=True)
|
|
136
|
-
|
|
137
|
-
# Force a index reset to avoid issues with the index
|
|
138
|
-
return coupon_dates.reset_index(drop=True)
|
|
129
|
+
# Return the coupon dates as a sorted Series
|
|
130
|
+
return pd.Series(coupon_dates).sort_values(ignore_index=True)
|
|
139
131
|
|
|
140
132
|
|
|
141
133
|
def quotation(
|
|
@@ -309,7 +301,7 @@ def _get_nsr_df(reference_date: pd.Timestamp) -> pd.DataFrame:
|
|
|
309
301
|
Returns:
|
|
310
302
|
pd.DataFrame: DataFrame containing the NIR data for NTN-B bonds.
|
|
311
303
|
"""
|
|
312
|
-
df = futures
|
|
304
|
+
df = futures(contract_code="DI1", reference_date=reference_date)
|
|
313
305
|
if "CurrentRate" in df.columns:
|
|
314
306
|
df = df.rename(columns={"CurrentRate": "NSR_DI"})
|
|
315
307
|
keep_cols = [
|
|
@@ -342,7 +334,7 @@ def _get_nsr_df(reference_date: pd.Timestamp) -> pd.DataFrame:
|
|
|
342
334
|
if reference_date == today:
|
|
343
335
|
# If the reference date is today, use the previous business day
|
|
344
336
|
anbima_date = bday.offset(reference_date, -1)
|
|
345
|
-
df_pre = spread
|
|
337
|
+
df_pre = spread(spread_type="DI_PRE", reference_date=anbima_date)
|
|
346
338
|
df_pre.query("BondType == 'LTN'", inplace=True)
|
|
347
339
|
df_pre["MaturityDate"] = bday.offset(df_pre["MaturityDate"], 0)
|
|
348
340
|
df_pre["DISpread"] /= 10_000 # Remove BPS (basis points) from the spread
|
|
@@ -38,9 +38,9 @@ def spread(
|
|
|
38
38
|
Example:
|
|
39
39
|
>>> spread("DI_PRE", "2024-06-18")
|
|
40
40
|
"""
|
|
41
|
-
|
|
41
|
+
spread_type_cap = str(spread_type).upper()
|
|
42
42
|
normalized_date = dv.normalize_date(reference_date)
|
|
43
|
-
if
|
|
43
|
+
if spread_type_cap == "DI_PRE":
|
|
44
44
|
return di_pre(normalized_date)
|
|
45
45
|
else:
|
|
46
46
|
raise ValueError(f"Unsupported spread type: {spread_type}")
|
pyield-0.9.1/pyield/__about__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.9.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|