Skip to content

Commit

Permalink
python 2.7 support removed & unidecoded input strings
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarob96 committed Apr 30, 2019
1 parent 331843c commit 3b62bb8
Show file tree
Hide file tree
Showing 6 changed files with 378 additions and 428 deletions.
761 changes: 357 additions & 404 deletions .idea/workspace.xml

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: python

python:
- "2.7"
- "3.5"
- "3.6"
- "3.7"
Expand All @@ -13,7 +12,7 @@ install:
- pip install requests==2.21.0
- pip install lxml==4.3.3
- pip install unidecode==1.0.23
- pip install investpy==0.8.4.1
- pip install investpy==0.8.4.2
- pip install pytest==4.1.1

script:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ To conclude this section, I am in the need to specify that this is not the final

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

``pip install investpy==0.8.4.1``
``pip install investpy==0.8.4.2``

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

Expand All @@ -38,7 +38,7 @@ All the dependencies are already listed on the setup file of the package, but to
* Full company name for equities add
* Company Profile retrieval returned value is a dict with the source and the description
* Internal fixes to improve its ease of adaptability
* Python 2.7 unidecode error fix (warning Python 2.7 will be deprecated in 2020)
* Temporarily removed Python 2.7 support due to its warning of deprecation in January 1st of 2020

## Additional Information

Expand Down
29 changes: 14 additions & 15 deletions investpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#!/usr/bin/env python

# Copyright 2018-2019 Alvaro Bartolome
Expand Down Expand Up @@ -225,11 +224,11 @@ def get_historical_data(equity, start, end, as_json=False, order='ascending'):
if equities is None:
raise IOError("ERR#001: equities object not found or unable to retrieve.")

if unidecode.unidecode(equity.lower()) not in [value.lower() for value in equities['name'].tolist()]:
if unidecode.unidecode(equity.lower()) not in [unidecode.unidecode(value.lower()) for value in equities['name'].tolist()]:
raise RuntimeError("ERR#018: equity " + equity.lower() + " not found, check if it is correct.")

for row in equities.itertuples():
if row.name.lower() == unidecode.unidecode(equity.lower()):
if unidecode.unidecode(row.name.lower()) == unidecode.unidecode(equity.lower()):
final = list()

for index in range(len(date_interval['intervals'])):
Expand Down Expand Up @@ -368,7 +367,7 @@ def get_equity_company_profile(equity, language='english'):
if equities is None:
raise IOError("ERR#001: equities object not found or unable to retrieve.")

if unidecode.unidecode(equity.lower()) not in [value.lower() for value in equities['name'].tolist()]:
if unidecode.unidecode(equity.lower()) not in [unidecode.unidecode(value.lower()) for value in equities['name'].tolist()]:
raise RuntimeError("ERR#018: equity " + equity.lower() + " not found, check if it is correct.")

company_profile = {
Expand All @@ -377,7 +376,7 @@ def get_equity_company_profile(equity, language='english'):
}

for row in equities.itertuples():
if row.name.lower() == unidecode.unidecode(equity.lower()):
if unidecode.unidecode(row.name.lower()) == unidecode.unidecode(equity.lower()):
if selected_source == 'Bolsa de Madrid':
url = "http://www.bolsamadrid.es/esp/aspx/Empresas/FichaValor.aspx?ISIN=" + row.isin

Expand Down Expand Up @@ -490,11 +489,11 @@ def get_fund_recent_data(fund, as_json=False, order='ascending'):
if funds is None:
raise IOError("ERR#005: funds object not found or unable to retrieve.")

if unidecode.unidecode(fund.lower()) not in [value.lower() for value in funds['name'].tolist()]:
if unidecode.unidecode(fund.lower()) not in [unidecode.unidecode(value.lower()) for value in funds['name'].tolist()]:
raise RuntimeError("ERR#019: fund " + fund.lower() + " not found, check if it is correct.")

for row in funds.itertuples():
if row.name.lower() == unidecode.unidecode(fund.lower()):
if unidecode.unidecode(row.name.lower()) == unidecode.unidecode(fund.lower()):
url = "https://es.investing.com/funds/" + row.tag + "-historical-data"

