cryptodatapy 0.2.3__py3-none-any.whl → 0.2.4__py3-none-any.whl

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.
@@ -88,7 +88,8 @@ class Filter:
88
88
 
89
89
  # add excl cols
90
90
  if self.excl_cols is not None:
91
- self.filtered_df = pd.concat([self.filtered_df, self.raw_df[self.excl_cols]], join="outer", axis=1)
91
+ self.filtered_df = pd.concat([self.filtered_df,
92
+ self.raw_df[self.excl_cols].reindex(self.filtered_df.index)], axis=1)
92
93
 
93
94
  return self.filtered_df
94
95
 
@@ -132,7 +133,8 @@ class Filter:
132
133
 
133
134
  # add excl cols
134
135
  if self.excl_cols is not None:
135
- self.filtered_df = pd.concat([self.df, self.raw_df[self.excl_cols]], join="outer", axis=1)
136
+ self.filtered_df = pd.concat([self.df,
137
+ self.raw_df[self.excl_cols].reindex(self.df)], axis=1)
136
138
  else:
137
139
  self.filtered_df = self.df
138
140
 
@@ -164,8 +166,34 @@ class Filter:
164
166
  # drop tickers with nobs < cs_obs
165
167
  obs = self.filtered_df.groupby(level=0).count().min(axis=1)
166
168
  idx_start = obs[obs > cs_obs].index[0]
167
- # self.filtered_df = self.filtered_df.unstack()[self.filtered_df.unstack().index > idx_start].stack()
168
169
  self.filtered_df = self.filtered_df.loc[idx_start:]
170
+
171
+ return self.filtered_df
172
+
173
+ def remove_delisted(self, field: str = 'close', n_unch_vals: int = 30) -> pd.DataFrame:
174
+ """
175
+ Removes delisted tickers from dataframe.
176
+
177
+ Parameters
178
+ ----------
179
+ field: str, default 'close'
180
+ Field/column to use for detecting delisted tickers.
181
+ n_unch_vals: int, default 30
182
+ Number of consecutive unchanged values to consider a ticker as delisted.
183
+
184
+ Returns
185
+ -------
186
+ filtered_df: pd.DataFrame - MultiIndex
187
+ Filtered dataFrame with DatetimeIndex (level 0), tickers (level 1) and fields (cols).
188
+ """
189
+ # delisted tickers
190
+ delisted_tickers = self.df[field].unstack()[self.df[field].unstack().pct_change().iloc[-n_unch_vals:] == 0].\
191
+ dropna(how='all', axis=0).dropna(thresh=n_unch_vals, axis=1).columns
192
+ print(delisted_tickers)
193
+
194
+ # drop delisted tickers
195
+ self.filtered_df = self.df.drop(delisted_tickers, level=1)
196
+
169
197
  return self.filtered_df
170
198
 
171
199
  def tickers(self, tickers_list) -> pd.DataFrame:
@@ -188,7 +216,7 @@ class Filter:
188
216
  tickers_list = [tickers_list]
189
217
 
190
218
  # drop tickers
191
- self.filtered_df = self.df.drop(tickers_list, level=1, axis=0)
219
+ self.filtered_df = self.df.drop(tickers_list, level=1)
192
220
 
193
221
  return self.filtered_df
194
222
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cryptodatapy
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Cryptoasset data library
5
5
  License: Apache-2.0
6
6
  Author: Systamental
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.9
13
13
  Requires-Dist: DBnomics (>=1.2.3)
14
14
  Requires-Dist: ccxt (>=1.91.52)
15
15
  Requires-Dist: coinmetrics-api-client (>=2022.6.17); python_version >= "3.7"
16
+ Requires-Dist: fsspec (>=2024.6.1)
16
17
  Requires-Dist: investpy (>=1.0.8)
17
18
  Requires-Dist: matplotlib (>=3.5.2)
18
19
  Requires-Dist: numpy (>=1.23.2)
@@ -20,8 +21,10 @@ Requires-Dist: openpyxl (>=3.1.2)
20
21
  Requires-Dist: pandas (>=1.4.4)
21
22
  Requires-Dist: pandas-datareader (>=0.10.0)
22
23
  Requires-Dist: prophet (>=1.1); python_version >= "3.7"
24
+ Requires-Dist: pyarrow (>=17.0.0)
23
25
  Requires-Dist: requests (>=2.28.0); python_version >= "3.7"
24
26
  Requires-Dist: responses (>=0.21.0)
27
+ Requires-Dist: s3fs (>=2024.6.1,<2025.0.0)
25
28
  Requires-Dist: selenium (>=4.4.3)
