8
8
import datetime
9
9
import json
10
10
from random import randint
11
- from tqdm import tqdm
12
11
13
12
import pandas as pd
14
13
import pkg_resources
@@ -77,8 +76,7 @@ def get_recent_data(equity, as_json=False, order='ascending'):
77
76
if pkg_resources .resource_exists (resource_package , resource_path ):
78
77
equities = pd .read_csv (pkg_resources .resource_filename (resource_package , resource_path ))
79
78
else :
80
- names = ts .get_equity_names ()
81
- equities = pd .DataFrame (names )
79
+ equities = pd .DataFrame (ts .get_equity_names ())
82
80
83
81
if equities is None :
84
82
raise IOError ("ERR#001: equities object not found or unable to retrieve." )
@@ -108,7 +106,7 @@ def get_recent_data(equity, as_json=False, order='ascending'):
108
106
result = list ()
109
107
110
108
if path_ :
111
- for elements_ in tqdm ( path_ , ascii = True , ncols = 80 ) :
109
+ for elements_ in path_ :
112
110
info = []
113
111
for nested_ in elements_ .xpath (".//td" ):
114
112
info .append (nested_ .text_content ())
@@ -234,8 +232,7 @@ def get_historical_data(equity, start, end, as_json=False, order='ascending'):
234
232
if pkg_resources .resource_exists (resource_package , resource_path ):
235
233
equities = pd .read_csv (pkg_resources .resource_filename (resource_package , resource_path ))
236
234
else :
237
- names = ts .get_equity_names ()
238
- equities = pd .DataFrame (names )
235
+ equities = pd .DataFrame (ts .get_equity_names ())
239
236
240
237
if equities is None :
241
238
raise IOError ("ERR#001: equities object not found or unable to retrieve." )
@@ -299,7 +296,7 @@ def get_historical_data(equity, start, end, as_json=False, order='ascending'):
299
296
result = list ()
300
297
301
298
if path_ :
302
- for elements_ in tqdm ( path_ , ascii = True , ncols = 80 ) :
299
+ for elements_ in path_ :
303
300
info = []
304
301
for nested_ in elements_ .xpath (".//td" ):
305
302
info .append (nested_ .text_content ())
@@ -350,11 +347,6 @@ def get_historical_data(equity, start, end, as_json=False, order='ascending'):
350
347
else :
351
348
continue
352
349
353
- if as_json is True :
354
- return {}
355
- elif as_json is False :
356
- return pd .DataFrame ()
357
-
358
350
359
351
def get_equity_company_profile (equity , language = 'english' ):
360
352
"""
@@ -392,8 +384,7 @@ def get_equity_company_profile(equity, language='english'):
392
384
if pkg_resources .resource_exists (resource_package , resource_path ):
393
385
equities = pd .read_csv (pkg_resources .resource_filename (resource_package , resource_path ))
394
386
else :
395
- names = ts .get_equity_names ()
396
- equities = pd .DataFrame (names )
387
+ equities = pd .DataFrame (ts .get_equity_names ())
397
388
398
389
if equities is None :
399
390
raise IOError ("ERR#001: equities object not found or unable to retrieve." )
@@ -537,8 +528,7 @@ def get_fund_recent_data(fund, as_json=False, order='ascending'):
537
528
if pkg_resources .resource_exists (resource_package , resource_path ):
538
529
funds = pd .read_csv (pkg_resources .resource_filename (resource_package , resource_path ))
539
530
else :
540
- names = fs .get_fund_names ()
541
- funds = pd .DataFrame (names )
531
+ funds = pd .DataFrame (fs .get_fund_names ())
542
532
543
533
if funds is None :
544
534
raise IOError ("ERR#005: funds object not found or unable to retrieve." )
@@ -568,7 +558,7 @@ def get_fund_recent_data(fund, as_json=False, order='ascending'):
568
558
result = list ()
569
559
570
560
if path_ :
571
- for elements_ in tqdm ( path_ , ascii = True , ncols = 80 ) :
561
+ for elements_ in path_ :
572
562
info = []
573
563
for nested_ in elements_ .xpath (".//td" ):
574
564
info .append (nested_ .text_content ())
@@ -686,8 +676,7 @@ def get_fund_historical_data(fund, start, end, as_json=False, order='ascending')
686
676
if pkg_resources .resource_exists (resource_package , resource_path ):
687
677
funds = pd .read_csv (pkg_resources .resource_filename (resource_package , resource_path ))
688
678
else :
689
- names = fs .get_fund_names ()
690
- funds = pd .DataFrame (names )
679
+ funds = pd .DataFrame (fs .get_fund_names ())
691
680
692
681
if funds is None :
693
682
raise IOError ("ERR#005: funds object not found or unable to retrieve." )
@@ -734,7 +723,7 @@ def get_fund_historical_data(fund, start, end, as_json=False, order='ascending')
734
723
result = list ()
735
724
736
725
if path_ :
737
- for elements_ in tqdm ( path_ , ascii = True , ncols = 80 ) :
726
+ for elements_ in path_ :
738
727
info = []
739
728
for nested_ in elements_ .xpath (".//td" ):
740
729
info .append (nested_ .text_content ())
@@ -777,11 +766,6 @@ def get_fund_historical_data(fund, start, end, as_json=False, order='ascending')
777
766
else :
778
767
continue
779
768
780
- if as_json is True :
781
- return {}
782
- elif as_json is False :
783
- return pd .DataFrame ()
784
-
785
769
786
770
def get_fund_information (fund , as_json = False ):
787
771
"""
@@ -808,8 +792,7 @@ def get_fund_information(fund, as_json=False):
808
792
if pkg_resources .resource_exists (resource_package , resource_path ):
809
793
funds = pd .read_csv (pkg_resources .resource_filename (resource_package , resource_path ))
810
794
else :
811
- names = fs .get_fund_names ()
812
- funds = pd .DataFrame (names )
795
+ funds = pd .DataFrame (fs .get_fund_names ())
813
796
814
797
if funds is None :
815
798
raise IOError ("ERR#005: funds object not found or unable to retrieve." )
@@ -989,8 +972,7 @@ def get_etf_recent_data(etf, as_json=False, order='ascending'):
989
972
if pkg_resources .resource_exists (resource_package , resource_path ):
990
973
etfs = pd .read_csv (pkg_resources .resource_filename (resource_package , resource_path ))
991
974
else :
992
- names = es .get_etf_names ()
993
- etfs = pd .DataFrame (names )
975
+ etfs = pd .DataFrame (es .get_etf_names ())
994
976
995
977
if etfs is None :
996
978
raise IOError ("ERR#009: etfs object not found or unable to retrieve." )
@@ -1020,7 +1002,7 @@ def get_etf_recent_data(etf, as_json=False, order='ascending'):
1020
1002
result = list ()
1021
1003
1022
1004
if path_ :
1023
- for elements_ in tqdm ( path_ , ascii = True , ncols = 80 ) :
1005
+ for elements_ in path_ :
1024
1006
info = []
1025
1007
for nested_ in elements_ .xpath (".//td" ):
1026
1008
info .append (nested_ .text_content ())
@@ -1138,8 +1120,7 @@ def get_etf_historical_data(etf, start, end, as_json=False, order='ascending'):
1138
1120
if pkg_resources .resource_exists (resource_package , resource_path ):
1139
1121
etfs = pd .read_csv (pkg_resources .resource_filename (resource_package , resource_path ))
1140
1122
else :
1141
- names = es .get_etf_names ()
1142
- etfs = pd .DataFrame (names )
1123
+ etfs = pd .DataFrame (es .get_etf_names ())
1143
1124
1144
1125
if etfs is None :
1145
1126
raise IOError ("ERR#009: etfs object not found or unable to retrieve." )
@@ -1186,7 +1167,7 @@ def get_etf_historical_data(etf, start, end, as_json=False, order='ascending'):
1186
1167
result = list ()
1187
1168
1188
1169
if path_ :
1189
- for elements_ in tqdm ( path_ , ascii = True , ncols = 80 ) :
1170
+ for elements_ in path_ :
1190
1171
info = []
1191
1172
for nested_ in elements_ .xpath (".//td" ):
1192
1173
info .append (nested_ .text_content ())
@@ -1228,8 +1209,3 @@ def get_etf_historical_data(etf, start, end, as_json=False, order='ascending'):
1228
1209
return pd .concat (final )
1229
1210
else :
1230
1211
continue
1231
-
1232
- if as_json is True :
1233
- return {}
1234
- elif as_json is False :
1235
- return pd .DataFrame ()
0 commit comments