cryptodatapy 0.2.1__py3-none-any.whl → 0.2.3__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/.DS_Store +0 -0
- cryptodatapy/conf/fx_tickers.csv +31 -0
- cryptodatapy/conf/tickers.csv +6 -0
- cryptodatapy/extract/libraries/ccxt_api.py +81 -60
- cryptodatapy/extract/libraries/library.py +19 -8
- cryptodatapy/transform/clean.py +136 -173
- cryptodatapy/transform/clean_perp_futures_ohlcv.ipynb +1639 -0
- cryptodatapy/transform/filter.py +56 -143
- cryptodatapy/transform/impute.py +36 -83
- cryptodatapy/transform/od.py +221 -450
- cryptodatapy/transform/wrangle.py +2 -4
- {cryptodatapy-0.2.1.dist-info → cryptodatapy-0.2.3.dist-info}/METADATA +1 -1
- {cryptodatapy-0.2.1.dist-info → cryptodatapy-0.2.3.dist-info}/RECORD +15 -13
- {cryptodatapy-0.2.1.dist-info → cryptodatapy-0.2.3.dist-info}/LICENSE +0 -0
- {cryptodatapy-0.2.1.dist-info → cryptodatapy-0.2.3.dist-info}/WHEEL +0 -0
@@ -0,0 +1,1639 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "code",
|
5
|
+
"execution_count": 86,
|
6
|
+
"id": "9fea9fae",
|
7
|
+
"metadata": {},
|
8
|
+
"outputs": [],
|
9
|
+
"source": [
|
10
|
+
"import pandas as pd\n",
|
11
|
+
"import numpy as np\n",
|
12
|
+
"\n",
|
13
|
+
"from cryptodatapy.extract.datarequest import DataRequest\n",
|
14
|
+
"from cryptodatapy.extract.getdata import GetData\n",
|
15
|
+
"from cryptodatapy.transform.od import OutlierDetection\n",
|
16
|
+
"from cryptodatapy.transform.impute import Impute\n",
|
17
|
+
"from cryptodatapy.transform.filter import Filter\n",
|
18
|
+
"from cryptodatapy.transform.clean import CleanData, stitch_dataframes\n",
|
19
|
+
"from cryptodatapy.transform.impute import Impute"
|
20
|
+
]
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"cell_type": "code",
|
24
|
+
"execution_count": 94,
|
25
|
+
"id": "c9876f0b",
|
26
|
+
"metadata": {},
|
27
|
+
"outputs": [],
|
28
|
+
"source": [
|
29
|
+
"data_req = DataRequest(source='tiingo')"
|
30
|
+
]
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"cell_type": "code",
|
34
|
+
"execution_count": 95,
|
35
|
+
"id": "e23c9751",
|
36
|
+
"metadata": {},
|
37
|
+
"outputs": [
|
38
|
+
{
|
39
|
+
"ename": "AttributeError",
|
40
|
+
"evalue": "'Tiingo' object has no attribute 'get_top_mkt_cap_info'",
|
41
|
+
"output_type": "error",
|
42
|
+
"traceback": [
|
43
|
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
44
|
+
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
|
45
|
+
"Cell \u001b[0;32mIn [95], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m GetData(data_req)\u001b[38;5;241m.\u001b[39mget_meta(method\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mget_top_mkt_cap_info\u001b[39m\u001b[38;5;124m'\u001b[39m)\n",
|
46
|
+
"File \u001b[0;32m~/projects/systamental/cryptodatapy/src/cryptodatapy/extract/getdata.py:145\u001b[0m, in \u001b[0;36mGetData.get_meta\u001b[0;34m(self, attr, method, **kwargs)\u001b[0m\n\u001b[1;32m 143\u001b[0m meta \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mgetattr\u001b[39m(ds, attr)\n\u001b[1;32m 144\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m method \u001b[38;5;129;01min\u001b[39;00m valid_meth:\n\u001b[0;32m--> 145\u001b[0m meta \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mgetattr\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mds\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m)\u001b[49m(\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m 146\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 147\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mAttributeError\u001b[39;00m(\n\u001b[1;32m 148\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSelect a valid attribute or method. Valid attributes: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mvalid_attr\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 149\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m Valid methods include: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mvalid_meth\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 150\u001b[0m )\n",
|
47
|
+
"\u001b[0;31mAttributeError\u001b[0m: 'Tiingo' object has no attribute 'get_top_mkt_cap_info'"
|
48
|
+
]
|
49
|
+
}
|
50
|
+
],
|
51
|
+
"source": [
|
52
|
+
"GetData(data_req).get_meta(method='get_top_mkt_cap_info')"
|
53
|
+
]
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"cell_type": "code",
|
57
|
+
"execution_count": 89,
|
58
|
+
"id": "b8facf81",
|
59
|
+
"metadata": {},
|
60
|
+
"outputs": [
|
61
|
+
{
|
62
|
+
"data": {
|
63
|
+
"text/html": [
|
64
|
+
"<div>\n",
|
65
|
+
"<style scoped>\n",
|
66
|
+
" .dataframe tbody tr th:only-of-type {\n",
|
67
|
+
" vertical-align: middle;\n",
|
68
|
+
" }\n",
|
69
|
+
"\n",
|
70
|
+
" .dataframe tbody tr th {\n",
|
71
|
+
" vertical-align: top;\n",
|
72
|
+
" }\n",
|
73
|
+
"\n",
|
74
|
+
" .dataframe thead th {\n",
|
75
|
+
" text-align: right;\n",
|
76
|
+
" }\n",
|
77
|
+
"</style>\n",
|
78
|
+
"<table border=\"1\" class=\"dataframe\">\n",
|
79
|
+
" <thead>\n",
|
80
|
+
" <tr style=\"text-align: right;\">\n",
|
81
|
+
" <th></th>\n",
|
82
|
+
" <th></th>\n",
|
83
|
+
" <th>close</th>\n",
|
84
|
+
" </tr>\n",
|
85
|
+
" <tr>\n",
|
86
|
+
" <th>date</th>\n",
|
87
|
+
" <th>ticker</th>\n",
|
88
|
+
" <th></th>\n",
|
89
|
+
" </tr>\n",
|
90
|
+
" </thead>\n",
|
91
|
+
" <tbody>\n",
|
92
|
+
" <tr>\n",
|
93
|
+
" <th>2019-01-31</th>\n",
|
94
|
+
" <th>EURUSD</th>\n",
|
95
|
+
" <td>1.147579</td>\n",
|
96
|
+
" </tr>\n",
|
97
|
+
" <tr>\n",
|
98
|
+
" <th>2019-02-28</th>\n",
|
99
|
+
" <th>EURUSD</th>\n",
|
100
|
+
" <td>1.138693</td>\n",
|
101
|
+
" </tr>\n",
|
102
|
+
" <tr>\n",
|
103
|
+
" <th>2019-03-31</th>\n",
|
104
|
+
" <th>EURUSD</th>\n",
|
105
|
+
" <td>1.122355</td>\n",
|
106
|
+
" </tr>\n",
|
107
|
+
" <tr>\n",
|
108
|
+
" <th>2019-04-30</th>\n",
|
109
|
+
" <th>EURUSD</th>\n",
|
110
|
+
" <td>1.120699</td>\n",
|
111
|
+
" </tr>\n",
|
112
|
+
" <tr>\n",
|
113
|
+
" <th>2019-05-31</th>\n",
|
114
|
+
" <th>EURUSD</th>\n",
|
115
|
+
" <td>1.11433</td>\n",
|
116
|
+
" </tr>\n",
|
117
|
+
" <tr>\n",
|
118
|
+
" <th>...</th>\n",
|
119
|
+
" <th>...</th>\n",
|
120
|
+
" <td>...</td>\n",
|
121
|
+
" </tr>\n",
|
122
|
+
" <tr>\n",
|
123
|
+
" <th>2024-04-30</th>\n",
|
124
|
+
" <th>EURUSD</th>\n",
|
125
|
+
" <td>1.066605</td>\n",
|
126
|
+
" </tr>\n",
|
127
|
+
" <tr>\n",
|
128
|
+
" <th>2024-05-31</th>\n",
|
129
|
+
" <th>EURUSD</th>\n",
|
130
|
+
" <td>1.084825</td>\n",
|
131
|
+
" </tr>\n",
|
132
|
+
" <tr>\n",
|
133
|
+
" <th>2024-06-30</th>\n",
|
134
|
+
" <th>EURUSD</th>\n",
|
135
|
+
" <td>1.073515</td>\n",
|
136
|
+
" </tr>\n",
|
137
|
+
" <tr>\n",
|
138
|
+
" <th>2024-07-31</th>\n",
|
139
|
+
" <th>EURUSD</th>\n",
|
140
|
+
" <td>1.082395</td>\n",
|
141
|
+
" </tr>\n",
|
142
|
+
" <tr>\n",
|
143
|
+
" <th>2024-08-31</th>\n",
|
144
|
+
" <th>EURUSD</th>\n",
|
145
|
+
" <td>1.092375</td>\n",
|
146
|
+
" </tr>\n",
|
147
|
+
" </tbody>\n",
|
148
|
+
"</table>\n",
|
149
|
+
"<p>68 rows × 1 columns</p>\n",
|
150
|
+
"</div>"
|
151
|
+
],
|
152
|
+
"text/plain": [
|
153
|
+
" close\n",
|
154
|
+
"date ticker \n",
|
155
|
+
"2019-01-31 EURUSD 1.147579\n",
|
156
|
+
"2019-02-28 EURUSD 1.138693\n",
|
157
|
+
"2019-03-31 EURUSD 1.122355\n",
|
158
|
+
"2019-04-30 EURUSD 1.120699\n",
|
159
|
+
"2019-05-31 EURUSD 1.11433\n",
|
160
|
+
"... ...\n",
|
161
|
+
"2024-04-30 EURUSD 1.066605\n",
|
162
|
+
"2024-05-31 EURUSD 1.084825\n",
|
163
|
+
"2024-06-30 EURUSD 1.073515\n",
|
164
|
+
"2024-07-31 EURUSD 1.082395\n",
|
165
|
+
"2024-08-31 EURUSD 1.092375\n",
|
166
|
+
"\n",
|
167
|
+
"[68 rows x 1 columns]"
|
168
|
+
]
|
169
|
+
},
|
170
|
+
"execution_count": 89,
|
171
|
+
"metadata": {},
|
172
|
+
"output_type": "execute_result"
|
173
|
+
}
|
174
|
+
],
|
175
|
+
"source": [
|
176
|
+
"fx_df"
|
177
|
+
]
|
178
|
+
},
|
179
|
+
{
|
180
|
+
"cell_type": "code",
|
181
|
+
"execution_count": null,
|
182
|
+
"id": "005404ee",
|
183
|
+
"metadata": {},
|
184
|
+
"outputs": [],
|
185
|
+
"source": []
|
186
|
+
},
|
187
|
+
{
|
188
|
+
"cell_type": "code",
|
189
|
+
"execution_count": null,
|
190
|
+
"id": "8e3dc50d",
|
191
|
+
"metadata": {},
|
192
|
+
"outputs": [],
|
193
|
+
"source": []
|
194
|
+
},
|
195
|
+
{
|
196
|
+
"cell_type": "code",
|
197
|
+
"execution_count": 2,
|
198
|
+
"id": "3cbdeffc",
|
199
|
+
"metadata": {},
|
200
|
+
"outputs": [],
|
201
|
+
"source": [
|
202
|
+
"# get all Binance perp futures tickers\n",
|
203
|
+
"data_req = DataRequest(source='ccxt')\n",
|
204
|
+
"perp_tickers = GetData(data_req).get_meta(method='get_markets_info', exch='binanceusdm', as_list=True)"
|
205
|
+
]
|
206
|
+
},
|
207
|
+
{
|
208
|
+
"cell_type": "code",
|
209
|
+
"execution_count": 3,
|
210
|
+
"id": "3d084cf7",
|
211
|
+
"metadata": {},
|
212
|
+
"outputs": [
|
213
|
+
{
|
214
|
+
"data": {
|
215
|
+
"text/plain": [
|
216
|
+
"314"
|
217
|
+
]
|
218
|
+
},
|
219
|
+
"execution_count": 3,
|
220
|
+
"metadata": {},
|
221
|
+
"output_type": "execute_result"
|
222
|
+
}
|
223
|
+
],
|
224
|
+
"source": [
|
225
|
+
"len(perp_tickers)"
|
226
|
+
]
|
227
|
+
},
|
228
|
+
{
|
229
|
+
"cell_type": "code",
|
230
|
+
"execution_count": 4,
|
231
|
+
"id": "fcb74458",
|
232
|
+
"metadata": {},
|
233
|
+
"outputs": [],
|
234
|
+
"source": [
|
235
|
+
"# get Binance spot tickers\n",
|
236
|
+
"data_req = DataRequest(source='ccxt')\n",
|
237
|
+
"spot_tickers = GetData(data_req).get_meta(method='get_markets_info', exch='binance', as_list=True)"
|
238
|
+
]
|
239
|
+
},
|
240
|
+
{
|
241
|
+
"cell_type": "code",
|
242
|
+
"execution_count": 5,
|
243
|
+
"id": "7962f7e5",
|
244
|
+
"metadata": {},
|
245
|
+
"outputs": [],
|
246
|
+
"source": [
|
247
|
+
"# find intersecting tickers\n",
|
248
|
+
"binance_tickers = [ticker for ticker in perp_tickers if ticker in spot_tickers]"
|
249
|
+
]
|
250
|
+
},
|
251
|
+
{
|
252
|
+
"cell_type": "code",
|
253
|
+
"execution_count": 6,
|
254
|
+
"id": "877811c1",
|
255
|
+
"metadata": {},
|
256
|
+
"outputs": [
|
257
|
+
{
|
258
|
+
"data": {
|
259
|
+
"text/plain": [
|
260
|
+
"284"
|
261
|
+
]
|
262
|
+
},
|
263
|
+
"execution_count": 6,
|
264
|
+
"metadata": {},
|
265
|
+
"output_type": "execute_result"
|
266
|
+
}
|
267
|
+
],
|
268
|
+
"source": [
|
269
|
+
"# number of tickers\n",
|
270
|
+
"len(binance_tickers)"
|
271
|
+
]
|
272
|
+
},
|
273
|
+
{
|
274
|
+
"cell_type": "code",
|
275
|
+
"execution_count": 7,
|
276
|
+
"id": "fe425163",
|
277
|
+
"metadata": {},
|
278
|
+
"outputs": [],
|
279
|
+
"source": [
|
280
|
+
"## # get cryptocompare tickers\n",
|
281
|
+
"data_req = DataRequest(source='cryptocompare')\n",
|
282
|
+
"cc_tickers = GetData(data_req).get_meta(method='get_assets_info', as_list=True)"
|
283
|
+
]
|
284
|
+
},
|
285
|
+
{
|
286
|
+
"cell_type": "code",
|
287
|
+
"execution_count": 8,
|
288
|
+
"id": "165053db",
|
289
|
+
"metadata": {},
|
290
|
+
"outputs": [],
|
291
|
+
"source": [
|
292
|
+
"# keep only USDT ticker\n",
|
293
|
+
"bin_tickers = []\n",
|
294
|
+
"for ticker in binance_tickers:\n",
|
295
|
+
" if '/' in ticker and ticker.split('/')[1] == 'USDT':\n",
|
296
|
+
" bin_tickers.append(ticker.split('/')[0])"
|
297
|
+
]
|
298
|
+
},
|
299
|
+
{
|
300
|
+
"cell_type": "code",
|
301
|
+
"execution_count": 9,
|
302
|
+
"id": "d6cf8a4c",
|
303
|
+
"metadata": {},
|
304
|
+
"outputs": [],
|
305
|
+
"source": [
|
306
|
+
"# usdt tickers\n",
|
307
|
+
"usdt_tickers = [ticker.split('/')[0] for ticker in binance_tickers if '/'in ticker and ticker.split('/')[1] == 'USDT']"
|
308
|
+
]
|
309
|
+
},
|
310
|
+
{
|
311
|
+
"cell_type": "code",
|
312
|
+
"execution_count": 10,
|
313
|
+
"id": "633f7a3e",
|
314
|
+
"metadata": {},
|
315
|
+
"outputs": [],
|
316
|
+
"source": [
|
317
|
+
"# intersecting tickers\n",
|
318
|
+
"tickers = [ticker for ticker in usdt_tickers if ticker in cc_tickers]"
|
319
|
+
]
|
320
|
+
},
|
321
|
+
{
|
322
|
+
"cell_type": "code",
|
323
|
+
"execution_count": 11,
|
324
|
+
"id": "30337a71",
|
325
|
+
"metadata": {},
|
326
|
+
"outputs": [
|
327
|
+
{
|
328
|
+
"data": {
|
329
|
+
"text/plain": [
|
330
|
+
"257"
|
331
|
+
]
|
332
|
+
},
|
333
|
+
"execution_count": 11,
|
334
|
+
"metadata": {},
|
335
|
+
"output_type": "execute_result"
|
336
|
+
}
|
337
|
+
],
|
338
|
+
"source": [
|
339
|
+
"len(tickers)"
|
340
|
+
]
|
341
|
+
},
|
342
|
+
{
|
343
|
+
"cell_type": "markdown",
|
344
|
+
"id": "f80eb97d",
|
345
|
+
"metadata": {},
|
346
|
+
"source": [
|
347
|
+
"### Binance Perp Futures"
|
348
|
+
]
|
349
|
+
},
|
350
|
+
{
|
351
|
+
"cell_type": "code",
|
352
|
+
"execution_count": 12,
|
353
|
+
"id": "49b09508",
|
354
|
+
"metadata": {},
|
355
|
+
"outputs": [],
|
356
|
+
"source": [
|
357
|
+
"# pull daily OHLC and funding rates for perp futures on Binance USDM exchange\n",
|
358
|
+
"data_req = DataRequest(source='ccxt',\n",
|
359
|
+
" tickers=tickers, \n",
|
360
|
+
" fields=['open', 'high', 'low', 'close', 'volume', 'funding_rate'], \n",
|
361
|
+
" mkt_type='perpetual_future', \n",
|
362
|
+
" freq='d')"
|
363
|
+
]
|
364
|
+
},
|
365
|
+
{
|
366
|
+
"cell_type": "code",
|
367
|
+
"execution_count": 13,
|
368
|
+
"id": "6ac9365b",
|
369
|
+
"metadata": {},
|
370
|
+
"outputs": [],
|
371
|
+
"source": [
|
372
|
+
"# df1 = GetData(data_req).get_series()"
|
373
|
+
]
|
374
|
+
},
|
375
|
+
{
|
376
|
+
"cell_type": "code",
|
377
|
+
"execution_count": 14,
|
378
|
+
"id": "98a425b2",
|
379
|
+
"metadata": {},
|
380
|
+
"outputs": [],
|
381
|
+
"source": [
|
382
|
+
"# df1.to_csv('binance_perp_futures.csv')\n",
|
383
|
+
"df1 = pd.read_csv('../../../../factorlab/notebooks/binance_perp_futures.csv', index_col=['date', 'ticker'], parse_dates=['date'])"
|
384
|
+
]
|
385
|
+
},
|
386
|
+
{
|
387
|
+
"cell_type": "code",
|
388
|
+
"execution_count": 15,
|
389
|
+
"id": "0e04da4a",
|
390
|
+
"metadata": {},
|
391
|
+
"outputs": [
|
392
|
+
{
|
393
|
+
"data": {
|
394
|
+
"text/html": [
|
395
|
+
"<div>\n",
|
396
|
+
"<style scoped>\n",
|
397
|
+
" .dataframe tbody tr th:only-of-type {\n",
|
398
|
+
" vertical-align: middle;\n",
|
399
|
+
" }\n",
|
400
|
+
"\n",
|
401
|
+
" .dataframe tbody tr th {\n",
|
402
|
+
" vertical-align: top;\n",
|
403
|
+
" }\n",
|
404
|
+
"\n",
|
405
|
+
" .dataframe thead th {\n",
|
406
|
+
" text-align: right;\n",
|
407
|
+
" }\n",
|
408
|
+
"</style>\n",
|
409
|
+
"<table border=\"1\" class=\"dataframe\">\n",
|
410
|
+
" <thead>\n",
|
411
|
+
" <tr style=\"text-align: right;\">\n",
|
412
|
+
" <th></th>\n",
|
413
|
+
" <th></th>\n",
|
414
|
+
" <th>open</th>\n",
|
415
|
+
" <th>high</th>\n",
|
416
|
+
" <th>low</th>\n",
|
417
|
+
" <th>close</th>\n",
|
418
|
+
" <th>volume</th>\n",
|
419
|
+
" <th>funding_rate</th>\n",
|
420
|
+
" </tr>\n",
|
421
|
+
" <tr>\n",
|
422
|
+
" <th>date</th>\n",
|
423
|
+
" <th>ticker</th>\n",
|
424
|
+
" <th></th>\n",
|
425
|
+
" <th></th>\n",
|
426
|
+
" <th></th>\n",
|
427
|
+
" <th></th>\n",
|
428
|
+
" <th></th>\n",
|
429
|
+
" <th></th>\n",
|
430
|
+
" </tr>\n",
|
431
|
+
" </thead>\n",
|
432
|
+
" <tbody>\n",
|
433
|
+
" <tr>\n",
|
434
|
+
" <th>2019-09-08</th>\n",
|
435
|
+
" <th>BTC</th>\n",
|
436
|
+
" <td>10000.00</td>\n",
|
437
|
+
" <td>10412.65</td>\n",
|
438
|
+
" <td>10000.00</td>\n",
|
439
|
+
" <td>10391.63</td>\n",
|
440
|
+
" <td>3096.291</td>\n",
|
441
|
+
" <td>NaN</td>\n",
|
442
|
+
" </tr>\n",
|
443
|
+
" <tr>\n",
|
444
|
+
" <th>2019-09-09</th>\n",
|
445
|
+
" <th>BTC</th>\n",
|
446
|
+
" <td>10316.62</td>\n",
|
447
|
+
" <td>10475.54</td>\n",
|
448
|
+
" <td>10077.22</td>\n",
|
449
|
+
" <td>10307.00</td>\n",
|
450
|
+
" <td>14824.373</td>\n",
|
451
|
+
" <td>NaN</td>\n",
|
452
|
+
" </tr>\n",
|
453
|
+
" <tr>\n",
|
454
|
+
" <th>2019-09-10</th>\n",
|
455
|
+
" <th>BTC</th>\n",
|
456
|
+
" <td>10307.00</td>\n",
|
457
|
+
" <td>10382.97</td>\n",
|
458
|
+
" <td>9940.87</td>\n",
|
459
|
+
" <td>10102.02</td>\n",
|
460
|
+
" <td>9068.955</td>\n",
|
461
|
+
" <td>0.0002</td>\n",
|
462
|
+
" </tr>\n",
|
463
|
+
" <tr>\n",
|
464
|
+
" <th>2019-09-11</th>\n",
|
465
|
+
" <th>BTC</th>\n",
|
466
|
+
" <td>10094.27</td>\n",
|
467
|
+
" <td>10293.11</td>\n",
|
468
|
+
" <td>9884.31</td>\n",
|
469
|
+
" <td>10159.55</td>\n",
|
470
|
+
" <td>10897.922</td>\n",
|
471
|
+
" <td>0.0003</td>\n",
|
472
|
+
" </tr>\n",
|
473
|
+
" <tr>\n",
|
474
|
+
" <th>2019-09-12</th>\n",
|
475
|
+
" <th>BTC</th>\n",
|
476
|
+
" <td>10163.06</td>\n",
|
477
|
+
" <td>10450.13</td>\n",
|
478
|
+
" <td>10042.12</td>\n",
|
479
|
+
" <td>10415.13</td>\n",
|
480
|
+
" <td>15609.634</td>\n",
|
481
|
+
" <td>0.0003</td>\n",
|
482
|
+
" </tr>\n",
|
483
|
+
" </tbody>\n",
|
484
|
+
"</table>\n",
|
485
|
+
"</div>"
|
486
|
+
],
|
487
|
+
"text/plain": [
|
488
|
+
" open high low close volume \\\n",
|
489
|
+
"date ticker \n",
|
490
|
+
"2019-09-08 BTC 10000.00 10412.65 10000.00 10391.63 3096.291 \n",
|
491
|
+
"2019-09-09 BTC 10316.62 10475.54 10077.22 10307.00 14824.373 \n",
|
492
|
+
"2019-09-10 BTC 10307.00 10382.97 9940.87 10102.02 9068.955 \n",
|
493
|
+
"2019-09-11 BTC 10094.27 10293.11 9884.31 10159.55 10897.922 \n",
|
494
|
+
"2019-09-12 BTC 10163.06 10450.13 10042.12 10415.13 15609.634 \n",
|
495
|
+
"\n",
|
496
|
+
" funding_rate \n",
|
497
|
+
"date ticker \n",
|
498
|
+
"2019-09-08 BTC NaN \n",
|
499
|
+
"2019-09-09 BTC NaN \n",
|
500
|
+
"2019-09-10 BTC 0.0002 \n",
|
501
|
+
"2019-09-11 BTC 0.0003 \n",
|
502
|
+
"2019-09-12 BTC 0.0003 "
|
503
|
+
]
|
504
|
+
},
|
505
|
+
"execution_count": 15,
|
506
|
+
"metadata": {},
|
507
|
+
"output_type": "execute_result"
|
508
|
+
}
|
509
|
+
],
|
510
|
+
"source": [
|
511
|
+
"df1.head()"
|
512
|
+
]
|
513
|
+
},
|
514
|
+
{
|
515
|
+
"cell_type": "markdown",
|
516
|
+
"id": "32f15191",
|
517
|
+
"metadata": {},
|
518
|
+
"source": [
|
519
|
+
"### Binance Spot"
|
520
|
+
]
|
521
|
+
},
|
522
|
+
{
|
523
|
+
"cell_type": "code",
|
524
|
+
"execution_count": 16,
|
525
|
+
"id": "83e9e466",
|
526
|
+
"metadata": {},
|
527
|
+
"outputs": [],
|
528
|
+
"source": [
|
529
|
+
"# pull OHLC from Binance\n",
|
530
|
+
"data_req = DataRequest(source='ccxt',\n",
|
531
|
+
" tickers=tickers, \n",
|
532
|
+
" fields=['open', 'high', 'low', 'close', 'volume'], \n",
|
533
|
+
" freq='d')"
|
534
|
+
]
|
535
|
+
},
|
536
|
+
{
|
537
|
+
"cell_type": "code",
|
538
|
+
"execution_count": 17,
|
539
|
+
"id": "82d4bbc7",
|
540
|
+
"metadata": {},
|
541
|
+
"outputs": [],
|
542
|
+
"source": [
|
543
|
+
"# df2 = GetData(data_req).get_series()"
|
544
|
+
]
|
545
|
+
},
|
546
|
+
{
|
547
|
+
"cell_type": "code",
|
548
|
+
"execution_count": 18,
|
549
|
+
"id": "4f63eb21",
|
550
|
+
"metadata": {},
|
551
|
+
"outputs": [],
|
552
|
+
"source": [
|
553
|
+
"# df2.to_csv('binance_spot.csv')\n",
|
554
|
+
"df2 = pd.read_csv('../../../../factorlab/notebooks/binance_spot.csv', index_col=['date', 'ticker'], parse_dates=['date'])"
|
555
|
+
]
|
556
|
+
},
|
557
|
+
{
|
558
|
+
"cell_type": "code",
|
559
|
+
"execution_count": 19,
|
560
|
+
"id": "ce8929c1",
|
561
|
+
"metadata": {},
|
562
|
+
"outputs": [
|
563
|
+
{
|
564
|
+
"data": {
|
565
|
+
"text/html": [
|
566
|
+
"<div>\n",
|
567
|
+
"<style scoped>\n",
|
568
|
+
" .dataframe tbody tr th:only-of-type {\n",
|
569
|
+
" vertical-align: middle;\n",
|
570
|
+
" }\n",
|
571
|
+
"\n",
|
572
|
+
" .dataframe tbody tr th {\n",
|
573
|
+
" vertical-align: top;\n",
|
574
|
+
" }\n",
|
575
|
+
"\n",
|
576
|
+
" .dataframe thead th {\n",
|
577
|
+
" text-align: right;\n",
|
578
|
+
" }\n",
|
579
|
+
"</style>\n",
|
580
|
+
"<table border=\"1\" class=\"dataframe\">\n",
|
581
|
+
" <thead>\n",
|
582
|
+
" <tr style=\"text-align: right;\">\n",
|
583
|
+
" <th></th>\n",
|
584
|
+
" <th></th>\n",
|
585
|
+
" <th>open</th>\n",
|
586
|
+
" <th>high</th>\n",
|
587
|
+
" <th>low</th>\n",
|
588
|
+
" <th>close</th>\n",
|
589
|
+
" <th>volume</th>\n",
|
590
|
+
" </tr>\n",
|
591
|
+
" <tr>\n",
|
592
|
+
" <th>date</th>\n",
|
593
|
+
" <th>ticker</th>\n",
|
594
|
+
" <th></th>\n",
|
595
|
+
" <th></th>\n",
|
596
|
+
" <th></th>\n",
|
597
|
+
" <th></th>\n",
|
598
|
+
" <th></th>\n",
|
599
|
+
" </tr>\n",
|
600
|
+
" </thead>\n",
|
601
|
+
" <tbody>\n",
|
602
|
+
" <tr>\n",
|
603
|
+
" <th rowspan=\"2\" valign=\"top\">2017-08-17</th>\n",
|
604
|
+
" <th>BTC</th>\n",
|
605
|
+
" <td>4261.48</td>\n",
|
606
|
+
" <td>4485.39</td>\n",
|
607
|
+
" <td>4200.74</td>\n",
|
608
|
+
" <td>4285.08</td>\n",
|
609
|
+
" <td>795.150377</td>\n",
|
610
|
+
" </tr>\n",
|
611
|
+
" <tr>\n",
|
612
|
+
" <th>ETH</th>\n",
|
613
|
+
" <td>301.13</td>\n",
|
614
|
+
" <td>312.18</td>\n",
|
615
|
+
" <td>298.00</td>\n",
|
616
|
+
" <td>302.00</td>\n",
|
617
|
+
" <td>7030.710340</td>\n",
|
618
|
+
" </tr>\n",
|
619
|
+
" <tr>\n",
|
620
|
+
" <th rowspan=\"2\" valign=\"top\">2017-08-18</th>\n",
|
621
|
+
" <th>BTC</th>\n",
|
622
|
+
" <td>4285.08</td>\n",
|
623
|
+
" <td>4371.52</td>\n",
|
624
|
+
" <td>3938.77</td>\n",
|
625
|
+
" <td>4108.37</td>\n",
|
626
|
+
" <td>1199.888264</td>\n",
|
627
|
+
" </tr>\n",
|
628
|
+
" <tr>\n",
|
629
|
+
" <th>ETH</th>\n",
|
630
|
+
" <td>302.00</td>\n",
|
631
|
+
" <td>311.79</td>\n",
|
632
|
+
" <td>283.94</td>\n",
|
633
|
+
" <td>293.96</td>\n",
|
634
|
+
" <td>9537.846460</td>\n",
|
635
|
+
" </tr>\n",
|
636
|
+
" <tr>\n",
|
637
|
+
" <th>2017-08-19</th>\n",
|
638
|
+
" <th>BTC</th>\n",
|
639
|
+
" <td>4108.37</td>\n",
|
640
|
+
" <td>4184.69</td>\n",
|
641
|
+
" <td>3850.00</td>\n",
|
642
|
+
" <td>4139.98</td>\n",
|
643
|
+
" <td>381.309763</td>\n",
|
644
|
+
" </tr>\n",
|
645
|
+
" </tbody>\n",
|
646
|
+
"</table>\n",
|
647
|
+
"</div>"
|
648
|
+
],
|
649
|
+
"text/plain": [
|
650
|
+
" open high low close volume\n",
|
651
|
+
"date ticker \n",
|
652
|
+
"2017-08-17 BTC 4261.48 4485.39 4200.74 4285.08 795.150377\n",
|
653
|
+
" ETH 301.13 312.18 298.00 302.00 7030.710340\n",
|
654
|
+
"2017-08-18 BTC 4285.08 4371.52 3938.77 4108.37 1199.888264\n",
|
655
|
+
" ETH 302.00 311.79 283.94 293.96 9537.846460\n",
|
656
|
+
"2017-08-19 BTC 4108.37 4184.69 3850.00 4139.98 381.309763"
|
657
|
+
]
|
658
|
+
},
|
659
|
+
"execution_count": 19,
|
660
|
+
"metadata": {},
|
661
|
+
"output_type": "execute_result"
|
662
|
+
}
|
663
|
+
],
|
664
|
+
"source": [
|
665
|
+
"df2.head()"
|
666
|
+
]
|
667
|
+
},
|
668
|
+
{
|
669
|
+
"cell_type": "markdown",
|
670
|
+
"id": "05f93b91",
|
671
|
+
"metadata": {},
|
672
|
+
"source": [
|
673
|
+
"### CryptoCompare - Historical Prices"
|
674
|
+
]
|
675
|
+
},
|
676
|
+
{
|
677
|
+
"cell_type": "code",
|
678
|
+
"execution_count": 20,
|
679
|
+
"id": "7f14d874",
|
680
|
+
"metadata": {},
|
681
|
+
"outputs": [],
|
682
|
+
"source": [
|
683
|
+
"# pull OHLC from CryptoCompare\n",
|
684
|
+
"data_req = DataRequest(source='cryptocompare',\n",
|
685
|
+
" tickers=tickers, \n",
|
686
|
+
" fields=['open', 'high', 'low', 'close', 'volume'], \n",
|
687
|
+
" freq='d')"
|
688
|
+
]
|
689
|
+
},
|
690
|
+
{
|
691
|
+
"cell_type": "code",
|
692
|
+
"execution_count": 21,
|
693
|
+
"id": "3a8708d3",
|
694
|
+
"metadata": {},
|
695
|
+
"outputs": [],
|
696
|
+
"source": [
|
697
|
+
"# df3 = GetData(data_req).get_series()"
|
698
|
+
]
|
699
|
+
},
|
700
|
+
{
|
701
|
+
"cell_type": "code",
|
702
|
+
"execution_count": 22,
|
703
|
+
"id": "aa265538",
|
704
|
+
"metadata": {},
|
705
|
+
"outputs": [],
|
706
|
+
"source": [
|
707
|
+
"# df3.to_csv('cc_spot.csv')\n",
|
708
|
+
"df3 = pd.read_csv('../../../../factorlab/notebooks/cc_spot.csv', index_col=['date', 'ticker'], parse_dates=['date'])"
|
709
|
+
]
|
710
|
+
},
|
711
|
+
{
|
712
|
+
"cell_type": "markdown",
|
713
|
+
"id": "5664e968",
|
714
|
+
"metadata": {},
|
715
|
+
"source": [
|
716
|
+
"### Clean Data"
|
717
|
+
]
|
718
|
+
},
|
719
|
+
{
|
720
|
+
"cell_type": "code",
|
721
|
+
"execution_count": 61,
|
722
|
+
"id": "f5ee4f6d",
|
723
|
+
"metadata": {},
|
724
|
+
"outputs": [],
|
725
|
+
"source": [
|
726
|
+
"df = stitch_dataframes([df1, df2, df3])\n",
|
727
|
+
"df.funding_rate = df.funding_rate.fillna(0)"
|
728
|
+
]
|
729
|
+
},
|
730
|
+
{
|
731
|
+
"cell_type": "code",
|
732
|
+
"execution_count": 62,
|
733
|
+
"id": "cbe07c91",
|
734
|
+
"metadata": {},
|
735
|
+
"outputs": [
|
736
|
+
{
|
737
|
+
"data": {
|
738
|
+
"text/html": [
|
739
|
+
"<div>\n",
|
740
|
+
"<style scoped>\n",
|
741
|
+
" .dataframe tbody tr th:only-of-type {\n",
|
742
|
+
" vertical-align: middle;\n",
|
743
|
+
" }\n",
|
744
|
+
"\n",
|
745
|
+
" .dataframe tbody tr th {\n",
|
746
|
+
" vertical-align: top;\n",
|
747
|
+
" }\n",
|
748
|
+
"\n",
|
749
|
+
" .dataframe thead th {\n",
|
750
|
+
" text-align: right;\n",
|
751
|
+
" }\n",
|
752
|
+
"</style>\n",
|
753
|
+
"<table border=\"1\" class=\"dataframe\">\n",
|
754
|
+
" <thead>\n",
|
755
|
+
" <tr style=\"text-align: right;\">\n",
|
756
|
+
" <th></th>\n",
|
757
|
+
" <th></th>\n",
|
758
|
+
" <th>open</th>\n",
|
759
|
+
" <th>high</th>\n",
|
760
|
+
" <th>low</th>\n",
|
761
|
+
" <th>close</th>\n",
|
762
|
+
" <th>volume</th>\n",
|
763
|
+
" <th>funding_rate</th>\n",
|
764
|
+
" </tr>\n",
|
765
|
+
" <tr>\n",
|
766
|
+
" <th>date</th>\n",
|
767
|
+
" <th>ticker</th>\n",
|
768
|
+
" <th></th>\n",
|
769
|
+
" <th></th>\n",
|
770
|
+
" <th></th>\n",
|
771
|
+
" <th></th>\n",
|
772
|
+
" <th></th>\n",
|
773
|
+
" <th></th>\n",
|
774
|
+
" </tr>\n",
|
775
|
+
" </thead>\n",
|
776
|
+
" <tbody>\n",
|
777
|
+
" <tr>\n",
|
778
|
+
" <th>2010-07-17</th>\n",
|
779
|
+
" <th>BTC</th>\n",
|
780
|
+
" <td>0.04951</td>\n",
|
781
|
+
" <td>0.04951</td>\n",
|
782
|
+
" <td>0.04951</td>\n",
|
783
|
+
" <td>0.04951</td>\n",
|
784
|
+
" <td>20.00</td>\n",
|
785
|
+
" <td>0.0</td>\n",
|
786
|
+
" </tr>\n",
|
787
|
+
" <tr>\n",
|
788
|
+
" <th>2010-07-18</th>\n",
|
789
|
+
" <th>BTC</th>\n",
|
790
|
+
" <td>0.04951</td>\n",
|
791
|
+
" <td>0.08585</td>\n",
|
792
|
+
" <td>0.04951</td>\n",
|
793
|
+
" <td>0.08584</td>\n",
|
794
|
+
" <td>75.01</td>\n",
|
795
|
+
" <td>0.0</td>\n",
|
796
|
+
" </tr>\n",
|
797
|
+
" <tr>\n",
|
798
|
+
" <th>2010-07-19</th>\n",
|
799
|
+
" <th>BTC</th>\n",
|
800
|
+
" <td>0.08584</td>\n",
|
801
|
+
" <td>0.09307</td>\n",
|
802
|
+
" <td>0.07723</td>\n",
|
803
|
+
" <td>0.08080</td>\n",
|
804
|
+
" <td>574.00</td>\n",
|
805
|
+
" <td>0.0</td>\n",
|
806
|
+
" </tr>\n",
|
807
|
+
" <tr>\n",
|
808
|
+
" <th>2010-07-20</th>\n",
|
809
|
+
" <th>BTC</th>\n",
|
810
|
+
" <td>0.08080</td>\n",
|
811
|
+
" <td>0.08181</td>\n",
|
812
|
+
" <td>0.07426</td>\n",
|
813
|
+
" <td>0.07474</td>\n",
|
814
|
+
" <td>262.00</td>\n",
|
815
|
+
" <td>0.0</td>\n",
|
816
|
+
" </tr>\n",
|
817
|
+
" <tr>\n",
|
818
|
+
" <th>2010-07-21</th>\n",
|
819
|
+
" <th>BTC</th>\n",
|
820
|
+
" <td>0.07474</td>\n",
|
821
|
+
" <td>0.07921</td>\n",
|
822
|
+
" <td>0.06634</td>\n",
|
823
|
+
" <td>0.07921</td>\n",
|
824
|
+
" <td>575.00</td>\n",
|
825
|
+
" <td>0.0</td>\n",
|
826
|
+
" </tr>\n",
|
827
|
+
" </tbody>\n",
|
828
|
+
"</table>\n",
|
829
|
+
"</div>"
|
830
|
+
],
|
831
|
+
"text/plain": [
|
832
|
+
" open high low close volume funding_rate\n",
|
833
|
+
"date ticker \n",
|
834
|
+
"2010-07-17 BTC 0.04951 0.04951 0.04951 0.04951 20.00 0.0\n",
|
835
|
+
"2010-07-18 BTC 0.04951 0.08585 0.04951 0.08584 75.01 0.0\n",
|
836
|
+
"2010-07-19 BTC 0.08584 0.09307 0.07723 0.08080 574.00 0.0\n",
|
837
|
+
"2010-07-20 BTC 0.08080 0.08181 0.07426 0.07474 262.00 0.0\n",
|
838
|
+
"2010-07-21 BTC 0.07474 0.07921 0.06634 0.07921 575.00 0.0"
|
839
|
+
]
|
840
|
+
},
|
841
|
+
"execution_count": 62,
|
842
|
+
"metadata": {},
|
843
|
+
"output_type": "execute_result"
|
844
|
+
}
|
845
|
+
],
|
846
|
+
"source": [
|
847
|
+
"df.head()"
|
848
|
+
]
|
849
|
+
},
|
850
|
+
{
|
851
|
+
"cell_type": "code",
|
852
|
+
"execution_count": 63,
|
853
|
+
"id": "bcbd3394",
|
854
|
+
"metadata": {},
|
855
|
+
"outputs": [],
|
856
|
+
"source": [
|
857
|
+
"# Filter data\n",
|
858
|
+
"clean_df = CleanData(df).filter_outliers(od_method='mad', excl_cols=['volume', 'funding_rate'], thresh_val=10).\\\n",
|
859
|
+
" repair_outliers(imp_method='fcst').\\\n",
|
860
|
+
" filter_avg_trading_val(thresh_val=1000000).\\\n",
|
861
|
+
" filter_missing_vals_gaps().\\\n",
|
862
|
+
" filter_min_nobs(ts_obs=1000, cs_obs=3).\\\n",
|
863
|
+
" get(attr='df').dropna(how='all')"
|
864
|
+
]
|
865
|
+
},
|
866
|
+
{
|
867
|
+
"cell_type": "code",
|
868
|
+
"execution_count": 64,
|
869
|
+
"id": "66c762a3",
|
870
|
+
"metadata": {},
|
871
|
+
"outputs": [
|
872
|
+
{
|
873
|
+
"data": {
|
874
|
+
"text/html": [
|
875
|
+
"<div>\n",
|
876
|
+
"<style scoped>\n",
|
877
|
+
" .dataframe tbody tr th:only-of-type {\n",
|
878
|
+
" vertical-align: middle;\n",
|
879
|
+
" }\n",
|
880
|
+
"\n",
|
881
|
+
" .dataframe tbody tr th {\n",
|
882
|
+
" vertical-align: top;\n",
|
883
|
+
" }\n",
|
884
|
+
"\n",
|
885
|
+
" .dataframe thead th {\n",
|
886
|
+
" text-align: right;\n",
|
887
|
+
" }\n",
|
888
|
+
"</style>\n",
|
889
|
+
"<table border=\"1\" class=\"dataframe\">\n",
|
890
|
+
" <thead>\n",
|
891
|
+
" <tr style=\"text-align: right;\">\n",
|
892
|
+
" <th></th>\n",
|
893
|
+
" <th></th>\n",
|
894
|
+
" <th>open</th>\n",
|
895
|
+
" <th>high</th>\n",
|
896
|
+
" <th>low</th>\n",
|
897
|
+
" <th>close</th>\n",
|
898
|
+
" <th>volume</th>\n",
|
899
|
+
" <th>funding_rate</th>\n",
|
900
|
+
" </tr>\n",
|
901
|
+
" <tr>\n",
|
902
|
+
" <th>date</th>\n",
|
903
|
+
" <th>ticker</th>\n",
|
904
|
+
" <th></th>\n",
|
905
|
+
" <th></th>\n",
|
906
|
+
" <th></th>\n",
|
907
|
+
" <th></th>\n",
|
908
|
+
" <th></th>\n",
|
909
|
+
" <th></th>\n",
|
910
|
+
" </tr>\n",
|
911
|
+
" </thead>\n",
|
912
|
+
" <tbody>\n",
|
913
|
+
" <tr>\n",
|
914
|
+
" <th rowspan=\"4\" valign=\"top\">2017-03-21</th>\n",
|
915
|
+
" <th>BTC</th>\n",
|
916
|
+
" <td>1047.51</td>\n",
|
917
|
+
" <td>1125.53</td>\n",
|
918
|
+
" <td>1043.87</td>\n",
|
919
|
+
" <td>1121.29</td>\n",
|
920
|
+
" <td>9.259127e+04</td>\n",
|
921
|
+
" <td>0.000000</td>\n",
|
922
|
+
" </tr>\n",
|
923
|
+
" <tr>\n",
|
924
|
+
" <th>ETC</th>\n",
|
925
|
+
" <td>1.867</td>\n",
|
926
|
+
" <td>2.39</td>\n",
|
927
|
+
" <td>1.867</td>\n",
|
928
|
+
" <td>2.378</td>\n",
|
929
|
+
" <td>2.151590e+06</td>\n",
|
930
|
+
" <td>0.000000</td>\n",
|
931
|
+
" </tr>\n",
|
932
|
+
" <tr>\n",
|
933
|
+
" <th>ETH</th>\n",
|
934
|
+
" <td>42.51</td>\n",
|
935
|
+
" <td>43.8</td>\n",
|
936
|
+
" <td>41.68</td>\n",
|
937
|
+
" <td>42.67</td>\n",
|
938
|
+
" <td>4.843660e+05</td>\n",
|
939
|
+
" <td>0.000000</td>\n",
|
940
|
+
" </tr>\n",
|
941
|
+
" <tr>\n",
|
942
|
+
" <th>LTC</th>\n",
|
943
|
+
" <td>4.121</td>\n",
|
944
|
+
" <td>4.155</td>\n",
|
945
|
+
" <td>4.014</td>\n",
|
946
|
+
" <td>4.09</td>\n",
|
947
|
+
" <td>1.932581e+05</td>\n",
|
948
|
+
" <td>0.000000</td>\n",
|
949
|
+
" </tr>\n",
|
950
|
+
" <tr>\n",
|
951
|
+
" <th>2017-03-22</th>\n",
|
952
|
+
" <th>BTC</th>\n",
|
953
|
+
" <td>1121.29</td>\n",
|
954
|
+
" <td>1121.88</td>\n",
|
955
|
+
" <td>997.78</td>\n",
|
956
|
+
" <td>1044.72</td>\n",
|
957
|
+
" <td>1.152861e+05</td>\n",
|
958
|
+
" <td>0.000000</td>\n",
|
959
|
+
" </tr>\n",
|
960
|
+
" <tr>\n",
|
961
|
+
" <th>...</th>\n",
|
962
|
+
" <th>...</th>\n",
|
963
|
+
" <td>...</td>\n",
|
964
|
+
" <td>...</td>\n",
|
965
|
+
" <td>...</td>\n",
|
966
|
+
" <td>...</td>\n",
|
967
|
+
" <td>...</td>\n",
|
968
|
+
" <td>...</td>\n",
|
969
|
+
" </tr>\n",
|
970
|
+
" <tr>\n",
|
971
|
+
" <th rowspan=\"5\" valign=\"top\">2024-08-04</th>\n",
|
972
|
+
" <th>YFI</th>\n",
|
973
|
+
" <td>5341.0</td>\n",
|
974
|
+
" <td>5341.0</td>\n",
|
975
|
+
" <td>5196.0</td>\n",
|
976
|
+
" <td>5198.0</td>\n",
|
977
|
+
" <td>4.281050e+02</td>\n",
|
978
|
+
" <td>0.000169</td>\n",
|
979
|
+
" </tr>\n",
|
980
|
+
" <tr>\n",
|
981
|
+
" <th>ZEC</th>\n",
|
982
|
+
" <td>31.76</td>\n",
|
983
|
+
" <td>34.44</td>\n",
|
984
|
+
" <td>31.28</td>\n",
|
985
|
+
" <td>31.55</td>\n",
|
986
|
+
" <td>1.348085e+06</td>\n",
|
987
|
+
" <td>0.000191</td>\n",
|
988
|
+
" </tr>\n",
|
989
|
+
" <tr>\n",
|
990
|
+
" <th>ZEN</th>\n",
|
991
|
+
" <td>9.657</td>\n",
|
992
|
+
" <td>9.112</td>\n",
|
993
|
+
" <td>8.285</td>\n",
|
994
|
+
" <td>8.462</td>\n",
|
995
|
+
" <td>2.071124e+06</td>\n",
|
996
|
+
" <td>0.000194</td>\n",
|
997
|
+
" </tr>\n",
|
998
|
+
" <tr>\n",
|
999
|
+
" <th>ZIL</th>\n",
|
1000
|
+
" <td>0.01422</td>\n",
|
1001
|
+
" <td>0.01441</td>\n",
|
1002
|
+
" <td>0.01392</td>\n",
|
1003
|
+
" <td>0.01396</td>\n",
|
1004
|
+
" <td>2.048626e+08</td>\n",
|
1005
|
+
" <td>-0.000031</td>\n",
|
1006
|
+
" </tr>\n",
|
1007
|
+
" <tr>\n",
|
1008
|
+
" <th>ZRX</th>\n",
|
1009
|
+
" <td>0.3055</td>\n",
|
1010
|
+
" <td>0.3121</td>\n",
|
1011
|
+
" <td>0.2983</td>\n",
|
1012
|
+
" <td>0.2988</td>\n",
|
1013
|
+
" <td>9.810764e+06</td>\n",
|
1014
|
+
" <td>0.000186</td>\n",
|
1015
|
+
" </tr>\n",
|
1016
|
+
" </tbody>\n",
|
1017
|
+
"</table>\n",
|
1018
|
+
"<p>193002 rows × 6 columns</p>\n",
|
1019
|
+
"</div>"
|
1020
|
+
],
|
1021
|
+
"text/plain": [
|
1022
|
+
" open high low close volume \\\n",
|
1023
|
+
"date ticker \n",
|
1024
|
+
"2017-03-21 BTC 1047.51 1125.53 1043.87 1121.29 9.259127e+04 \n",
|
1025
|
+
" ETC 1.867 2.39 1.867 2.378 2.151590e+06 \n",
|
1026
|
+
" ETH 42.51 43.8 41.68 42.67 4.843660e+05 \n",
|
1027
|
+
" LTC 4.121 4.155 4.014 4.09 1.932581e+05 \n",
|
1028
|
+
"2017-03-22 BTC 1121.29 1121.88 997.78 1044.72 1.152861e+05 \n",
|
1029
|
+
"... ... ... ... ... ... \n",
|
1030
|
+
"2024-08-04 YFI 5341.0 5341.0 5196.0 5198.0 4.281050e+02 \n",
|
1031
|
+
" ZEC 31.76 34.44 31.28 31.55 1.348085e+06 \n",
|
1032
|
+
" ZEN 9.657 9.112 8.285 8.462 2.071124e+06 \n",
|
1033
|
+
" ZIL 0.01422 0.01441 0.01392 0.01396 2.048626e+08 \n",
|
1034
|
+
" ZRX 0.3055 0.3121 0.2983 0.2988 9.810764e+06 \n",
|
1035
|
+
"\n",
|
1036
|
+
" funding_rate \n",
|
1037
|
+
"date ticker \n",
|
1038
|
+
"2017-03-21 BTC 0.000000 \n",
|
1039
|
+
" ETC 0.000000 \n",
|
1040
|
+
" ETH 0.000000 \n",
|
1041
|
+
" LTC 0.000000 \n",
|
1042
|
+
"2017-03-22 BTC 0.000000 \n",
|
1043
|
+
"... ... \n",
|
1044
|
+
"2024-08-04 YFI 0.000169 \n",
|
1045
|
+
" ZEC 0.000191 \n",
|
1046
|
+
" ZEN 0.000194 \n",
|
1047
|
+
" ZIL -0.000031 \n",
|
1048
|
+
" ZRX 0.000186 \n",
|
1049
|
+
"\n",
|
1050
|
+
"[193002 rows x 6 columns]"
|
1051
|
+
]
|
1052
|
+
},
|
1053
|
+
"execution_count": 64,
|
1054
|
+
"metadata": {},
|
1055
|
+
"output_type": "execute_result"
|
1056
|
+
}
|
1057
|
+
],
|
1058
|
+
"source": [
|
1059
|
+
"clean_df"
|
1060
|
+
]
|
1061
|
+
},
|
1062
|
+
{
|
1063
|
+
"cell_type": "code",
|
1064
|
+
"execution_count": 65,
|
1065
|
+
"id": "bec999ba",
|
1066
|
+
"metadata": {},
|
1067
|
+
"outputs": [],
|
1068
|
+
"source": [
|
1069
|
+
"# Filter data\n",
|
1070
|
+
"clean = CleanData(df)"
|
1071
|
+
]
|
1072
|
+
},
|
1073
|
+
{
|
1074
|
+
"cell_type": "code",
|
1075
|
+
"execution_count": 66,
|
1076
|
+
"id": "34372e70",
|
1077
|
+
"metadata": {},
|
1078
|
+
"outputs": [
|
1079
|
+
{
|
1080
|
+
"data": {
|
1081
|
+
"text/plain": [
|
1082
|
+
"<cryptodatapy.transform.clean.CleanData at 0x7face8e7eb50>"
|
1083
|
+
]
|
1084
|
+
},
|
1085
|
+
"execution_count": 66,
|
1086
|
+
"metadata": {},
|
1087
|
+
"output_type": "execute_result"
|
1088
|
+
}
|
1089
|
+
],
|
1090
|
+
"source": [
|
1091
|
+
"clean.filter_outliers(od_method='mad', excl_cols=['volume', 'funding_rate'], thresh_val=10).\\\n",
|
1092
|
+
" repair_outliers(imp_method='fcst').\\\n",
|
1093
|
+
" filter_avg_trading_val(thresh_val=1000000).\\\n",
|
1094
|
+
" filter_missing_vals_gaps().\\\n",
|
1095
|
+
" filter_min_nobs(ts_obs=1000, cs_obs=3)"
|
1096
|
+
]
|
1097
|
+
},
|
1098
|
+
{
|
1099
|
+
"cell_type": "code",
|
1100
|
+
"execution_count": 79,
|
1101
|
+
"id": "ba73590b",
|
1102
|
+
"metadata": {},
|
1103
|
+
"outputs": [
|
1104
|
+
{
|
1105
|
+
"data": {
|
1106
|
+
"text/html": [
|
1107
|
+
"<div>\n",
|
1108
|
+
"<style scoped>\n",
|
1109
|
+
" .dataframe tbody tr th:only-of-type {\n",
|
1110
|
+
" vertical-align: middle;\n",
|
1111
|
+
" }\n",
|
1112
|
+
"\n",
|
1113
|
+
" .dataframe tbody tr th {\n",
|
1114
|
+
" vertical-align: top;\n",
|
1115
|
+
" }\n",
|
1116
|
+
"\n",
|
1117
|
+
" .dataframe thead th {\n",
|
1118
|
+
" text-align: right;\n",
|
1119
|
+
" }\n",
|
1120
|
+
"</style>\n",
|
1121
|
+
"<table border=\"1\" class=\"dataframe\">\n",
|
1122
|
+
" <thead>\n",
|
1123
|
+
" <tr style=\"text-align: right;\">\n",
|
1124
|
+
" <th></th>\n",
|
1125
|
+
" <th>1000SATS</th>\n",
|
1126
|
+
" <th>1INCH</th>\n",
|
1127
|
+
" <th>AAVE</th>\n",
|
1128
|
+
" <th>ACE</th>\n",
|
1129
|
+
" <th>ACH</th>\n",
|
1130
|
+
" <th>ADA</th>\n",
|
1131
|
+
" <th>AEVO</th>\n",
|
1132
|
+
" <th>AGIX</th>\n",
|
1133
|
+
" <th>AGLD</th>\n",
|
1134
|
+
" <th>AI</th>\n",
|
1135
|
+
" <th>...</th>\n",
|
1136
|
+
" <th>XVG</th>\n",
|
1137
|
+
" <th>XVS</th>\n",
|
1138
|
+
" <th>YFI</th>\n",
|
1139
|
+
" <th>YGG</th>\n",
|
1140
|
+
" <th>ZEC</th>\n",
|
1141
|
+
" <th>ZEN</th>\n",
|
1142
|
+
" <th>ZIL</th>\n",
|
1143
|
+
" <th>ZK</th>\n",
|
1144
|
+
" <th>ZRO</th>\n",
|
1145
|
+
" <th>ZRX</th>\n",
|
1146
|
+
" </tr>\n",
|
1147
|
+
" </thead>\n",
|
1148
|
+
" <tbody>\n",
|
1149
|
+
" <tr>\n",
|
1150
|
+
" <th>n_obs</th>\n",
|
1151
|
+
" <td>237.000000</td>\n",
|
1152
|
+
" <td>1319.000000</td>\n",
|
1153
|
+
" <td>1395.000000</td>\n",
|
1154
|
+
" <td>326.000000</td>\n",
|
1155
|
+
" <td>1419.000000</td>\n",
|
1156
|
+
" <td>2500.000000</td>\n",
|
1157
|
+
" <td>278.000000</td>\n",
|
1158
|
+
" <td>536.000000</td>\n",
|
1159
|
+
" <td>1040.000000</td>\n",
|
1160
|
+
" <td>524.000000</td>\n",
|
1161
|
+
" <td>...</td>\n",
|
1162
|
+
" <td>3101.000000</td>\n",
|
1163
|
+
" <td>1399.000000</td>\n",
|
1164
|
+
" <td>1466.000000</td>\n",
|
1165
|
+
" <td>1067.000000</td>\n",
|
1166
|
+
" <td>2838.000000</td>\n",
|
1167
|
+
" <td>2617.000000</td>\n",
|
1168
|
+
" <td>2379.000000</td>\n",
|
1169
|
+
" <td>49.000000</td>\n",
|
1170
|
+
" <td>46.000000</td>\n",
|
1171
|
+
" <td>2551.000000</td>\n",
|
1172
|
+
" </tr>\n",
|
1173
|
+
" <tr>\n",
|
1174
|
+
" <th>%_NaN_start</th>\n",
|
1175
|
+
" <td>95.382817</td>\n",
|
1176
|
+
" <td>74.303526</td>\n",
|
1177
|
+
" <td>72.822911</td>\n",
|
1178
|
+
" <td>93.648938</td>\n",
|
1179
|
+
" <td>72.355348</td>\n",
|
1180
|
+
" <td>51.295539</td>\n",
|
1181
|
+
" <td>94.584064</td>\n",
|
1182
|
+
" <td>89.557763</td>\n",
|
1183
|
+
" <td>79.738944</td>\n",
|
1184
|
+
" <td>89.791545</td>\n",
|
1185
|
+
" <td>...</td>\n",
|
1186
|
+
" <td>39.586986</td>\n",
|
1187
|
+
" <td>72.744983</td>\n",
|
1188
|
+
" <td>71.439704</td>\n",
|
1189
|
+
" <td>79.212936</td>\n",
|
1190
|
+
" <td>44.710695</td>\n",
|
1191
|
+
" <td>49.016170</td>\n",
|
1192
|
+
" <td>53.652835</td>\n",
|
1193
|
+
" <td>99.045393</td>\n",
|
1194
|
+
" <td>99.103838</td>\n",
|
1195
|
+
" <td>50.301968</td>\n",
|
1196
|
+
" </tr>\n",
|
1197
|
+
" <tr>\n",
|
1198
|
+
" <th>%_outliers</th>\n",
|
1199
|
+
" <td>0.038964</td>\n",
|
1200
|
+
" <td>0.642899</td>\n",
|
1201
|
+
" <td>0.370154</td>\n",
|
1202
|
+
" <td>0.253263</td>\n",
|
1203
|
+
" <td>0.584454</td>\n",
|
1204
|
+
" <td>0.876680</td>\n",
|
1205
|
+
" <td>0.331190</td>\n",
|
1206
|
+
" <td>0.253263</td>\n",
|
1207
|
+
" <td>0.526008</td>\n",
|
1208
|
+
" <td>0.253263</td>\n",
|
1209
|
+
" <td>...</td>\n",
|
1210
|
+
" <td>2.824859</td>\n",
|
1211
|
+
" <td>0.642899</td>\n",
|
1212
|
+
" <td>0.389636</td>\n",
|
1213
|
+
" <td>0.467563</td>\n",
|
1214
|
+
" <td>0.857199</td>\n",
|
1215
|
+
" <td>1.207871</td>\n",
|
1216
|
+
" <td>0.974089</td>\n",
|
1217
|
+
" <td>0.000000</td>\n",
|
1218
|
+
" <td>0.019482</td>\n",
|
1219
|
+
" <td>0.993571</td>\n",
|
1220
|
+
" </tr>\n",
|
1221
|
+
" <tr>\n",
|
1222
|
+
" <th>%_imputed</th>\n",
|
1223
|
+
" <td>0.175336</td>\n",
|
1224
|
+
" <td>1.052016</td>\n",
|
1225
|
+
" <td>0.584454</td>\n",
|
1226
|
+
" <td>0.370154</td>\n",
|
1227
|
+
" <td>0.701344</td>\n",
|
1228
|
+
" <td>1.246834</td>\n",
|
1229
|
+
" <td>0.545490</td>\n",
|
1230
|
+
" <td>1.188389</td>\n",
|
1231
|
+
" <td>0.779271</td>\n",
|
1232
|
+
" <td>0.662381</td>\n",
|
1233
|
+
" <td>...</td>\n",
|
1234
|
+
" <td>3.779466</td>\n",
|
1235
|
+
" <td>0.779271</td>\n",
|
1236
|
+
" <td>0.701344</td>\n",
|
1237
|
+
" <td>0.740308</td>\n",
|
1238
|
+
" <td>1.207871</td>\n",
|
1239
|
+
" <td>1.461134</td>\n",
|
1240
|
+
" <td>1.422170</td>\n",
|
1241
|
+
" <td>0.116891</td>\n",
|
1242
|
+
" <td>0.136372</td>\n",
|
1243
|
+
" <td>1.363725</td>\n",
|
1244
|
+
" </tr>\n",
|
1245
|
+
" <tr>\n",
|
1246
|
+
" <th>%_below_avg_trading_val</th>\n",
|
1247
|
+
" <td>0.564972</td>\n",
|
1248
|
+
" <td>0.564972</td>\n",
|
1249
|
+
" <td>0.603935</td>\n",
|
1250
|
+
" <td>1.753361</td>\n",
|
1251
|
+
" <td>6.409507</td>\n",
|
1252
|
+
" <td>0.564972</td>\n",
|
1253
|
+
" <td>2.591077</td>\n",
|
1254
|
+
" <td>1.110462</td>\n",
|
1255
|
+
" <td>1.636470</td>\n",
|
1256
|
+
" <td>6.019871</td>\n",
|
1257
|
+
" <td>...</td>\n",
|
1258
|
+
" <td>41.671537</td>\n",
|
1259
|
+
" <td>4.227547</td>\n",
|
1260
|
+
" <td>0.564972</td>\n",
|
1261
|
+
" <td>1.402688</td>\n",
|
1262
|
+
" <td>4.773037</td>\n",
|
1263
|
+
" <td>17.786869</td>\n",
|
1264
|
+
" <td>9.526593</td>\n",
|
1265
|
+
" <td>0.564972</td>\n",
|
1266
|
+
" <td>0.564972</td>\n",
|
1267
|
+
" <td>12.195597</td>\n",
|
1268
|
+
" </tr>\n",
|
1269
|
+
" <tr>\n",
|
1270
|
+
" <th>%_missing_vals_gaps</th>\n",
|
1271
|
+
" <td>0.000000</td>\n",
|
1272
|
+
" <td>0.000000</td>\n",
|
1273
|
+
" <td>0.000000</td>\n",
|
1274
|
+
" <td>0.019482</td>\n",
|
1275
|
+
" <td>0.019482</td>\n",
|
1276
|
+
" <td>0.000000</td>\n",
|
1277
|
+
" <td>0.000000</td>\n",
|
1278
|
+
" <td>0.000000</td>\n",
|
1279
|
+
" <td>0.000000</td>\n",
|
1280
|
+
" <td>0.000000</td>\n",
|
1281
|
+
" <td>...</td>\n",
|
1282
|
+
" <td>10.325346</td>\n",
|
1283
|
+
" <td>13.598286</td>\n",
|
1284
|
+
" <td>0.000000</td>\n",
|
1285
|
+
" <td>11.903370</td>\n",
|
1286
|
+
" <td>16.540035</td>\n",
|
1287
|
+
" <td>6.916034</td>\n",
|
1288
|
+
" <td>6.623807</td>\n",
|
1289
|
+
" <td>0.000000</td>\n",
|
1290
|
+
" <td>0.000000</td>\n",
|
1291
|
+
" <td>7.305669</td>\n",
|
1292
|
+
" </tr>\n",
|
1293
|
+
" <tr>\n",
|
1294
|
+
" <th>n_tickers_below_min_obs</th>\n",
|
1295
|
+
" <td>129.000000</td>\n",
|
1296
|
+
" <td>129.000000</td>\n",
|
1297
|
+
" <td>129.000000</td>\n",
|
1298
|
+
" <td>129.000000</td>\n",
|
1299
|
+
" <td>129.000000</td>\n",
|
1300
|
+
" <td>129.000000</td>\n",
|
1301
|
+
" <td>129.000000</td>\n",
|
1302
|
+
" <td>129.000000</td>\n",
|
1303
|
+
" <td>129.000000</td>\n",
|
1304
|
+
" <td>129.000000</td>\n",
|
1305
|
+
" <td>...</td>\n",
|
1306
|
+
" <td>129.000000</td>\n",
|
1307
|
+
" <td>129.000000</td>\n",
|
1308
|
+
" <td>129.000000</td>\n",
|
1309
|
+
" <td>129.000000</td>\n",
|
1310
|
+
" <td>129.000000</td>\n",
|
1311
|
+
" <td>129.000000</td>\n",
|
1312
|
+
" <td>129.000000</td>\n",
|
1313
|
+
" <td>129.000000</td>\n",
|
1314
|
+
" <td>129.000000</td>\n",
|
1315
|
+
" <td>129.000000</td>\n",
|
1316
|
+
" </tr>\n",
|
1317
|
+
" </tbody>\n",
|
1318
|
+
"</table>\n",
|
1319
|
+
"<p>7 rows × 256 columns</p>\n",
|
1320
|
+
"</div>"
|
1321
|
+
],
|
1322
|
+
"text/plain": [
|
1323
|
+
" 1000SATS 1INCH AAVE ACE \\\n",
|
1324
|
+
"n_obs 237.000000 1319.000000 1395.000000 326.000000 \n",
|
1325
|
+
"%_NaN_start 95.382817 74.303526 72.822911 93.648938 \n",
|
1326
|
+
"%_outliers 0.038964 0.642899 0.370154 0.253263 \n",
|
1327
|
+
"%_imputed 0.175336 1.052016 0.584454 0.370154 \n",
|
1328
|
+
"%_below_avg_trading_val 0.564972 0.564972 0.603935 1.753361 \n",
|
1329
|
+
"%_missing_vals_gaps 0.000000 0.000000 0.000000 0.019482 \n",
|
1330
|
+
"n_tickers_below_min_obs 129.000000 129.000000 129.000000 129.000000 \n",
|
1331
|
+
"\n",
|
1332
|
+
" ACH ADA AEVO AGIX \\\n",
|
1333
|
+
"n_obs 1419.000000 2500.000000 278.000000 536.000000 \n",
|
1334
|
+
"%_NaN_start 72.355348 51.295539 94.584064 89.557763 \n",
|
1335
|
+
"%_outliers 0.584454 0.876680 0.331190 0.253263 \n",
|
1336
|
+
"%_imputed 0.701344 1.246834 0.545490 1.188389 \n",
|
1337
|
+
"%_below_avg_trading_val 6.409507 0.564972 2.591077 1.110462 \n",
|
1338
|
+
"%_missing_vals_gaps 0.019482 0.000000 0.000000 0.000000 \n",
|
1339
|
+
"n_tickers_below_min_obs 129.000000 129.000000 129.000000 129.000000 \n",
|
1340
|
+
"\n",
|
1341
|
+
" AGLD AI ... XVG \\\n",
|
1342
|
+
"n_obs 1040.000000 524.000000 ... 3101.000000 \n",
|
1343
|
+
"%_NaN_start 79.738944 89.791545 ... 39.586986 \n",
|
1344
|
+
"%_outliers 0.526008 0.253263 ... 2.824859 \n",
|
1345
|
+
"%_imputed 0.779271 0.662381 ... 3.779466 \n",
|
1346
|
+
"%_below_avg_trading_val 1.636470 6.019871 ... 41.671537 \n",
|
1347
|
+
"%_missing_vals_gaps 0.000000 0.000000 ... 10.325346 \n",
|
1348
|
+
"n_tickers_below_min_obs 129.000000 129.000000 ... 129.000000 \n",
|
1349
|
+
"\n",
|
1350
|
+
" XVS YFI YGG ZEC \\\n",
|
1351
|
+
"n_obs 1399.000000 1466.000000 1067.000000 2838.000000 \n",
|
1352
|
+
"%_NaN_start 72.744983 71.439704 79.212936 44.710695 \n",
|
1353
|
+
"%_outliers 0.642899 0.389636 0.467563 0.857199 \n",
|
1354
|
+
"%_imputed 0.779271 0.701344 0.740308 1.207871 \n",
|
1355
|
+
"%_below_avg_trading_val 4.227547 0.564972 1.402688 4.773037 \n",
|
1356
|
+
"%_missing_vals_gaps 13.598286 0.000000 11.903370 16.540035 \n",
|
1357
|
+
"n_tickers_below_min_obs 129.000000 129.000000 129.000000 129.000000 \n",
|
1358
|
+
"\n",
|
1359
|
+
" ZEN ZIL ZK ZRO \\\n",
|
1360
|
+
"n_obs 2617.000000 2379.000000 49.000000 46.000000 \n",
|
1361
|
+
"%_NaN_start 49.016170 53.652835 99.045393 99.103838 \n",
|
1362
|
+
"%_outliers 1.207871 0.974089 0.000000 0.019482 \n",
|
1363
|
+
"%_imputed 1.461134 1.422170 0.116891 0.136372 \n",
|
1364
|
+
"%_below_avg_trading_val 17.786869 9.526593 0.564972 0.564972 \n",
|
1365
|
+
"%_missing_vals_gaps 6.916034 6.623807 0.000000 0.000000 \n",
|
1366
|
+
"n_tickers_below_min_obs 129.000000 129.000000 129.000000 129.000000 \n",
|
1367
|
+
"\n",
|
1368
|
+
" ZRX \n",
|
1369
|
+
"n_obs 2551.000000 \n",
|
1370
|
+
"%_NaN_start 50.301968 \n",
|
1371
|
+
"%_outliers 0.993571 \n",
|
1372
|
+
"%_imputed 1.363725 \n",
|
1373
|
+
"%_below_avg_trading_val 12.195597 \n",
|
1374
|
+
"%_missing_vals_gaps 7.305669 \n",
|
1375
|
+
"n_tickers_below_min_obs 129.000000 \n",
|
1376
|
+
"\n",
|
1377
|
+
"[7 rows x 256 columns]"
|
1378
|
+
]
|
1379
|
+
},
|
1380
|
+
"execution_count": 79,
|
1381
|
+
"metadata": {},
|
1382
|
+
"output_type": "execute_result"
|
1383
|
+
}
|
1384
|
+
],
|
1385
|
+
"source": [
|
1386
|
+
"clean.summary.close"
|
1387
|
+
]
|
1388
|
+
},
|
1389
|
+
{
|
1390
|
+
"cell_type": "code",
|
1391
|
+
"execution_count": 80,
|
1392
|
+
"id": "f89c762c",
|
1393
|
+
"metadata": {},
|
1394
|
+
"outputs": [
|
1395
|
+
{
|
1396
|
+
"data": {
|
1397
|
+
"text/plain": [
|
1398
|
+
"<cryptodatapy.transform.clean.CleanData at 0x7face8e7eb50>"
|
1399
|
+
]
|
1400
|
+
},
|
1401
|
+
"execution_count": 80,
|
1402
|
+
"metadata": {},
|
1403
|
+
"output_type": "execute_result"
|
1404
|
+
}
|
1405
|
+
],
|
1406
|
+
"source": [
|
1407
|
+
"clean.filter_tickers(['BTC'])"
|
1408
|
+
]
|
1409
|
+
},
|
1410
|
+
{
|
1411
|
+
"cell_type": "code",
|
1412
|
+
"execution_count": 85,
|
1413
|
+
"id": "d621e6f3",
|
1414
|
+
"metadata": {},
|
1415
|
+
"outputs": [
|
1416
|
+
{
|
1417
|
+
"data": {
|
1418
|
+
"text/html": [
|
1419
|
+
"<div>\n",
|
1420
|
+
"<style scoped>\n",
|
1421
|
+
" .dataframe tbody tr th:only-of-type {\n",
|
1422
|
+
" vertical-align: middle;\n",
|
1423
|
+
" }\n",
|
1424
|
+
"\n",
|
1425
|
+
" .dataframe tbody tr th {\n",
|
1426
|
+
" vertical-align: top;\n",
|
1427
|
+
" }\n",
|
1428
|
+
"\n",
|
1429
|
+
" .dataframe thead th {\n",
|
1430
|
+
" text-align: right;\n",
|
1431
|
+
" }\n",
|
1432
|
+
"</style>\n",
|
1433
|
+
"<table border=\"1\" class=\"dataframe\">\n",
|
1434
|
+
" <thead>\n",
|
1435
|
+
" <tr style=\"text-align: right;\">\n",
|
1436
|
+
" <th></th>\n",
|
1437
|
+
" <th></th>\n",
|
1438
|
+
" <th>open</th>\n",
|
1439
|
+
" <th>high</th>\n",
|
1440
|
+
" <th>low</th>\n",
|
1441
|
+
" <th>close</th>\n",
|
1442
|
+
" <th>volume</th>\n",
|
1443
|
+
" <th>funding_rate</th>\n",
|
1444
|
+
" </tr>\n",
|
1445
|
+
" <tr>\n",
|
1446
|
+
" <th>date</th>\n",
|
1447
|
+
" <th>ticker</th>\n",
|
1448
|
+
" <th></th>\n",
|
1449
|
+
" <th></th>\n",
|
1450
|
+
" <th></th>\n",
|
1451
|
+
" <th></th>\n",
|
1452
|
+
" <th></th>\n",
|
1453
|
+
" <th></th>\n",
|
1454
|
+
" </tr>\n",
|
1455
|
+
" </thead>\n",
|
1456
|
+
" <tbody>\n",
|
1457
|
+
" <tr>\n",
|
1458
|
+
" <th>2013-09-29</th>\n",
|
1459
|
+
" <th>LTC</th>\n",
|
1460
|
+
" <td>2.56500</td>\n",
|
1461
|
+
" <td>2.59000</td>\n",
|
1462
|
+
" <td>2.59000</td>\n",
|
1463
|
+
" <td>2.59000</td>\n",
|
1464
|
+
" <td>5.000000e+00</td>\n",
|
1465
|
+
" <td>0.000000</td>\n",
|
1466
|
+
" </tr>\n",
|
1467
|
+
" <tr>\n",
|
1468
|
+
" <th>2013-09-30</th>\n",
|
1469
|
+
" <th>LTC</th>\n",
|
1470
|
+
" <td>2.59000</td>\n",
|
1471
|
+
" <td>2.55400</td>\n",
|
1472
|
+
" <td>2.55400</td>\n",
|
1473
|
+
" <td>2.55400</td>\n",
|
1474
|
+
" <td>5.623000e+01</td>\n",
|
1475
|
+
" <td>0.000000</td>\n",
|
1476
|
+
" </tr>\n",
|
1477
|
+
" <tr>\n",
|
1478
|
+
" <th>2013-10-01</th>\n",
|
1479
|
+
" <th>LTC</th>\n",
|
1480
|
+
" <td>2.55400</td>\n",
|
1481
|
+
" <td>2.66600</td>\n",
|
1482
|
+
" <td>2.52500</td>\n",
|
1483
|
+
" <td>2.66600</td>\n",
|
1484
|
+
" <td>1.000000e+00</td>\n",
|
1485
|
+
" <td>0.000000</td>\n",
|
1486
|
+
" </tr>\n",
|
1487
|
+
" <tr>\n",
|
1488
|
+
" <th>2013-10-02</th>\n",
|
1489
|
+
" <th>LTC</th>\n",
|
1490
|
+
" <td>2.66600</td>\n",
|
1491
|
+
" <td>2.33700</td>\n",
|
1492
|
+
" <td>2.33700</td>\n",
|
1493
|
+
" <td>2.33700</td>\n",
|
1494
|
+
" <td>1.500000e+00</td>\n",
|
1495
|
+
" <td>0.000000</td>\n",
|
1496
|
+
" </tr>\n",
|
1497
|
+
" <tr>\n",
|
1498
|
+
" <th>2013-10-03</th>\n",
|
1499
|
+
" <th>LTC</th>\n",
|
1500
|
+
" <td>2.33700</td>\n",
|
1501
|
+
" <td>2.50200</td>\n",
|
1502
|
+
" <td>2.48900</td>\n",
|
1503
|
+
" <td>2.50200</td>\n",
|
1504
|
+
" <td>9.274000e+01</td>\n",
|
1505
|
+
" <td>0.000000</td>\n",
|
1506
|
+
" </tr>\n",
|
1507
|
+
" <tr>\n",
|
1508
|
+
" <th>...</th>\n",
|
1509
|
+
" <th>...</th>\n",
|
1510
|
+
" <td>...</td>\n",
|
1511
|
+
" <td>...</td>\n",
|
1512
|
+
" <td>...</td>\n",
|
1513
|
+
" <td>...</td>\n",
|
1514
|
+
" <td>...</td>\n",
|
1515
|
+
" <td>...</td>\n",
|
1516
|
+
" </tr>\n",
|
1517
|
+
" <tr>\n",
|
1518
|
+
" <th rowspan=\"5\" valign=\"top\">2024-08-04</th>\n",
|
1519
|
+
" <th>ZEN</th>\n",
|
1520
|
+
" <td>8.40600</td>\n",
|
1521
|
+
" <td>9.11200</td>\n",
|
1522
|
+
" <td>8.28500</td>\n",
|
1523
|
+
" <td>8.46200</td>\n",
|
1524
|
+
" <td>2.071124e+06</td>\n",
|
1525
|
+
" <td>0.000194</td>\n",
|
1526
|
+
" </tr>\n",
|
1527
|
+
" <tr>\n",
|
1528
|
+
" <th>ZIL</th>\n",
|
1529
|
+
" <td>0.01422</td>\n",
|
1530
|
+
" <td>0.01441</td>\n",
|
1531
|
+
" <td>0.01392</td>\n",
|
1532
|
+
" <td>0.01396</td>\n",
|
1533
|
+
" <td>2.048626e+08</td>\n",
|
1534
|
+
" <td>-0.000031</td>\n",
|
1535
|
+
" </tr>\n",
|
1536
|
+
" <tr>\n",
|
1537
|
+
" <th>ZK</th>\n",
|
1538
|
+
" <td>0.11451</td>\n",
|
1539
|
+
" <td>0.11673</td>\n",
|
1540
|
+
" <td>0.10857</td>\n",
|
1541
|
+
" <td>0.10874</td>\n",
|
1542
|
+
" <td>3.833253e+08</td>\n",
|
1543
|
+
" <td>0.000200</td>\n",
|
1544
|
+
" </tr>\n",
|
1545
|
+
" <tr>\n",
|
1546
|
+
" <th>ZRO</th>\n",
|
1547
|
+
" <td>3.63100</td>\n",
|
1548
|
+
" <td>3.64800</td>\n",
|
1549
|
+
" <td>3.36200</td>\n",
|
1550
|
+
" <td>3.36700</td>\n",
|
1551
|
+
" <td>7.049472e+07</td>\n",
|
1552
|
+
" <td>0.000184</td>\n",
|
1553
|
+
" </tr>\n",
|
1554
|
+
" <tr>\n",
|
1555
|
+
" <th>ZRX</th>\n",
|
1556
|
+
" <td>0.30550</td>\n",
|
1557
|
+
" <td>0.31210</td>\n",
|
1558
|
+
" <td>0.29830</td>\n",
|
1559
|
+
" <td>0.29880</td>\n",
|
1560
|
+
" <td>9.810764e+06</td>\n",
|
1561
|
+
" <td>0.000186</td>\n",
|
1562
|
+
" </tr>\n",
|
1563
|
+
" </tbody>\n",
|
1564
|
+
"</table>\n",
|
1565
|
+
"<p>387494 rows × 6 columns</p>\n",
|
1566
|
+
"</div>"
|
1567
|
+
],
|
1568
|
+
"text/plain": [
|
1569
|
+
" open high low close volume \\\n",
|
1570
|
+
"date ticker \n",
|
1571
|
+
"2013-09-29 LTC 2.56500 2.59000 2.59000 2.59000 5.000000e+00 \n",
|
1572
|
+
"2013-09-30 LTC 2.59000 2.55400 2.55400 2.55400 5.623000e+01 \n",
|
1573
|
+
"2013-10-01 LTC 2.55400 2.66600 2.52500 2.66600 1.000000e+00 \n",
|
1574
|
+
"2013-10-02 LTC 2.66600 2.33700 2.33700 2.33700 1.500000e+00 \n",
|
1575
|
+
"2013-10-03 LTC 2.33700 2.50200 2.48900 2.50200 9.274000e+01 \n",
|
1576
|
+
"... ... ... ... ... ... \n",
|
1577
|
+
"2024-08-04 ZEN 8.40600 9.11200 8.28500 8.46200 2.071124e+06 \n",
|
1578
|
+
" ZIL 0.01422 0.01441 0.01392 0.01396 2.048626e+08 \n",
|
1579
|
+
" ZK 0.11451 0.11673 0.10857 0.10874 3.833253e+08 \n",
|
1580
|
+
" ZRO 3.63100 3.64800 3.36200 3.36700 7.049472e+07 \n",
|
1581
|
+
" ZRX 0.30550 0.31210 0.29830 0.29880 9.810764e+06 \n",
|
1582
|
+
"\n",
|
1583
|
+
" funding_rate \n",
|
1584
|
+
"date ticker \n",
|
1585
|
+
"2013-09-29 LTC 0.000000 \n",
|
1586
|
+
"2013-09-30 LTC 0.000000 \n",
|
1587
|
+
"2013-10-01 LTC 0.000000 \n",
|
1588
|
+
"2013-10-02 LTC 0.000000 \n",
|
1589
|
+
"2013-10-03 LTC 0.000000 \n",
|
1590
|
+
"... ... \n",
|
1591
|
+
"2024-08-04 ZEN 0.000194 \n",
|
1592
|
+
" ZIL -0.000031 \n",
|
1593
|
+
" ZK 0.000200 \n",
|
1594
|
+
" ZRO 0.000184 \n",
|
1595
|
+
" ZRX 0.000186 \n",
|
1596
|
+
"\n",
|
1597
|
+
"[387494 rows x 6 columns]"
|
1598
|
+
]
|
1599
|
+
},
|
1600
|
+
"execution_count": 85,
|
1601
|
+
"metadata": {},
|
1602
|
+
"output_type": "execute_result"
|
1603
|
+
}
|
1604
|
+
],
|
1605
|
+
"source": [
|
1606
|
+
"df.drop(['BTC'], level=1, axis=0)"
|
1607
|
+
]
|
1608
|
+
},
|
1609
|
+
{
|
1610
|
+
"cell_type": "code",
|
1611
|
+
"execution_count": null,
|
1612
|
+
"id": "fabfa152",
|
1613
|
+
"metadata": {},
|
1614
|
+
"outputs": [],
|
1615
|
+
"source": []
|
1616
|
+
}
|
1617
|
+
],
|
1618
|
+
"metadata": {
|
1619
|
+
"kernelspec": {
|
1620
|
+
"display_name": "cryptodatapy",
|
1621
|
+
"language": "python",
|
1622
|
+
"name": "cryptodatapy"
|
1623
|
+
},
|
1624
|
+
"language_info": {
|
1625
|
+
"codemirror_mode": {
|
1626
|
+
"name": "ipython",
|
1627
|
+
"version": 3
|
1628
|
+
},
|
1629
|
+
"file_extension": ".py",
|
1630
|
+
"mimetype": "text/x-python",
|
1631
|
+
"name": "python",
|
1632
|
+
"nbconvert_exporter": "python",
|
1633
|
+
"pygments_lexer": "ipython3",
|
1634
|
+
"version": "3.9.12"
|
1635
|
+
}
|
1636
|
+
},
|
1637
|
+
"nbformat": 4,
|
1638
|
+
"nbformat_minor": 5
|
1639
|
+
}
|