AnomalyLab 0.3.1__tar.gz → 0.3.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.
Files changed (49) hide show
  1. {anomalylab-0.3.1 → anomalylab-0.3.3/AnomalyLab.egg-info}/PKG-INFO +1 -1
  2. {anomalylab-0.3.1/AnomalyLab.egg-info → anomalylab-0.3.3}/PKG-INFO +1 -1
  3. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/core/core.py +11 -4
  4. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/preprocess/fillna.py +16 -7
  5. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/structure/panel_data.py +5 -2
  6. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/structure/time_series.py +3 -2
  7. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/visualization/format.py +0 -6
  8. {anomalylab-0.3.1 → anomalylab-0.3.3}/setup.py +1 -1
  9. {anomalylab-0.3.1 → anomalylab-0.3.3}/.gitattributes +0 -0
  10. {anomalylab-0.3.1 → anomalylab-0.3.3}/.github/workflows/python-publish.yml +0 -0
  11. {anomalylab-0.3.1 → anomalylab-0.3.3}/.gitignore +0 -0
  12. {anomalylab-0.3.1 → anomalylab-0.3.3}/AnomalyLab.egg-info/SOURCES.txt +0 -0
  13. {anomalylab-0.3.1 → anomalylab-0.3.3}/AnomalyLab.egg-info/dependency_links.txt +0 -0
  14. {anomalylab-0.3.1 → anomalylab-0.3.3}/AnomalyLab.egg-info/requires.txt +0 -0
  15. {anomalylab-0.3.1 → anomalylab-0.3.3}/AnomalyLab.egg-info/top_level.txt +0 -0
  16. {anomalylab-0.3.1 → anomalylab-0.3.3}/LICENSE +0 -0
  17. {anomalylab-0.3.1 → anomalylab-0.3.3}/MANIFEST.in +0 -0
  18. {anomalylab-0.3.1 → anomalylab-0.3.3}/README.md +0 -0
  19. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/__init__.py +0 -0
  20. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/config.py +0 -0
  21. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/core/__init__.py +0 -0
  22. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/datasets/__init__.py +0 -0
  23. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/datasets/dataset.py +0 -0
  24. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/datasets/panel_data.csv +0 -0
  25. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/datasets/time_series_data.csv +0 -0
  26. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/datasets/transition_matrix.png +0 -0
  27. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/empirical/__init__.py +0 -0
  28. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/empirical/correlation.py +0 -0
  29. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/empirical/empirical.py +0 -0
  30. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/empirical/factor_return.py +0 -0
  31. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/empirical/fm_regression.py +0 -0
  32. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/empirical/persistence.py +0 -0
  33. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/empirical/portfolio.py +0 -0
  34. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/empirical/summary.py +0 -0
  35. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/preprocess/__init__.py +0 -0
  36. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/preprocess/normalize.py +0 -0
  37. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/preprocess/outliers.py +0 -0
  38. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/preprocess/preprocessor.py +0 -0
  39. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/preprocess/shift.py +0 -0
  40. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/preprocess/truncate.py +0 -0
  41. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/structure/__init__.py +0 -0
  42. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/structure/data.py +0 -0
  43. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/utils/__init__.py +0 -0
  44. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/utils/imports.py +0 -0
  45. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/utils/utils.py +0 -0
  46. {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/visualization/__init__.py +0 -0
  47. {anomalylab-0.3.1 → anomalylab-0.3.3}/requirements.txt +0 -0
  48. {anomalylab-0.3.1 → anomalylab-0.3.3}/setup.cfg +0 -0
  49. {anomalylab-0.3.1 → anomalylab-0.3.3}/tests/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: AnomalyLab
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: A Python package for empirical asset pricing analysis.
5
5
  Author: FinPhd
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: AnomalyLab
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: A Python package for empirical asset pricing analysis.
5
5
  Author: FinPhd
6
6
  Classifier: Programming Language :: Python :: 3
@@ -121,8 +121,7 @@ class Panel:
121
121
 
122
122
  @property
123
123
  def fm_preprocessor(self) -> FamaMacBethRegression:
124
- if self._fm_preprocessor is None:
125
- self._fm_preprocessor = FamaMacBethRegression(panel_data=self.panel_data)
124
+ self._fm_preprocessor = FamaMacBethRegression(panel_data=self.panel_data)
126
125
  return self._fm_preprocessor
127
126
 
128
127
  def format_preprocessor(self, path: str) -> FormatExcel:
@@ -355,10 +354,18 @@ class Panel:
355
354
  )
356
355
 
357
356
  def format_excel(
358
- self, path: str, align=True, line=True, convert_brackets=False
357
+ self,
358
+ path: str,
359
+ align=True,
360
+ line=True,
361
+ convert_brackets=False,
362
+ adjust_col_widths=False,
359
363
  ) -> None:
360
364
  self.format_preprocessor(path=path).process(
361
- align=align, line=line, convert_brackets=convert_brackets
365
+ align=align,
366
+ line=line,
367
+ convert_brackets=convert_brackets,
368
+ adjust_col_widths=adjust_col_widths,
362
369
  )
363
370
 