26
29
  Requires-Dist: statsmodels (>=0.13.2)
27
30
  Requires-Dist: webdriver-manager (>=3.8.3)
@@ -54,17 +54,17 @@ cryptodatapy/extract/web/__init__.py,sha256=8i0fweCeqSpdiPf-47jT240I4ca6SizCu9aD
54
54
  cryptodatapy/extract/web/aqr.py,sha256=LS1D7QzG6UWkLUfDMgBFtiHpznnnAUOpec5Sx3vRGME,11875
55
55
  cryptodatapy/extract/web/web.py,sha256=27cAzlIyYn6R29726J7p9NhSwHypas9EQSjHLILtcjk,9748
56
56
  cryptodatapy/transform/__init__.py,sha256=Spb5cGJ3V_o8hgSWOSrF8J_vsSZpFk0uzW7RpkgfbFE,131
57
- cryptodatapy/transform/clean.py,sha256=rWxEnNIGs28k8x5Hmvo1VcDRtu1-ys0p6M8AO0hDikE,11493
58
- cryptodatapy/transform/clean_perp_futures_ohlcv.ipynb,sha256=9UNGJCgDZrpPbcoGh2kol_Mt20bf572IHgcPKxzqJ5M,52671
57
+ cryptodatapy/transform/clean.py,sha256=uWz9qO55o3-TZGZPPsr0tXAhg2QLMElQ6EkNy-pV96Q,12660
58
+ cryptodatapy/transform/clean_perp_futures_ohlcv.ipynb,sha256=AsO1JMiKKnpRPDU7PT5y8eigNqu0hwkXxVjApt9H9JM,40056
59
59
  cryptodatapy/transform/convertparams.py,sha256=WuQuPxKkjBy85F4NCYdSLWIls-1Avltu6EoaSIu7AYc,44285
60
- cryptodatapy/transform/filter.py,sha256=AArjX0ccYs6NVwoTSrj7G3RvBlqSseQcSDT5B9eXmCY,8030
60
+ cryptodatapy/transform/filter.py,sha256=0-Yz8tfOpHUBULiIVKRlih6lzBj9W9kVzWz1ojYBtSI,9014
61
61
  cryptodatapy/transform/impute.py,sha256=c7qdgFg0qs_xuQnX0jazpt0wgASC0KElLZRuxTkeVKY,5519
62
62
  cryptodatapy/transform/od.py,sha256=LHCzs-Q1hWHixWaQLhnHRacI-sVNlLX_EFv4jOpp4Zk,31008
63
63
  cryptodatapy/transform/wrangle.py,sha256=cBPV2Ub4RmVCdFdx3UlOlI2s4Rc_zzoMAXWcJvqbehs,40157
64
64
  cryptodatapy/util/__init__.py,sha256=zSQ2HU2QIXzCuptJjknmrClwtQKCvIj4aNysZljIgrU,116
65
65
  cryptodatapy/util/datacatalog.py,sha256=qCCX6srXvaAbVAKuA0M2y5IK_2OEx5xA3yRahDZlC-g,13157
66
66
  cryptodatapy/util/datacredentials.py,sha256=KkfJJqDr1jvzdlvpKNqrPwDvWyfbA5GDY87ZG3PHpIA,1510
67
- cryptodatapy-0.2.3.dist-info/LICENSE,sha256=sw4oVq8bDjT3uMtaFebQ-xeIVP4H-bXldTs9q-Jjeks,11344
68
- cryptodatapy-0.2.3.dist-info/WHEEL,sha256=y3eDiaFVSNTPbgzfNn0nYn5tEn1cX6WrdetDlQM4xWw,83
69
- cryptodatapy-0.2.3.dist-info/METADATA,sha256=Z4P3NafpxStnr3crVtpMYJ2ZtPuOpcgqvSwrV2ka4oU,6188
70
- cryptodatapy-0.2.3.dist-info/RECORD,,
67
+ cryptodatapy-0.2.4.dist-info/LICENSE,sha256=sw4oVq8bDjT3uMtaFebQ-xeIVP4H-bXldTs9q-Jjeks,11344
68
+ cryptodatapy-0.2.4.dist-info/WHEEL,sha256=y3eDiaFVSNTPbgzfNn0nYn5tEn1cX6WrdetDlQM4xWw,83
69
+ cryptodatapy-0.2.4.dist-info/METADATA,sha256=SXI76NY-jFrgBFebNE3ZcYhSa-7rCPqB9NNPxwer5HY,6300
70
+ cryptodatapy-0.2.4.dist-info/RECORD,,