PYield 0.2.11__tar.gz → 0.2.13__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.2.11 → pyield-0.2.13}/PKG-INFO +1 -1
- pyield-0.2.13/pyield/__about__.py +1 -0
- {pyield-0.2.11 → pyield-0.2.13}/pyield/di_html.py +6 -1
- {pyield-0.2.11 → pyield-0.2.13}/pyield/di_xml.py +14 -5
- {pyield-0.2.11 → pyield-0.2.13}/pyproject.toml +1 -1
- pyield-0.2.11/pyield/__about__.py +0 -1
- {pyield-0.2.11 → pyield-0.2.13}/LICENSE +0 -0
- {pyield-0.2.11 → pyield-0.2.13}/README.md +0 -0
- {pyield-0.2.11 → pyield-0.2.13}/pyield/__init__.py +0 -0
- {pyield-0.2.11 → pyield-0.2.13}/pyield/br_calendar.py +0 -0
- {pyield-0.2.11 → pyield-0.2.13}/pyield/di_futures.py +0 -0
- {pyield-0.2.11 → pyield-0.2.13}/pyield/new_br_holidays.txt +0 -0
- {pyield-0.2.11 → pyield-0.2.13}/pyield/old_br_holidays.txt +0 -0
- {pyield-0.2.11 → pyield-0.2.13}/tests/__init__.py +0 -0
- {pyield-0.2.11 → pyield-0.2.13}/tests/test_br_calendar.py +0 -0
- {pyield-0.2.11 → pyield-0.2.13}/tests/test_di.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.13"
|
|
@@ -188,7 +188,11 @@ def process_di(df: pd.DataFrame, reference_date: pd.Timestamp) -> pd.DataFrame:
|
|
|
188
188
|
"ÚLT.OF. VENDA": "last_offer_rate",
|
|
189
189
|
}
|
|
190
190
|
)
|
|
191
|
-
|
|
191
|
+
|
|
192
|
+
df.insert(0, "reference_date", reference_date)
|
|
193
|
+
# Convert to datetime64[ns] since it is pandas default type for timestamps
|
|
194
|
+
df["reference_date"] = df["reference_date"].astype("datetime64[ns]")
|
|
195
|
+
|
|
192
196
|
# Contract code format was changed in 22/05/2006
|
|
193
197
|
if reference_date < pd.Timestamp("2006-05-22"):
|
|
194
198
|
df["expiration"] = df["contract_code"].apply(
|
|
@@ -232,6 +236,7 @@ def process_di(df: pd.DataFrame, reference_date: pd.Timestamp) -> pd.DataFrame:
|
|
|
232
236
|
# Order columns
|
|
233
237
|
df = df[
|
|
234
238
|
[
|
|
239
|
+
"reference_date",
|
|
235
240
|
"contract_code",
|
|
236
241
|
"expiration",
|
|
237
242
|
"bdays",
|
|
@@ -34,14 +34,19 @@ def extract_xml_file(zip_file: io.BytesIO) -> io.BytesIO:
|
|
|
34
34
|
|
|
35
35
|
# Then, read the inner file
|
|
36
36
|
with zipfile.ZipFile(outer_file, "r") as inner_zip:
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
filenames = inner_zip.namelist()
|
|
38
|
+
# Get first file that ends with ".xml"
|
|
39
|
+
xml_filename = [name for name in filenames if name.endswith(".xml")][0]
|
|
40
|
+
inner_file_content = inner_zip.read(xml_filename)
|
|
39
41
|
|
|
40
42
|
return io.BytesIO(inner_file_content)
|
|
41
43
|
|
|
42
44
|
|
|
43
45
|
def parse_xml_file(xml_file: io.BytesIO) -> list:
|
|
44
|
-
|
|
46
|
+
parser = etree.XMLParser(
|
|
47
|
+
ns_clean=True, remove_blank_text=True, remove_comments=True, recover=True
|
|
48
|
+
)
|
|
49
|
+
tree = etree.parse(xml_file, parser)
|
|
45
50
|
# Definir os namespaces (substitua 'ns' pelo prefixo apropriado se necessário)
|
|
46
51
|
namespaces = {"ns": "urn:bvmf.217.01.xsd"}
|
|
47
52
|
|
|
@@ -92,13 +97,17 @@ def process_df(df_raw: pd.DataFrame, reference_date: pd.Timestamp) -> pd.DataFra
|
|
|
92
97
|
# Remover colunas cujos dados são constantes: MktDataStrmId, AdjstdQtStin e PrvsAdjstdQtStin
|
|
93
98
|
df.drop(columns=["MktDataStrmId", "AdjstdQtStin", "PrvsAdjstdQtStin"], inplace=True)
|
|
94
99
|
|
|
100
|
+
df.insert(0, "RptDt", reference_date)
|
|
101
|
+
# Convert to datetime64[ns] since it is pandas default type for timestamps
|
|
102
|
+
df["RptDt"] = df["RptDt"].astype("datetime64[ns]")
|
|
103
|
+
|
|
95
104
|
expiration = df["TckrSymb"].str[3:].apply(dif.get_expiration_date)
|
|
96
105
|
# Insert the column at the beginning
|
|
97
|
-
df.insert(
|
|
106
|
+
df.insert(2, "ExpDt", expiration)
|
|
98
107
|
|
|
99
108
|
business_days = brc.count_bdays(reference_date, df["ExpDt"])
|
|
100
109
|
# Insert the column at the beginning
|
|
101
|
-
df.insert(
|
|
110
|
+
df.insert(3, "BDaysToExp", business_days)
|
|
102
111
|
# Convert to nullable integer, since other columns use this data type
|
|
103
112
|
df["BDaysToExp"] = df["BDaysToExp"].astype(pd.Int64Dtype())
|
|
104
113
|
# Remove expired contracts
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.11"
|
|
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
|