cryptodatapy 0.2.7__py3-none-any.whl → 0.2.8__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.
- cryptodatapy/extract/datarequest.py +27 -1
- cryptodatapy/extract/libraries/Untitled.ipynb +168 -2
- cryptodatapy/extract/libraries/ccxt_api.py +17 -17
- cryptodatapy/extract/libraries/pandasdr_api.py +151 -137
- cryptodatapy/transform/convertparams.py +73 -164
- cryptodatapy/transform/wrangle.py +43 -23
- {cryptodatapy-0.2.7.dist-info → cryptodatapy-0.2.8.dist-info}/METADATA +1 -1
- {cryptodatapy-0.2.7.dist-info → cryptodatapy-0.2.8.dist-info}/RECORD +10 -10
- {cryptodatapy-0.2.7.dist-info → cryptodatapy-0.2.8.dist-info}/LICENSE +0 -0
- {cryptodatapy-0.2.7.dist-info → cryptodatapy-0.2.8.dist-info}/WHEEL +0 -0
@@ -21,6 +21,7 @@ class DataRequest:
|
|
21
21
|
markets: Optional[Union[str, List[str]]] = None,
|
22
22
|
freq: str = "d",
|
23
23
|
exch: Optional[str] = None,
|
24
|
+
countries: Optional[Union[str, List[str]]] = None,
|
24
25
|
mkt_type: Optional[str] = "spot",
|
25
26
|
start_date: Optional[Union[str, datetime, pd.Timestamp]] = None,
|
26
27
|
end_date: Optional[Union[str, datetime, pd.Timestamp]] = None,
|
@@ -55,6 +56,8 @@ class DataRequest:
|
|
55
56
|
Frequency of data observations. Defaults to daily 'd' which includes weekends for cryptoassets.
|
56
57
|
exch: str, optional, default None
|
57
58
|
Name of asset exchange, e.g. 'Binance', 'FTX', 'IEX', 'Nasdaq', etc.
|
59
|
+
countries: list or str, optional, default None
|
60
|
+
Country codes for which to pull data, e.g. 'US', 'GB', 'CN', 'JP', etc.
|
58
61
|
mkt_type: str, optional, default 'spot'
|
59
62
|
Market type, e.g. 'spot ', 'future', 'perpetual_future', 'option'.
|
60
63
|
start_date: str, datetime or pd.Timestamp, optional, default None
|
@@ -99,6 +102,7 @@ class DataRequest:
|
|
99
102
|
self.markets = markets # markets
|
100
103
|
self.freq = freq # frequency
|
101
104
|
self.exch = exch # exchange
|
105
|
+
self.countries = countries # country codes
|
102
106
|
self.mkt_type = mkt_type # market type
|
103
107
|
self.start_date = start_date # start date
|
104
108
|
self.end_date = end_date # end date
|
@@ -282,6 +286,27 @@ class DataRequest:
|
|
282
286
|
else:
|
283
287
|
raise TypeError("Exchange must be a string.")
|
284
288
|
|
289
|
+
@property
|
290
|
+
def countries(self):
|
291
|
+
"""
|
292
|
+
Returns country codes for data request.
|
293
|
+
"""
|
294
|
+
return self._countries
|
295
|
+
|
296
|
+
@countries.setter
|
297
|
+
def countries(self, countries):
|
298
|
+
"""
|
299
|
+
Sets country codes for data request.
|
300
|
+
"""
|
301
|
+
if countries is None:
|
302
|
+
self._countries = countries
|
303
|
+
elif isinstance(countries, str):
|
304
|
+
self._countries = [countries]
|
305
|
+
elif isinstance(countries, list):
|
306
|
+
self._countries = countries
|
307
|
+
else:
|
308
|
+
raise TypeError("Country codes must be a string or list of strings.")
|
309
|
+
|
285
310
|
@property
|
286
311
|
def mkt_type(self):
|
287
312
|
"""
|
@@ -665,7 +690,8 @@ class DataRequest:
|
|
665
690
|
Data response in JSON format.
|
666
691
|
"""
|
667
692
|
# set number of attempts
|
668
|
-
attempts = 0
|
693
|
+
attempts, resp = 0, None
|
694
|
+
|
669
695
|
# run a while loop in case the attempt fails
|
670
696
|
while attempts < self.trials:
|
671
697
|
|