Skip to content

Commit 9369c2f

Browse files
author
alvarob96
committed
updated tests/, tqdm removed & release setup
tests updated to improve code coverage when retrieving data from intervals over 20 years removed return statements that are lines missed because previous checks avoid them tqdm package removed as it is not necessary and it can also be annoying (even though it can be useful when testing functions) setup.py, requirements.txtm README.md and .travis.yml updated to fit new release version 0.8.4.8 additionally notebooks/ have been removed as improves, proposals and changes tests need to be done in another repo or branch so as no to interfere in investpy package
1 parent a092919 commit 9369c2f

14 files changed

+358
-18710
lines changed

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ __pycache__/
99
.tox
1010
.cache
1111
.pytest_cache
12-
*.pyc
12+
*.pyc
13+
.DS_Store

Diff for: .idea/workspace.xml

+309-166
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .travis.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ install:
1111
- pip install pandas==0.24.2
1212
- pip install requests==2.22.0
1313
- pip install lxml==4.3.3
14-
- pip install unidecode==1.0.23
15-
- pip install tqdm==4.32.1
16-
- pip install investpy==0.8.4.7
14+
- pip install Unidecode==1.0.23
15+
- pip install investpy==0.8.4.8
1716
- pip install pytest==4.5.0
1817
- pip install codecov==2.0.15
1918
- pip install pytest-cov==2.7.1

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ To conclude this section, I am in the need to specify that this is not the final
2020