head = {
Expand Down Expand Up @@ -638,11 +637,11 @@ def get_fund_historical_data(fund, start, end, as_json=False, order='ascending')
if funds is None:
raise IOError("ERR#005: funds object not found or unable to retrieve.")

if unidecode.unidecode(fund.lower()) not in [value.lower() for value in funds['name'].tolist()]:
if unidecode.unidecode(fund.lower()) not in [unidecode.unidecode(value.lower()) for value in funds['name'].tolist()]:
raise RuntimeError("ERR#019: fund " + fund.lower() + " not found, check if it is correct.")

for row in funds.itertuples():
if row.name.lower() == unidecode.unidecode(fund.lower()):
if unidecode.unidecode(row.name.lower()) == unidecode.unidecode(fund.lower()):
final = list()

for index in range(len(date_interval['intervals'])):
Expand Down Expand Up @@ -761,11 +760,11 @@ def get_fund_information(fund, as_json=False):
if funds is None:
raise IOError("ERR#005: funds object not found or unable to retrieve.")

if unidecode.unidecode(fund.lower()) not in [value.lower() for value in funds['name'].tolist()]:
if unidecode.unidecode(fund.lower()) not in [unidecode.unidecode(value.lower()) for value in funds['name'].tolist()]:
raise RuntimeError("ERR#019: fund " + fund.lower() + " not found, check if it is correct.")

for row in funds.itertuples():
if row.name.lower() == unidecode.unidecode(fund.lower()):
if unidecode.unidecode(row.name.lower()) == unidecode.unidecode(fund.lower()):
url = "https://es.investing.com/funds/" + row.tag

head = {
Expand Down Expand Up @@ -918,11 +917,11 @@ def get_etf_recent_data(etf, as_json=False, order='ascending'):
if etfs is None:
raise IOError("ERR#009: etfs object not found or unable to retrieve.")

if unidecode.unidecode(etf.lower()) not in [value.lower() for value in etfs['name'].tolist()]:
if unidecode.unidecode(etf.lower()) not in [unidecode.unidecode(value.lower()) for value in etfs['name'].tolist()]:
raise RuntimeError("ERR#019: etf " + etf.lower() + " not found, check if it is correct.")

for row in etfs.itertuples():
if row.name.lower() == unidecode.unidecode(etf.lower()):
if unidecode.unidecode(row.name.lower()) == unidecode.unidecode(etf.lower()):
url = "https://es.investing.com/etfs/" + row.tag + "-historical-data"

head = {
Expand Down Expand Up @@ -1066,11 +1065,11 @@ def get_etf_historical_data(etf, start, end, as_json=False, order='ascending'):
if etfs is None:
raise IOError("ERR#009: etfs object not found or unable to retrieve.")

if unidecode.unidecode(etf.lower()) not in [value.lower() for value in etfs['name'].tolist()]:
if unidecode.unidecode(etf.lower()) not in [unidecode.unidecode(value.lower()) for value in etfs['name'].tolist()]:
raise RuntimeError("ERR#019: etf " + etf.lower() + " not found, check if it is correct.")

for row in etfs.itertuples():
if row.name.lower() == unidecode.unidecode(etf.lower()):
if unidecode.unidecode(row.name.lower()) == unidecode.unidecode(etf.lower()):
final = list()

for index in range(len(date_interval['intervals'])):
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ def readme():

setup(
name='investpy',
version='0.8.4.1',
version='0.8.4.2',
packages=find_packages(),
url='',
download_url='https://github.com/alvarob96/investpy/archive/0.8.4.1.tar.gz',
download_url='https://github.com/alvarob96/investpy/archive/0.8.4.2.tar.gz',
license='MIT License',
author='Alvaro Bartolome',
author_email='[email protected]',
Expand All @@ -31,7 +31,6 @@ def readme():
include_package_data=True,
classifiers=[
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_investing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ def test_investing():
This function checks that main functions of investpy work properly.
"""

investpy.get_recent_data(equity='bbva',
investpy.get_recent_data(equity='enegás',
as_json=True,
order='ascending')

investpy.get_historical_data(equity='bbva',
investpy.get_historical_data(equity='enegás',
start='30/10/2018',
end='30/12/2018',
as_json=False,
Expand Down

0 comments on commit 3b62bb8

Please sign in to comment.