cryptodatapy 0.2.15__tar.gz → 0.2.16__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.
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/PKG-INFO +1 -1
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/pyproject.toml +1 -1
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/data_vendors/coinmetrics_api.py +32 -32
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/data_vendors/cryptocompare_api.py +159 -204
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/data_vendors/datavendor.py +21 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/data_vendors/tiingo_api.py +5 -1
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/libraries/ccxt_api.py +215 -209
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/transform/convertparams.py +35 -57
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/util/datacredentials.py +18 -3
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/LICENSE +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/README.md +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/__init__.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/conf/__init__.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/conf/fields.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/conf/tickers.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/__init__.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/br_econ_calendar.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/ca_econ_calendar.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/cn_econ_calendar.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/de_econ_calendar.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/ez_econ_calendar.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/fr_econ_calendar.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/gb_econ_calendar.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/get_econ_calendars.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/id_econ_calendar.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/in_econ_calendar.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/it_econ_calendar.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/jp_econ_calendar.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/kr_econ_calendar.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/mx_econ_calendar.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/ru_econ_calendar.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/tr_econ_calendar.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/datasets/us_econ_calendar.csv +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/__init__.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/data_vendors/.ipynb_checkpoints/CCXT-checkpoint.ipynb +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/data_vendors/.ipynb_checkpoints/DBNomics-checkpoint.ipynb +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/data_vendors/.ipynb_checkpoints/InvestPy-checkpoint.ipynb +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/data_vendors/.ipynb_checkpoints/NasdaqDataLink-checkpoint.ipynb +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/data_vendors/.ipynb_checkpoints/PandasDataReader-checkpoint.ipynb +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/data_vendors/__init__.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/data_vendors/glassnode_api.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/datarequest.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/exchanges/__init__.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/exchanges/dydx.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/exchanges/exchange.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/getdata.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/libraries/__init__.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/libraries/dbnomics_api.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/libraries/investpy_api.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/libraries/library.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/libraries/pandasdr_api.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/web/__init__.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/web/aqr.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/web/web.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/transform/__init__.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/transform/clean.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/transform/filter.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/transform/impute.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/transform/od.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/transform/wrangle.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/util/__init__.py +0 -0
- {cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/util/datacatalog.py +0 -0
{cryptodatapy-0.2.15 → cryptodatapy-0.2.16}/src/cryptodatapy/extract/data_vendors/coinmetrics_api.py
RENAMED
@@ -35,6 +35,7 @@ class CoinMetrics(DataVendor):
|
|
35
35
|
frequencies: List[str] = ["tick", "block", "1s", "1min", "5min", "10min", "15min", "30min",
|
36
36
|
"1h", "2h", "4h", "8h", "d", "w", "m", "q"],
|
37
37
|
base_url: Optional[str] = data_cred.coinmetrics_base_url,
|
38
|
+
api_endpoints: Optional[Dict[str, str]] = None,
|
38
39
|
api_key: Optional[str] = data_cred.coinmetrics_api_key,
|
39
40
|
max_obs_per_call: Optional[int] = None,
|
40
41
|
rate_limit: Optional[Any] = None,
|
@@ -62,6 +63,9 @@ class CoinMetrics(DataVendor):
|
|
62
63
|
List of available frequencies, e.g. ['tick', '1min', '5min', '10min', '15min', '30min', '1h', '2h', '4h',
|
63
64
|
base_url: str, optional, default None
|
64
65
|
Base url used for GET requests. If not provided, default is set to base_url stored in DataCredentials.
|
66
|
+
api_endpoints: dict, optional, default None
|
67
|
+
Dictionary with available API endpoints. If not provided, default is set to api_endpoints stored in
|
68
|
+
DataCredentials.
|
65
69
|
api_key: str, optional, default None
|
66
70
|
Api key, e.g. 'dcf13983adf7dfa79a0dfa35adf'. If not provided, default is set to
|
67
71
|
api_key stored in DataCredentials.
|
@@ -73,13 +77,13 @@ class CoinMetrics(DataVendor):
|
|
73
77
|
"""
|
74
78
|
super().__init__(
|
75
79
|
categories, exchanges, indexes, assets, markets, market_types,
|
76
|
-
fields, frequencies, base_url, api_key, max_obs_per_call, rate_limit
|
80
|
+
fields, frequencies, base_url, api_endpoints, api_key, max_obs_per_call, rate_limit
|
77
81
|
)
|
78
82
|
self.data_req = None
|
83
|
+
self.data_resp = None
|
79
84
|
self.data = pd.DataFrame()
|
80
85
|
|
81
|
-
|
82
|
-
def req_meta(data_type: str) -> Dict[str, Any]:
|
86
|
+
def req_meta(self, data_type: str) -> Dict[str, Any]:
|
83
87
|
"""
|
84
88
|
Request metadata.
|
85
89
|
|
@@ -95,14 +99,14 @@ class CoinMetrics(DataVendor):
|
|
95
99
|
Object with metadata.
|
96
100
|
"""
|
97
101
|
try:
|
98
|
-
|
102
|
+
self.data_resp = getattr(client, data_type)()
|
99
103
|
|
100
104
|
except AssertionError as e:
|
101
105
|
logging.warning(e)
|
102
106
|
logging.warning(f"Failed to get metadata for {data_type}.")
|
103
107
|
|
104
108
|
else:
|
105
|
-
return
|
109
|
+
return self.data_resp
|
106
110
|
|
107
111
|
def get_exchanges_info(self, as_list: bool = False) -> Union[List[str], pd.DataFrame]:
|
108
112
|
"""
|
@@ -119,9 +123,9 @@ class CoinMetrics(DataVendor):
|
|
119
123
|
List or dataframe with info on supported exchanges.
|
120
124
|
"""
|
121
125
|
# req data
|
122
|
-
|
126
|
+
self.req_meta(data_type='catalog_exchanges')
|
123
127
|
# wrangle data resp
|
124
|
-
self.exchanges = WrangleInfo(
|
128
|
+
self.exchanges = WrangleInfo(self.data_resp).cm_meta_resp(as_list=as_list, index_name='exchange')
|
125
129
|
|
126
130
|
return self.exchanges
|
127
131
|
|
@@ -140,9 +144,9 @@ class CoinMetrics(DataVendor):
|
|
140
144
|
List or dataframe with info on available indexes.
|
141
145
|
"""
|
142
146
|
# req data
|
143
|
-
|
147
|
+
self.req_meta(data_type='catalog_indexes')
|
144
148
|
# wrangle data resp
|
145
|
-
self.indexes = WrangleInfo(
|
149
|
+
self.indexes = WrangleInfo(self.data_resp).cm_meta_resp(as_list=as_list, index_name='ticker')
|
146
150
|
|
147
151
|
return self.indexes
|
148
152
|
|
@@ -161,9 +165,9 @@ class CoinMetrics(DataVendor):
|
|
161
165
|
List or dataframe with info on available assets.
|
162
166
|
"""
|
163
167
|
# req data
|
164
|
-
|
168
|
+
self.req_meta(data_type='catalog_assets')
|
165
169
|
# wrangle data resp
|
166
|
-
self.assets = WrangleInfo(
|
170
|
+
self.assets = WrangleInfo(self.data_resp).cm_meta_resp(as_list=as_list, index_name='ticker')
|
167
171
|
|
168
172
|
return self.assets
|
169
173
|
|
@@ -182,9 +186,9 @@ class CoinMetrics(DataVendor):
|
|
182
186
|
List or dataframe with info on available markets, by exchange.
|
183
187
|
"""
|
184
188
|
# req data
|
185
|
-
|
189
|
+
self.req_meta(data_type='catalog_markets')
|
186
190
|
# wrangle data resp
|
187
|
-
self.markets = WrangleInfo(
|
191
|
+
self.markets = WrangleInfo(self.data_resp).cm_meta_resp(as_list=as_list)
|
188
192
|
|
189
193
|
return self.markets
|
190
194
|
|
@@ -203,9 +207,9 @@ class CoinMetrics(DataVendor):
|
|
203
207
|
List or dataframe of on-chain info.
|
204
208
|
"""
|
205
209
|
# req data
|
206
|
-
|
210
|
+
self.req_meta(data_type='catalog_metrics')
|
207
211
|
# wrangle data resp
|
208
|
-
onchain_fields = WrangleInfo(
|
212
|
+
onchain_fields = WrangleInfo(self.data_resp).cm_meta_resp(as_list=as_list, index_name='fields')
|
209
213
|
|
210
214
|
return onchain_fields
|
211
215
|
|
@@ -327,15 +331,15 @@ class CoinMetrics(DataVendor):
|
|
327
331
|
url = self.base_url + data_type
|
328
332
|
|
329
333
|
# data request
|
330
|
-
data_resp = data_req.get_req(url=url, params=params)
|
334
|
+
self.data_resp = data_req.get_req(url=url, params=params)
|
331
335
|
|
332
336
|
# raise error if data is None
|
333
|
-
if data_resp is None:
|
337
|
+
if self.data_resp is None:
|
334
338
|
raise Exception("Failed to fetch data after multiple attempts.")
|
335
339
|
# retrieve data
|
336
340
|
else:
|
337
341
|
# data
|
338
|
-
data, next_page_url = data_resp.get('data', []), data_resp.get('next_page_url')
|
342
|
+
data, next_page_url = self.data_resp.get('data', []), self.data_resp.get('next_page_url')
|
339
343
|
|
340
344
|
# while loop
|
341
345
|
while next_page_url:
|
@@ -355,8 +359,7 @@ class CoinMetrics(DataVendor):
|
|
355
359
|
|
356
360
|
return df
|
357
361
|
|
358
|
-
|
359
|
-
def wrangle_data_resp(data_req: DataRequest, data_resp: pd.DataFrame()) -> pd.DataFrame():
|
362
|
+
def wrangle_data_resp(self, data_req: DataRequest, data_resp: pd.DataFrame()) -> pd.DataFrame():
|
360
363
|
"""
|
361
364
|
Wrangle data response.
|
362
365
|
|
@@ -897,41 +900,38 @@ class CoinMetrics(DataVendor):
|
|
897
900
|
'candle_usd_volume', 'candle_trades_count']
|
898
901
|
oc_list = [field for field in self.fields if field not in ohlcv_list]
|
899
902
|
|
900
|
-
# empty df
|
901
|
-
df = pd.DataFrame()
|
902
|
-
|
903
903
|
# get indexes data
|
904
904
|
self.get_indexes_info(as_list=True)
|
905
905
|
sleep(self.data_req.pause)
|
906
906
|
if any([ticker.upper() in self.indexes for ticker in self.data_req.source_tickers]) and any(
|
907
907
|
[field in ohlcv_list for field in self.data_req.source_fields]
|
908
908
|
):
|
909
|
-
|
910
|
-
|
909
|
+
df = self.get_indexes(data_req)
|
910
|
+
self.data = pd.concat([self.data, df])
|
911
911
|
|
912
912
|
# get OHLCV data
|
913
913
|
self.get_assets_info(as_list=True)
|
914
|
-
sleep(
|
914
|
+
sleep(self.data_req.pause)
|
915
915
|
if any([ticker in self.assets for ticker in self.data_req.source_tickers]) and any(
|
916
916
|
[field in ohlcv_list for field in self.data_req.source_fields]
|
917
917
|
):
|
918
918
|
df1 = self.get_ohlcv(data_req)
|
919
|
-
|
919
|
+
self.data = pd.concat([self.data, df1])
|
920
920
|
|
921
921
|
# get on-chain data
|
922
922
|
if any([ticker in self.assets for ticker in self.data_req.source_tickers]) and any(
|
923
923
|
[field in oc_list for field in self.data_req.source_fields]
|
924
924
|
):
|
925
925
|
df2 = self.get_onchain(data_req)
|
926
|
-
|
926
|
+
self.data = pd.concat([self.data, df2], axis=1)
|
927
927
|
|
928
928
|
# check if df empty
|
929
|
-
if
|
929
|
+
if self.data.empty:
|
930
930
|
raise Exception("No data returned."
|
931
931
|
" Check data request parameters and try again.")
|
932
932
|
|
933
933
|
# filter df for desired fields and sort index by date
|
934
|
-
fields = [field for field in data_req.fields if field in
|
935
|
-
|
934
|
+
fields = [field for field in data_req.fields if field in self.data.columns]
|
935
|
+
self.data = self.data.loc[:, fields].sort_index()
|
936
936
|
|
937
|
-
return
|
937
|
+
return self.data
|