2121
In order to get this package working you will need to install [**investpy**](https://pypi.org/project/investpy/) from PyPi via Terminal typing:
2222

23-
``pip install investpy==0.8.4.7``
23+
``pip install investpy==0.8.4.8``
2424

2525
All the dependencies are already listed on the setup file of the package, but to sum them up, you will need the following requirements:
2626

Diff for: investpy/__init__.py

+14-38
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import datetime
99
import json
1010
from random import randint
11-
from tqdm import tqdm
1211

1312
import pandas as pd
1413
import pkg_resources
@@ -77,8 +76,7 @@ def get_recent_data(equity, as_json=False, order='ascending'):
7776
if pkg_resources.resource_exists(resource_package, resource_path):
7877
equities = pd.read_csv(pkg_resources.resource_filename(resource_package, resource_path))
7978
else:
80-
names = ts.get_equity_names()
81-
equities = pd.DataFrame(names)
79+
equities = pd.DataFrame(ts.get_equity_names())
8280

8381
if equities is None:
8482
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'):
108106
result = list()
109107

110108
if path_:
111-
for elements_ in tqdm(path_, ascii=True, ncols=80):
109+
for elements_ in path_:
112110
info = []
113111
for nested_ in elements_.xpath(".//td"):
114112
info.append(nested_.text_content())
@@ -234,8 +232,7 @@ def get_historical_data(equity, start, end, as_json=False, order='ascending'):
234232
if pkg_resources.resource_exists(resource_package, resource_path):
235233
equities = pd.read_csv(pkg_resources.resource_filename(resource_package, resource_path))
236234
else:
237-
names = ts.get_equity_names()
238-
equities = pd.DataFrame(names)
235+
equities = pd.DataFrame(ts.get_equity_names())
239236

240237
if equities is None:
241238
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'):
299296
result = list()
300297

301298
if path_:
302-
for elements_ in tqdm(path_, ascii=True, ncols=80):
299+
for elements_ in path_:
303300
info = []
304301
for nested_ in elements_.xpath(".//td"):
305302
info.append(nested_.text_content())
@@ -350,11 +347,6 @@ def get_historical_data(equity, start, end, as_json=False, order='ascending'):
350347
else:
351348
continue
352349

353-
if as_json is True:
354-
return {}
355-
elif as_json is False:
356-
return pd.DataFrame()
357-
358350

359351
def get_equity_company_profile(equity, language='english'):
360352
"""
@@ -392,8 +384,7 @@ def get_equity_company_profile(equity, language='english'):
392384
if pkg_resources.resource_exists(resource_package, resource_path):
393385
equities = pd.read_csv(pkg_resources.resource_filename(resource_package, resource_path))
394386
else:
395-
names = ts.get_equity_names()
396-
equities = pd.DataFrame(names)
387+
equities = pd.DataFrame(ts.get_equity_names())
397388

398389
if equities is None:
399390
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'):
537528
if pkg_resources.resource_exists(resource_package, resource_path):
538529
funds = pd.read_csv(pkg_resources.resource_filename(resource_package, resource_path))
539530
else:
540-
names = fs.get_fund_names()
541-
funds = pd.DataFrame(names)
531+
funds = pd.DataFrame(fs.get_fund_names())
542532

543533
if funds is None:
544534
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'):
568558
result = list()
569559

570560
if path_:
571-
for elements_ in tqdm(path_, ascii=True, ncols=80):
561+
for elements_ in path_:
572562
info = []
573563
for nested_ in elements_.xpath(".//td"):
574564
info.append(nested_.text_content())
@@ -686,8 +676,7 @@ def get_fund_historical_data(fund, start, end, as_json=False, order='ascending')
686676
if pkg_resources.resource_exists(resource_package, resource_path):
687677
funds = pd.read_csv(pkg_resources.resource_filename(resource_package, resource_path))
688678
else:
689-
names = fs.get_fund_names()
690-
funds = pd.DataFrame(names)
679+
funds = pd.DataFrame(fs.get_fund_names())
691680

692681
if funds is None:
693682
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')
734723
result = list()
735724

736725
if path_:
737-
for elements_ in tqdm(path_, ascii=True, ncols=80):
726+
for elements_ in path_:
738727
info = []
739728
for nested_ in elements_.xpath(".//td"):
740729
info.append(nested_.text_content())
@@ -777,11 +766,6 @@ def get_fund_historical_data(fund, start, end, as_json=False, order='ascending')
777766
else:
778767
continue
779768

780-
if as_json is True:
781-
return {}
782-
elif as_json is False:
783-
return pd.DataFrame()
784-
785769

786770
def get_fund_information(fund, as_json=False):
787771
"""
@@ -808,8 +792,7 @@ def get_fund_information(fund, as_json=False):
808792
if pkg_resources.resource_exists(resource_package, resource_path):
809793
funds = pd.read_csv(pkg_resources.resource_filename(resource_package, resource_path))
810794
else:
811-
names = fs.get_fund_names()
812-
funds = pd.DataFrame(names)
795+
funds = pd.DataFrame(fs.get_fund_names())
813796

814797
if funds is None:
815798
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'):
989972
if pkg_resources.resource_exists(resource_package, resource_path):
990973
etfs = pd.read_csv(pkg_resources.resource_filename(resource_package, resource_path))
991974
else:
992-
names = es.get_etf_names()
993-
etfs = pd.DataFrame(names)
975+
etfs = pd.DataFrame(es.get_etf_names())
994976

995977
if etfs is None:
996978
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'):
10201002
result = list()
10211003

10221004
if path_:
1023-
for elements_ in tqdm(path_, ascii=True, ncols=80):
1005+
for elements_ in path_:
10241006
info = []
10251007
for nested_ in elements_.xpath(".//td"):
10261008
info.append(nested_.text_content())
@@ -1138,8 +1120,7 @@ def get_etf_historical_data(etf, start, end, as_json=False, order='ascending'):
11381120
if pkg_resources.resource_exists(resource_package, resource_path):
11391121
etfs = pd.read_csv(pkg_resources.resource_filename(resource_package, resource_path))
11401122
else:
1141-
names = es.get_etf_names()
1142-
etfs = pd.DataFrame(names)
1123+
etfs = pd.DataFrame(es.get_etf_names())
11431124

11441125
if etfs is None:
11451126
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'):
11861167
result = list()
11871168

11881169
if path_:
1189-
for elements_ in tqdm(path_, ascii=True, ncols=80):
1170+
for elements_ in path_:
11901171
info = []
11911172
for nested_ in elements_.xpath(".//td"):
11921173
info.append(nested_.text_content())
@@ -1228,8 +1209,3 @@ def get_etf_historical_data(etf, start, end, as_json=False, order='ascending'):
12281209
return pd.concat(final)
12291210
else:
12301211
continue
1231-
1232-
if as_json is True:
1233-
return {}
1234-
elif as_json is False:
1235-
return pd.DataFrame()

Diff for: investpy/equities.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import pkg_resources
1212
import requests
1313
from lxml.html import fromstring
14-
from tqdm import tqdm
1514

1615
from investpy import user_agent as ua
1716

@@ -57,7 +56,7 @@ def get_equity_names():
5756
results = list()
5857

5958
if path_:
60-
for elements_ in tqdm(path_, ascii=True, ncols=80):
59+
for elements_ in path_:
6160
id_ = elements_.get('id').replace('pair_', '')
6261

6362
for element_ in elements_.xpath('.//a'):
@@ -153,8 +152,7 @@ def get_equities():
153152
if pkg_resources.resource_exists(resource_package, resource_path):
154153
equities = pd.read_csv(pkg_resources.resource_filename(resource_package, resource_path))
155154
else:
156-
names = get_equity_names()
157-
equities = pd.DataFrame(names)
155+
equities = pd.DataFrame(get_equity_names())
158156

159157
if equities is None:
160158
raise IOError("ERR#001: equities list not found or unable to retrieve.")
@@ -177,8 +175,7 @@ def list_equities():
177175
if pkg_resources.resource_exists(resource_package, resource_path):
178176
equities = pd.read_csv(pkg_resources.resource_filename(resource_package, resource_path))
179177
else:
180-
names = get_equity_names()
181-
equities = pd.DataFrame(names)
178+
equities = pd.DataFrame(get_equity_names())
182179

183180
if equities is None:
184181
raise IOError("ERR#001: equities list not found or unable to retrieve.")

Diff for: investpy/etfs.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import pkg_resources
1212
import requests
1313
from lxml.html import fromstring
14-
from tqdm import tqdm
1514

1615
from investpy import user_agent as ua
1716

@@ -49,7 +48,7 @@ def get_etf_names():
4948
results = list()
5049

5150
if path_:
52-
for elements_ in tqdm(path_, ascii=True, ncols=80):
51+
for elements_ in path_:
5352
id_ = elements_.get('id').replace('pair_', '')
5453
symbol = elements_.xpath(".//td[contains(@class, 'symbol')]")[0].get('title')
5554

@@ -98,8 +97,7 @@ def get_etfs():
9897
if pkg_resources.resource_exists(resource_package, resource_path):
9998
etfs = pd.read_csv(pkg_resources.resource_filename(resource_package, resource_path))
10099
else:
101-
names = get_etf_names()
102-
etfs = pd.DataFrame(names)
100+
etfs = pd.DataFrame(get_etf_names())
103101

104102
if etfs is None:
105103
raise IOError("ERR#009: etf list not found or unable to retrieve.")
@@ -122,8 +120,7 @@ def list_etfs():
122120
if pkg_resources.resource_exists(resource_package, resource_path):
123121
etfs = pd.read_csv(pkg_resources.resource_filename(resource_package, resource_path))
124122
else:
125-
names = get_etf_names()
126-
etfs = pd.DataFrame(names)
123+
etfs = pd.DataFrame(get_etf_names())
127124

128125
if etfs is None:
129126
raise IOError("ERR#009: etf list not found or unable to retrieve.")
@@ -156,8 +153,7 @@ def dict_etfs(columns=None, as_json=False):
156153
if pkg_resources.resource_exists(resource_package, resource_path):
157154
etfs = pd.read_csv(pkg_resources.resource_filename(resource_package, resource_path))
158155
else:
159-
names = get_etf_names()
160-
etfs = pd.DataFrame(names)
156+
etfs = pd.DataFrame(get_etf_names())
161157

162158
if etfs is None:
163159
raise IOError("ERR#009: etf list not found or unable to retrieve.")

Diff for: investpy/funds.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import pkg_resources
1212
import requests
1313
from lxml.html import fromstring
14-
from tqdm import tqdm
1514

1615
from investpy import user_agent as ua
1716

@@ -49,7 +48,7 @@ def get_fund_names():
4948
results = list()
5049

5150
if path_:
52-
for elements_ in tqdm(path_, ascii=True, ncols=80):
51+
for elements_ in path_:
5352
id_ = elements_.get('id').replace('pair_', '')
5453
symbol = elements_.xpath(".//td[contains(@class, 'symbol')]")[0].get('title')
5554

@@ -210,8 +209,7 @@ def get_funds():
210209
if pkg_resources.resource_exists(resource_package, resource_path):
211210
funds = pd.read_csv(pkg_resources.resource_filename(resource_package, resource_path))
212211
else:
213-
names = get_fund_names()
214-
funds = pd.DataFrame(names)
212+
funds = pd.DataFrame(get_fund_names())
215213

216214
if funds is None:
217215
raise IOError("ERR#005: fund list not found or unable to retrieve.")
@@ -234,8 +232,7 @@ def list_funds():
234232
if pkg_resources.resource_exists(resource_package, resource_path):
235233
funds = pd.read_csv(pkg_resources.resource_filename(resource_package, resource_path))
236234
else:
237-
names = get_fund_names()
238-
funds = pd.DataFrame(names)
235+
funds = pd.DataFrame(get_fund_names())
239236

240237
if funds is None:
241238
raise IOError("ERR#005: fund list not found or unable to retrieve.")
@@ -268,8 +265,7 @@ def dict_funds(columns=None, as_json=False):
268265
if pkg_resources.resource_exists(resource_package, resource_path):
269266
funds = pd.read_csv(pkg_resources.resource_filename(resource_package, resource_path))
270267
else:
271-
names = get_fund_names()
272-
funds = pd.DataFrame(names)
268+
funds = pd.DataFrame(get_fund_names())
273269

274270
if funds is None:
275271
raise IOError("ERR#005: fund list not found or unable to retrieve.")

0 commit comments

Comments
 (0)