364
371
 
@@ -201,12 +201,15 @@ class FillNa(Preprocessor):
201
201
 
202
202
  def _warning(self, fill_columns: list[str]) -> None:
203
203
  """
204
- Issues warnings regarding missing values and normalization status.
204
+ Emit warnings regarding missing values and normalization status.
205
205
 
206
- This method checks if any missing values are present in the specified
207
- fill_columns. If none are found, it emits a warning. Additionally,
208
- it checks if the data has already been normalized, in which case
209
- it warns that missing values have been filled with zeros.
206
+ This method performs the following checks:
207
+ 1. It verifies if there are any missing values in the specified `fill_columns`.
208
+ - If no missing values are found, a warning is issued indicating this.
209
+ 2. It checks whether the data has already been normalized.
210
+ - If normalized, a warning is issued that missing values were filled with zeros during normalization.
211
+ 3. It checks whether missing values were filled previously.
212
+ - If so, a warning is issued to indicate that missing values have already been handled earlier.
210
213
 
211
214
  Args:
212
215
  fill_columns (list[str]): The list of columns to check for missing values.
@@ -215,7 +218,11 @@ class FillNa(Preprocessor):
215
218
  warnings.warn(message=f"Missing values not found in {fill_columns}.")
216
219
  if self.panel_data.normalize:
217
220
  warnings.warn(
218
- message=f"The data has already been normalized and the missing values have been filled 0."
221
+ message=f"The data has already been normalized, and missing values have been filled with 0."
222
+ )
223
+ if self.panel_data.fillna:
224
+ warnings.warn(
225
+ message=f"The missing values have already been handled earlier."
219
226
  )
220
227
 
221
228
 
@@ -224,7 +231,9 @@ if __name__ == "__main__":
224
231
 
225
232
  df: DataFrame = DataSet.get_panel_data()
226
233
 
227
- panel: PanelData = PanelData(df=df, name="Stocks", classifications="industry")
234
+ panel: PanelData = PanelData(
235
+ df=df, name="Stocks", ret="return", classifications="industry"
236
+ )
228
237
 
229
238
  fill_nan: FillNa = FillNa(panel_data=panel)
230
239
  fill_nan.fill_group_column(
@@ -61,8 +61,9 @@ class PanelData(Data):
61
61
  if self.is_copy:
62
62
  self.df = copy.deepcopy(self.df)
63
63
  self.df[self.id] = self.df[self.id].astype(int)
64
- self.df[self.time] = pd.to_datetime(self.df[self.time], format="ISO8601")
65
- self.df[self.time] = self.df[self.time].dt.to_period(freq=self.frequency)
64
+ if not isinstance(self.df[self.time].dtype, pd.PeriodDtype):
65
+ self.df[self.time] = pd.to_datetime(self.df[self.time], format="ISO8601")
66
+ self.df[self.time] = self.df[self.time].dt.to_period(freq=self.frequency)
66
67
  self.df.sort_values(by=[self.time, self.id], inplace=True)
67
68
  basic_column = (
68
69
  [self.id, self.time] if self.ret is None else [self.id, self.time, self.ret]
@@ -182,6 +183,8 @@ class PanelData(Data):
182
183
  raise ValueError("No classifications found.")
183
184
  check_columns = set(self.classifications)
184
185
  elif check_range == "characteristics":
186
+ if self.firm_characteristics is None:
187
+ raise ValueError("No firm characteristics found.")
185
188
  check_columns = set(self.firm_characteristics)
186
189
  else:
187
190
  raise ValueError("Invalid check_range value.")
@@ -37,8 +37,9 @@ class TimeSeries(Data):
37
37
  """
38
38
  if self.is_copy:
39
39
  self.df = copy.deepcopy(self.df)
40
- self.df[self.time] = pd.to_datetime(self.df[self.time], format="ISO8601")
41
- self.df[self.time] = self.df[self.time].dt.to_period(freq=self.frequency)
40
+ if not isinstance(self.df[self.time].dtype, pd.PeriodDtype):
41
+ self.df[self.time] = pd.to_datetime(self.df[self.time], format="ISO8601")
42
+ self.df[self.time] = self.df[self.time].dt.to_period(freq=self.frequency)
42
43
  self.df = self.df.sort_values(by=self.time)
43
44
  self.factors = list(self.df.columns)
44
45
  self.factors.remove(self.time)
@@ -1,11 +1,5 @@
1
1
  from anomalylab.utils.imports import *
2
2
 
3
- # from dataclasses import dataclass
4
- # from openpyxl import load_workbook
5
- # from openpyxl.styles import Alignment, Border, Side
6
- # from glob import glob
7
- # import os
8
-
9
3
 
10
4
  @dataclass
11
5
  class FormatExcel:
@@ -2,7 +2,7 @@ from setuptools import find_packages, setup
2
2
 
3
3
  setup(
4
4
  name="AnomalyLab",
5
- version="0.3.1",
5
+ version="0.3.3",
6
6
  author="FinPhd",
7
7
  # author_email="your.email@example.com",
8
8
  description="A Python package for empirical asset pricing analysis.",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes