AnomalyLab 0.2.1__tar.gz → 0.2.3__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.
- {anomalylab-0.2.1 → anomalylab-0.2.3}/.gitignore +3 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3/AnomalyLab.egg-info}/PKG-INFO +1 -1
- {anomalylab-0.2.1/AnomalyLab.egg-info → anomalylab-0.2.3}/PKG-INFO +1 -1
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/empirical/portfolio.py +3 -3
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/preprocess/outliers.py +0 -2
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/preprocess/shift.py +11 -4
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/structure/panel_data.py +0 -3
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/structure/time_series.py +0 -3
- {anomalylab-0.2.1 → anomalylab-0.2.3}/setup.py +1 -1
- {anomalylab-0.2.1 → anomalylab-0.2.3}/.gitattributes +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/.github/workflows/python-publish.yml +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/AnomalyLab.egg-info/SOURCES.txt +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/AnomalyLab.egg-info/dependency_links.txt +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/AnomalyLab.egg-info/requires.txt +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/AnomalyLab.egg-info/top_level.txt +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/LICENSE +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/MANIFEST.in +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/README.md +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/__init__.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/config.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/core/__init__.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/core/core.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/datasets/__init__.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/datasets/dataset.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/datasets/panel_data.csv +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/datasets/time_series_data.csv +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/datasets/transition_matrix.png +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/empirical/__init__.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/empirical/correlation.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/empirical/empirical.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/empirical/fm_regression.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/empirical/persistence.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/empirical/summary.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/preprocess/__init__.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/preprocess/fillna.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/preprocess/normalize.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/preprocess/preprocessor.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/preprocess/truncate.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/structure/__init__.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/structure/data.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/utils/__init__.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/utils/imports.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/utils/utils.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/visualization/__init__.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/anomalylab/visualization/format.py +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/requirements.txt +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/setup.cfg +0 -0
- {anomalylab-0.2.1 → anomalylab-0.2.3}/tests/__init__.py +0 -0
|
@@ -40,11 +40,11 @@ class PortfolioAnalysis(Empirical):
|
|
|
40
40
|
for field in ["endog", "weight"]:
|
|
41
41
|
if getattr(self, field) is None:
|
|
42
42
|
raise ValueError(f"{field} must be provided")
|
|
43
|
-
self.ft_series = self.factors_series.df
|
|
44
43
|
if self.models is not None and self.factors_series is None:
|
|
45
44
|
raise ValueError(
|
|
46
45
|
"If 'models' is provided, 'factors_series' must also be provided!"
|
|
47
46
|
)
|
|
47
|
+
self.ft_series = getattr(self.factors_series, "df", None)
|
|
48
48
|
|
|
49
49
|
def add_star(self, mean_val: float, p_val: float) -> str:
|
|
50
50
|
"""Add significance stars to mean values based on p-value thresholds.
|
|
@@ -677,8 +677,8 @@ if __name__ == "__main__":
|
|
|
677
677
|
panel,
|
|
678
678
|
endog="return",
|
|
679
679
|
weight="MktCap",
|
|
680
|
-
models=Models,
|
|
681
|
-
factors_series=time_series,
|
|
680
|
+
# models=Models,
|
|
681
|
+
# factors_series=time_series,
|
|
682
682
|
)
|
|
683
683
|
|
|
684
684
|
group = portfolio.GroupN("Illiq", 10)
|
|
@@ -56,8 +56,15 @@ class Shift(Preprocessor):
|
|
|
56
56
|
Shift: The instance of the Shift class with updated state.
|
|
57
57
|
|
|
58
58
|
Raises:
|
|
59
|
-
|
|
59
|
+
NotImplementedError: Only monthly frequency is supported.
|
|
60
|
+
warnings: The data has already been shifted.
|
|
61
|
+
|
|
60
62
|
"""
|
|
63
|
+
|
|
64
|
+
# todo: add support for daily and yearly frequency
|
|
65
|
+
if self.panel_data.frequency != "M":
|
|
66
|
+
raise NotImplementedError("Only monthly frequency is supported.")
|
|
67
|
+
|
|
61
68
|
# Check if the data has already been shifted
|
|
62
69
|
if self.panel_data.shift:
|
|
63
70
|
# raise ValueError("The data has already been shifted.")
|
|
@@ -76,14 +83,14 @@ class Shift(Preprocessor):
|
|
|
76
83
|
):
|
|
77
84
|
# Copy the columns to shift
|
|
78
85
|
df_shift: DataFrame = self.panel_data.df[
|
|
79
|
-
[self.
|
|
86
|
+
[self.time, self.id] + columns
|
|
80
87
|
].copy()
|
|
81
88
|
# Shift the columns
|
|
82
|
-
df_shift[self.
|
|
89
|
+
df_shift[self.time] += period
|
|
83
90
|
# Merge the shifted columns
|
|
84
91
|
self.panel_data.df = self.panel_data.df.merge(
|
|
85
92
|
right=df_shift,
|
|
86
|
-
on=[self.
|
|
93
|
+
on=[self.time, self.id],
|
|
87
94
|
# If dropna is True, only keep the rows with matching 'time' and 'id'
|
|
88
95
|
how="inner" if dropna else "left",
|
|
89
96
|
suffixes=("", f"({period})"),
|
|
@@ -58,9 +58,6 @@ class PanelData(Data):
|
|
|
58
58
|
This method identifies remaining columns as firm characteristics, excluding classifications.
|
|
59
59
|
"""
|
|
60
60
|
self.df[self.id] = self.df[self.id].astype(int)
|
|
61
|
-
# todo: add support for daily and yearly frequency
|
|
62
|
-
if self.frequency != "M":
|
|
63
|
-
raise NotImplementedError("Only monthly frequency is supported.")
|
|
64
61
|
self.df[self.time] = pd.to_datetime(self.df[self.time], format="ISO8601")
|
|
65
62
|
self.df[self.time] = self.df[self.time].dt.to_period(freq=self.frequency)
|
|
66
63
|
self.df = self.df.sort_values(by=[self.time, self.id])
|
|
@@ -34,9 +34,6 @@ class TimeSeries(Data):
|
|
|
34
34
|
|
|
35
35
|
This method renames the time column to a standardized name and identifies remaining columns as factors.
|
|
36
36
|
"""
|
|
37
|
-
# todo: add support for daily and yearly frequency
|
|
38
|
-
if self.frequency != "M":
|
|
39
|
-
raise NotImplementedError("Only monthly frequency is supported.")
|
|
40
37
|
self.df[self.time] = pd.to_datetime(self.df[self.time], format="ISO8601")
|
|
41
38
|
self.df[self.time] = self.df[self.time].dt.to_period(freq=self.frequency)
|
|
42
39
|
self.df = self.df.sort_values(by=self.time)
|
|
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
|
|
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
|