cryptodatapy 0.2.5__py3-none-any.whl → 0.2.7__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/conf/fields.csv +1 -1
- cryptodatapy/conf/tickers.csv +0 -1
- cryptodatapy/extract/data_vendors/CoinMetrics.ipynb +747 -0
- cryptodatapy/extract/data_vendors/coinmetrics_api.py +279 -209
- cryptodatapy/extract/data_vendors/cryptocompare_api.py +3 -5
- cryptodatapy/extract/data_vendors/datavendor.py +32 -12
- cryptodatapy/extract/data_vendors/glassnode_api.py +3 -2
- cryptodatapy/extract/data_vendors/tiingo_api.py +3 -2
- cryptodatapy/extract/datarequest.py +197 -36
- cryptodatapy/extract/libraries/Untitled.ipynb +33 -0
- cryptodatapy/extract/libraries/ccxt.ipynb +628 -754
- cryptodatapy/extract/libraries/ccxt_api.py +630 -346
- cryptodatapy/extract/libraries/pandasdr_api.py +13 -12
- cryptodatapy/extract/libraries/yfinance_api.py +511 -0
- cryptodatapy/transform/cc_onchain_data.csv +118423 -0
- cryptodatapy/transform/clean.py +17 -15
- cryptodatapy/transform/clean_onchain_data.ipynb +4750 -0
- cryptodatapy/transform/clean_perp_futures_ohlcv.ipynb +1712 -1097
- cryptodatapy/transform/cmdty_data.ipynb +402 -0
- cryptodatapy/transform/convertparams.py +139 -181
- cryptodatapy/transform/credit_data.ipynb +291 -0
- cryptodatapy/transform/eqty_data.ipynb +836 -0
- cryptodatapy/transform/filter.py +13 -10
- cryptodatapy/transform/global_credit_data_daily.parquet +0 -0
- cryptodatapy/transform/od.py +1 -0
- cryptodatapy/transform/rates_data.ipynb +465 -0
- cryptodatapy/transform/us_rates_daily.csv +227752 -0
- cryptodatapy/transform/wrangle.py +109 -20
- cryptodatapy/util/datacredentials.py +28 -7
- {cryptodatapy-0.2.5.dist-info → cryptodatapy-0.2.7.dist-info}/METADATA +10 -7
- {cryptodatapy-0.2.5.dist-info → cryptodatapy-0.2.7.dist-info}/RECORD +33 -31
- {cryptodatapy-0.2.5.dist-info → cryptodatapy-0.2.7.dist-info}/WHEEL +1 -1
- cryptodatapy/.DS_Store +0 -0
- cryptodatapy/.idea/.gitignore +0 -3
- cryptodatapy/.idea/cryptodatapy.iml +0 -12
- cryptodatapy/.idea/csv-plugin.xml +0 -16
- cryptodatapy/.idea/inspectionProfiles/Project_Default.xml +0 -6
- cryptodatapy/.idea/inspectionProfiles/profiles_settings.xml +0 -6
- cryptodatapy/.idea/misc.xml +0 -4
- cryptodatapy/.idea/modules.xml +0 -8
- cryptodatapy/.idea/vcs.xml +0 -6
- {cryptodatapy-0.2.5.dist-info → cryptodatapy-0.2.7.dist-info}/LICENSE +0 -0
@@ -13,10 +13,7 @@ class ConvertParams:
|
|
13
13
|
Converts data request parameters from CryptoDataPy to data source format.
|
14
14
|
"""
|
15
15
|
|
16
|
-
def __init__(
|
17
|
-
self,
|
18
|
-
data_req: DataRequest = None,
|
19
|
-
):
|
16
|
+
def __init__(self, data_req: DataRequest):
|
20
17
|
"""
|
21
18
|
Constructor
|
22
19
|
|
@@ -24,7 +21,6 @@ class ConvertParams:
|
|
24
21
|
----------
|
25
22
|
data_req: DataRequest
|
26
23
|
Parameters of data request in CryptoDataPy format.
|
27
|
-
|
28
24
|
"""
|
29
25
|
self.data_req = data_req
|
30
26
|
|
@@ -69,7 +65,7 @@ class ConvertParams:
|
|
69
65
|
start_date = round(pd.Timestamp(self.data_req.start_date).timestamp())
|
70
66
|
# convert end date
|
71
67
|
if self.data_req.end_date is None:
|
72
|
-
end_date = round(pd.Timestamp
|
68
|
+
end_date = round(pd.Timestamp.utcnow()).timestamp()
|
73
69
|
else:
|
74
70
|
end_date = round(pd.Timestamp(self.data_req.end_date).timestamp())
|
75
71
|
# fields
|
@@ -108,7 +104,6 @@ class ConvertParams:
|
|
108
104
|
def to_coinmetrics(self) -> Dict[str, Union[list, str, int, float, None]]:
|
109
105
|
"""
|
110
106
|
Convert tickers from CryptoDataPy to CoinMetrics format.
|
111
|
-
|
112
107
|
"""
|
113
108
|
# convert tickers
|
114
109
|
if self.data_req.source_tickers is not None:
|
@@ -121,10 +116,12 @@ class ConvertParams:
|
|
121
116
|
freq = self.data_req.source_freq
|
122
117
|
self.data_req.freq = self.data_req.source_freq
|
123
118
|
else:
|
124
|
-
if self.data_req.freq
|
119
|
+
if self.data_req.freq is None:
|
120
|
+
freq = "1d"
|
121
|
+
elif self.data_req.freq == "block":
|
125
122
|
freq = "1b"
|
126
123
|
elif self.data_req.freq == "tick":
|
127
|
-
freq = "
|
124
|
+
freq = "raw"
|
128
125
|
elif self.data_req.freq[-1] == "s":
|
129
126
|
freq = "1s"
|
130
127
|
elif self.data_req.freq[-3:] == "min":
|
@@ -226,6 +223,16 @@ class ConvertParams:
|
|
226
223
|
+ "-"
|
227
224
|
+ "future"
|
228
225
|
)
|
226
|
+
# start date
|
227
|
+
if self.data_req.start_date is not None:
|
228
|
+
start_date = self.data_req.start_date.strftime('%Y-%m-%d')
|
229
|
+
else:
|
230
|
+
start_date = None
|
231
|
+
# end date
|
232
|
+
if self.data_req.end_date is not None:
|
233
|
+
end_date = self.data_req.end_date.strftime('%Y-%m-%d')
|
234
|
+
else:
|
235
|
+
end_date = None
|
229
236
|
|
230
237
|
return {
|
231
238
|
"tickers": tickers,
|
@@ -235,8 +242,8 @@ class ConvertParams:
|
|
235
242
|
"ctys": None,
|
236
243
|
"mkt_type": self.data_req.mkt_type,
|
237
244
|
"mkts": mkts_list,
|
238
|
-
"start_date":
|
239
|
-
"end_date":
|
245
|
+
"start_date": start_date,
|
246
|
+
"end_date": end_date,
|
240
247
|
"fields": fields,
|
241
248
|
"tz": tz,
|
242
249
|
"inst": inst,
|
@@ -251,7 +258,6 @@ class ConvertParams:
|
|
251
258
|
def to_glassnode(self) -> Dict[str, Union[list, str, int, float, None]]:
|
252
259
|
"""
|
253
260
|
Convert tickers from CryptoDataPy to Glassnode format.
|
254
|
-
|
255
261
|
"""
|
256
262
|
# convert tickers
|
257
263
|
if self.data_req.source_tickers is not None:
|
@@ -264,7 +270,9 @@ class ConvertParams:
|
|
264
270
|
freq = self.data_req.source_freq
|
265
271
|
self.data_req.freq = self.data_req.source_freq
|
266
272
|
else:
|
267
|
-
if self.data_req.freq
|
273
|
+
if self.data_req.freq is None:
|
274
|
+
freq = "24h"
|
275
|
+
elif self.data_req.freq[-3:] == "min":
|
268
276
|
freq = "10m"
|
269
277
|
elif self.data_req.freq[-1] == "h":
|
270
278
|
freq = "1h"
|
@@ -275,7 +283,7 @@ class ConvertParams:
|
|
275
283
|
elif self.data_req.freq == "m":
|
276
284
|
freq = "1month"
|
277
285
|
else:
|
278
|
-
freq =
|
286
|
+
freq = "24h"
|
279
287
|
# convert quote ccy
|
280
288
|
if self.data_req.quote_ccy is None:
|
281
289
|
quote_ccy = "USD"
|
@@ -334,7 +342,6 @@ class ConvertParams:
|
|
334
342
|
def to_tiingo(self) -> Dict[str, Union[list, str, int, float, datetime, None]]:
|
335
343
|
"""
|
336
344
|
Convert tickers from CryptoDataPy to Tiingo format.
|
337
|
-
|
338
345
|
"""
|
339
346
|
# convert tickers
|
340
347
|
if self.data_req.source_tickers is not None:
|
@@ -347,7 +354,9 @@ class ConvertParams:
|
|
347
354
|
freq = self.data_req.source_freq
|
348
355
|
self.data_req.freq = self.data_req.source_freq
|
349
356
|
else:
|
350
|
-
if self.data_req.freq
|
357
|
+
if self.data_req.freq is None:
|
358
|
+
freq = "1day"
|
359
|
+
elif self.data_req.freq[-3:] == "min":
|
351
360
|
freq = self.data_req.freq
|
352
361
|
elif self.data_req.freq[-1] == "h":
|
353
362
|
freq = "1hour"
|
@@ -388,7 +397,7 @@ class ConvertParams:
|
|
388
397
|
start_date = self.data_req.start_date
|
389
398
|
# convert end date
|
390
399
|
if self.data_req.end_date is None:
|
391
|
-
end_date =
|
400
|
+
end_date = pd.Timestamp.utcnow()
|
392
401
|
else:
|
393
402
|
end_date = self.data_req.end_date
|
394
403
|
# convert fields
|
@@ -424,154 +433,113 @@ class ConvertParams:
|
|
424
433
|
"source_fields": self.data_req.source_fields,
|
425
434
|
}
|
426
435
|
|
427
|
-
def to_ccxt(self) ->
|
436
|
+
def to_ccxt(self) -> DataRequest:
|
428
437
|
"""
|
429
438
|
Convert tickers from CryptoDataPy to CCXT format.
|
430
439
|
"""
|
431
|
-
#
|
432
|
-
if self.data_req.source_tickers is
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
else:
|
442
|
-
if self.data_req.freq == "tick":
|
443
|
-
freq = "tick"
|
440
|
+
# tickers
|
441
|
+
if self.data_req.source_tickers is None:
|
442
|
+
self.data_req.source_tickers = [ticker.upper() for ticker in self.data_req.tickers]
|
443
|
+
|
444
|
+
# freq
|
445
|
+
if self.data_req.source_freq is None:
|
446
|
+
if self.data_req.freq is None:
|
447
|
+
self.data_req.source_freq = "1d"
|
448
|
+
elif self.data_req.freq == "tick":
|
449
|
+
self.data_req.source_freq = "tick"
|
444
450
|
elif self.data_req.freq[-3:] == "min":
|
445
|
-
|
446
|
-
elif self.data_req.freq == "
|
447
|
-
|
451
|
+
self.data_req.source_freq = self.data_req.freq.replace("min", "m")
|
452
|
+
elif self.data_req.freq[-1] == "h":
|
453
|
+
self.data_req.source_freq = self.data_req.freq
|
448
454
|
elif self.data_req.freq == "w":
|
449
|
-
|
455
|
+
self.data_req.source_freq = "1w"
|
450
456
|
elif self.data_req.freq == "m":
|
451
|
-
|
457
|
+
self.data_req.source_freq = "1M"
|
452
458
|
elif self.data_req.freq[-1] == "m":
|
453
|
-
|
459
|
+
self.data_req.source_freq = self.data_req.freq.replace("m", "M")
|
454
460
|
elif self.data_req.freq == "q":
|
455
|
-
|
461
|
+
self.data_req.source_freq = "1q"
|
456
462
|
elif self.data_req.freq == "y":
|
457
|
-
|
463
|
+
self.data_req.source_freq = "1y"
|
458
464
|
else:
|
459
|
-
|
460
|
-
|
465
|
+
self.data_req.source_freq = "1d"
|
466
|
+
|
467
|
+
# quote ccy
|
461
468
|
if self.data_req.quote_ccy is None:
|
462
|
-
quote_ccy = "USDT"
|
469
|
+
self.data_req.quote_ccy = "USDT"
|
463
470
|
else:
|
464
|
-
quote_ccy = self.data_req.quote_ccy.upper()
|
465
|
-
|
471
|
+
self.data_req.quote_ccy = self.data_req.quote_ccy.upper()
|
472
|
+
|
473
|
+
# exch
|
466
474
|
if self.data_req.mkt_type == "perpetual_future" and (
|
467
475
|
self.data_req.exch is None or self.data_req.exch == "binance"
|
468
476
|
):
|
469
|
-
exch = "binanceusdm"
|
477
|
+
self.data_req.exch = "binanceusdm"
|
470
478
|
elif self.data_req.exch is None:
|
471
|
-
exch = "binance"
|
479
|
+
self.data_req.exch = "binance"
|
472
480
|
elif (
|
473
481
|
self.data_req.exch == "kucoin"
|
474
482
|
and self.data_req.mkt_type == "perpetual_future"
|
475
483
|
):
|
476
|
-
exch = "kucoinfutures"
|
484
|
+
self.data_req.exch = "kucoinfutures"
|
477
485
|
elif (
|
478
486
|
self.data_req.exch == "huobi"
|
479
487
|
and self.data_req.mkt_type == "perpetual_future"
|
480
488
|
):
|
481
|
-
exch = "huobipro"
|
489
|
+
self.data_req.exch = "huobipro"
|
482
490
|
elif (
|
483
491
|
self.data_req.exch == "bitfinex"
|
484
492
|
and self.data_req.mkt_type == "perpetual_future"
|
485
493
|
):
|
486
|
-
exch = "bitfinex2"
|
494
|
+
self.data_req.exch = "bitfinex2"
|
487
495
|
elif (
|
488
496
|
self.data_req.exch == "mexc"
|
489
497
|
and self.data_req.mkt_type == "perpetual_future"
|
490
498
|
):
|
491
|
-
exch = "mexc3"
|
499
|
+
self.data_req.exch = "mexc3"
|
492
500
|
else:
|
493
|
-
exch = self.data_req.exch.lower()
|
494
|
-
|
495
|
-
|
496
|
-
if self.data_req.
|
497
|
-
|
501
|
+
self.data_req.exch = self.data_req.exch.lower()
|
502
|
+
|
503
|
+
# markets
|
504
|
+
if self.data_req.source_markets is None:
|
505
|
+
if self.data_req.mkt_type == "spot":
|
506
|
+
self.data_req.source_markets = [ticker + "/" + self.data_req.quote_ccy
|
507
|
+
for ticker in self.data_req.source_tickers]
|
508
|
+
elif self.data_req.mkt_type == "perpetual_future":
|
509
|
+
self.data_req.source_markets = [ticker + "/" + self.data_req.quote_ccy + ":" + self.data_req.quote_ccy
|
510
|
+
for ticker in self.data_req.source_tickers]
|
498
511
|
else:
|
499
|
-
for
|
500
|
-
|
501
|
-
|
502
|
-
elif self.data_req.mkt_type == "perpetual_future":
|
503
|
-
if exch == "binanceusdm":
|
504
|
-
mkts_list.append(ticker.upper() + "/" + quote_ccy.upper())
|
505
|
-
elif (
|
506
|
-
exch == "ftx"
|
507
|
-
or exch == "okx"
|
508
|
-
or exch == "kucoinfutures"
|
509
|
-
or exch == "huobipro"
|
510
|
-
or exch == "cryptocom"
|
511
|
-
or exch == "bitfinex2"
|
512
|
-
or exch == "bybit"
|
513
|
-
or exch == "mexc3"
|
514
|
-
or exch == "aax"
|
515
|
-
or exch == "bitmex"
|
516
|
-
):
|
517
|
-
mkts_list.append(
|
518
|
-
ticker.upper()
|
519
|
-
+ "/"
|
520
|
-
+ quote_ccy.upper()
|
521
|
-
+ ":"
|
522
|
-
+ quote_ccy.upper()
|
523
|
-
)
|
524
|
-
# convert start date
|
512
|
+
self.data_req.source_tickers = [market.split("/")[0] for market in self.data_req.source_markets]
|
513
|
+
|
514
|
+
# start date
|
525
515
|
if self.data_req.start_date is None:
|
526
|
-
|
516
|
+
self.data_req.source_start_date = round(
|
527
517
|
pd.Timestamp("2010-01-01 00:00:00").timestamp() * 1e3
|
528
518
|
)
|
529
519
|
else:
|
530
|
-
|
520
|
+
self.data_req.source_start_date = round(
|
531
521
|
pd.Timestamp(self.data_req.start_date).timestamp() * 1e3
|
532
522
|
)
|
533
|
-
|
523
|
+
|
524
|
+
# end date
|
534
525
|
if self.data_req.end_date is None:
|
535
|
-
|
536
|
-
else:
|
537
|
-
end_date = round(pd.Timestamp(self.data_req.end_date).timestamp() * 1e3)
|
538
|
-
# convert fields
|
539
|
-
if self.data_req.source_fields is not None:
|
540
|
-
fields = self.data_req.source_fields
|
541
|
-
self.data_req.fields = self.data_req.source_fields
|
526
|
+
self.data_req.source_end_date = round(pd.Timestamp.utcnow().timestamp() * 1e3)
|
542
527
|
else:
|
543
|
-
|
528
|
+
self.data_req.source_end_date = round(pd.Timestamp(self.data_req.end_date).timestamp() * 1e3)
|
529
|
+
|
530
|
+
# fields
|
531
|
+
if self.data_req.source_fields is None:
|
532
|
+
self.data_req.source_fields = self.convert_fields(data_source='ccxt')
|
533
|
+
|
544
534
|
# tz
|
545
535
|
if self.data_req.tz is None:
|
546
|
-
tz = "UTC"
|
547
|
-
else:
|
548
|
-
tz = self.data_req.tz
|
536
|
+
self.data_req.tz = "UTC"
|
549
537
|
|
550
|
-
return
|
551
|
-
"tickers": tickers,
|
552
|
-
"freq": freq,
|
553
|
-
"quote_ccy": quote_ccy,
|
554
|
-
"exch": exch,
|
555
|
-
"ctys": None,
|
556
|
-
"mkt_type": self.data_req.mkt_type,
|
557
|
-
"mkts": mkts_list,
|
558
|
-
"start_date": start_date,
|
559
|
-
"end_date": end_date,
|
560
|
-
"fields": fields,
|
561
|
-
"tz": tz,
|
562
|
-
"inst": None,
|
563
|
-
"cat": 'crypto',
|
564
|
-
"trials": self.data_req.trials,
|
565
|
-
"pause": self.data_req.pause,
|
566
|
-
"source_tickers": self.data_req.source_tickers,
|
567
|
-
"source_freq": self.data_req.source_freq,
|
568
|
-
"source_fields": self.data_req.source_fields,
|
569
|
-
}
|
538
|
+
return self.data_req
|
570
539
|
|
571
540
|
def to_dbnomics(self) -> Dict[str, Union[list, str, int, float, None]]:
|
572
541
|
"""
|
573
542
|
Convert tickers from CryptoDataPy to DBnomics format.
|
574
|
-
|
575
543
|
"""
|
576
544
|
# convert tickers
|
577
545
|
with resources.path("cryptodatapy.conf", "tickers.csv") as f:
|
@@ -682,7 +650,7 @@ class ConvertParams:
|
|
682
650
|
start_date = pd.Timestamp(self.data_req.start_date).strftime("%d/%m/%Y")
|
683
651
|
# convert end date
|
684
652
|
if self.data_req.end_date is None:
|
685
|
-
end_date =
|
653
|
+
end_date = pd.Timestamp.utcnow().strftime("%d/%m/%Y")
|
686
654
|
else:
|
687
655
|
end_date = pd.Timestamp(self.data_req.end_date).strftime("%d/%m/%Y")
|
688
656
|
# convert fields
|
@@ -716,7 +684,6 @@ class ConvertParams:
|
|
716
684
|
def to_fred(self) -> Dict[str, Union[list, str, int, float, datetime, None]]:
|
717
685
|
"""
|
718
686
|
Convert tickers from CryptoDataPy to Fred format.
|
719
|
-
|
720
687
|
"""
|
721
688
|
# convert tickers
|
722
689
|
with resources.path("cryptodatapy.conf", "tickers.csv") as f:
|
@@ -751,7 +718,7 @@ class ConvertParams:
|
|
751
718
|
start_date = self.data_req.start_date
|
752
719
|
# end date
|
753
720
|
if self.data_req.end_date is None:
|
754
|
-
end_date =
|
721
|
+
end_date = pd.Timestamp.utcnow()
|
755
722
|
else:
|
756
723
|
end_date = self.data_req.end_date
|
757
724
|
# fields
|
@@ -790,7 +757,6 @@ class ConvertParams:
|
|
790
757
|
def to_wb(self) -> Dict[str, Union[list, str, int, float, datetime, None]]:
|
791
758
|
"""
|
792
759
|
Convert tickers from CryptoDataPy to Yahoo Finance format.
|
793
|
-
|
794
760
|
"""
|
795
761
|
# convert tickers
|
796
762
|
with resources.path("cryptodatapy.conf", "tickers.csv") as f:
|
@@ -842,7 +808,7 @@ class ConvertParams:
|
|
842
808
|
start_date = int(self.data_req.start_date.year)
|
843
809
|
# end date
|
844
810
|
if self.data_req.end_date is None:
|
845
|
-
end_date =
|
811
|
+
end_date = pd.Timestamp.utcnow().year
|
846
812
|
else:
|
847
813
|
end_date = int(self.data_req.end_date.year)
|
848
814
|
# fields
|
@@ -876,80 +842,72 @@ class ConvertParams:
|
|
876
842
|
def to_yahoo(self) -> Dict[str, Union[list, str, int, float, datetime, None]]:
|
877
843
|
"""
|
878
844
|
Convert tickers from CryptoDataPy to Yahoo Finance format.
|
879
|
-
|
880
845
|
"""
|
881
|
-
#
|
846
|
+
# tickers
|
882
847
|
with resources.path("cryptodatapy.conf", "tickers.csv") as f:
|
883
848
|
tickers_path = f
|
884
849
|
tickers_df, tickers = pd.read_csv(tickers_path, index_col=0, encoding="latin1"), []
|
885
850
|
|
886
|
-
if self.data_req.source_tickers is
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
self.data_req.freq = self.data_req.source_freq
|
907
|
-
else:
|
908
|
-
freq = self.data_req.freq
|
909
|
-
# convert quote ccy
|
910
|
-
quote_ccy = self.data_req.quote_ccy
|
851
|
+
if self.data_req.source_tickers is None:
|
852
|
+
if self.data_req.cat == 'eqty':
|
853
|
+
self.data_req.source_tickers = [ticker.upper() for ticker in self.data_req.tickers]
|
854
|
+
else:
|
855
|
+
self.data_req.source_tickers = []
|
856
|
+
for ticker in self.data_req.tickers:
|
857
|
+
if self.data_req.cat == 'fx':
|
858
|
+
ticker = ticker.upper()
|
859
|
+
try:
|
860
|
+
self.data_req.source_tickers.append(tickers_df.loc[ticker, "yahoo_id"])
|
861
|
+
except KeyError:
|
862
|
+
logging.warning(
|
863
|
+
f"{ticker} not found for Yahoo Finance data source. Check tickers in"
|
864
|
+
f" data catalog and try again."
|
865
|
+
)
|
866
|
+
|
867
|
+
# freq
|
868
|
+
if self.data_req.source_freq is None:
|
869
|
+
self.data_req.source_freq = self.data_req.freq
|
870
|
+
|
911
871
|
# start date
|
912
872
|
if self.data_req.start_date is None:
|
913
|
-
|
873
|
+
self.data_req.source_start_date = '1920-01-01'
|
914
874
|
else:
|
915
|
-
|
875
|
+
self.data_req.source_start_date = self.data_req.start_date
|
876
|
+
|
916
877
|
# end date
|
917
878
|
if self.data_req.end_date is None:
|
918
|
-
|
879
|
+
self.data_req.source_end_date = pd.Timestamp.utcnow().strftime('%Y-%m-%d')
|
919
880
|
else:
|
920
|
-
|
881
|
+
self.data_req.source_end_date = self.data_req.end_date
|
882
|
+
|
921
883
|
# fields
|
922
|
-
if self.data_req.source_fields is
|
923
|
-
|
924
|
-
|
925
|
-
else:
|
926
|
-
fields = self.convert_fields(data_source='yahoo')
|
884
|
+
if self.data_req.source_fields is None:
|
885
|
+
self.data_req.source_fields = self.convert_fields(data_source='yahoo')
|
886
|
+
|
927
887
|
# tz
|
928
888
|
if self.data_req.tz is None:
|
929
|
-
tz = "America/New_York"
|
930
|
-
else:
|
931
|
-
tz = self.data_req.tz
|
889
|
+
self.data_req.tz = "America/New_York"
|
932
890
|
|
933
|
-
return {
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
}
|
891
|
+
# return {
|
892
|
+
# "tickers": tickers,
|
893
|
+
# "freq": freq,
|
894
|
+
# "quote_ccy": quote_ccy,
|
895
|
+
# "exch": self.data_req.exch,
|
896
|
+
# "ctys": None,
|
897
|
+
# "mkt_type": self.data_req.mkt_type,
|
898
|
+
# "mkts": None,
|
899
|
+
# "start_date": start_date,
|
900
|
+
# "end_date": end_date,
|
901
|
+
# "fields": fields,
|
902
|
+
# "tz": tz,
|
903
|
+
# "inst": None,
|
904
|
+
# "cat": self.data_req.cat,
|
905
|
+
# "trials": self.data_req.trials,
|
906
|
+
# "pause": self.data_req.pause,
|
907
|
+
# "source_tickers": self.data_req.source_tickers,
|
908
|
+
# "source_freq": self.data_req.source_freq,
|
909
|
+
# "source_fields": self.data_req.source_fields,
|
910
|
+
# }
|
953
911
|
|
954
912
|
def to_famafrench(self) -> Dict[str, Union[list, str, int, float, datetime, None]]:
|
955
913
|
"""
|
@@ -988,7 +946,7 @@ class ConvertParams:
|
|
988
946
|
start_date = self.data_req.start_date
|
989
947
|
# end date
|
990
948
|
if self.data_req.end_date is None:
|
991
|
-
end_date =
|
949
|
+
end_date = pd.Timestamp.utcnow().date()
|
992
950
|
else:
|
993
951
|
end_date = self.data_req.end_date
|
994
952
|
|