Skip to content

Commit

Permalink
applied unidecode function to solve bug #313
Browse files Browse the repository at this point in the history
  • Loading branch information
Álvaro Bartolomé committed Mar 31, 2021
1 parent ae15606 commit 3e42ea1
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 141 deletions.
22 changes: 11 additions & 11 deletions investpy/bonds.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ def get_bond_recent_data(bond, as_json=False, order='ascending', interval='Daily

bond = unidecode(bond.strip().lower())

if bond not in list(bonds['name'].str.lower()):
if bond not in list(bonds['name'].apply(unidecode).str.lower()):
raise RuntimeError("ERR#0068: bond " + bond + " not found, check if it is correct.")

id_ = bonds.loc[(bonds['name'].str.lower() == bond).idxmax(), 'id']
name = bonds.loc[(bonds['name'].str.lower() == bond).idxmax(), 'name']
full_name = bonds.loc[(bonds['name'].str.lower() == bond).idxmax(), 'full_name']
id_ = bonds.loc[(bonds['name'].apply(unidecode).str.lower() == bond).idxmax(), 'id']
name = bonds.loc[(bonds['name'].apply(unidecode).str.lower() == bond).idxmax(), 'name']
full_name = bonds.loc[(bonds['name'].apply(unidecode).str.lower() == bond).idxmax(), 'full_name']

header = full_name + " Bond Yield Historical Data"

Expand Down Expand Up @@ -475,12 +475,12 @@ def get_bond_historical_data(bond, from_date, to_date, as_json=False, order='asc

bond = unidecode(bond.strip().lower())

if bond not in list(bonds['name'].str.lower()):
if bond not in list(bonds['name'].apply(unidecode).str.lower()):
raise RuntimeError("ERR#0068: bond " + bond + " not found, check if it is correct.")

id_ = bonds.loc[(bonds['name'].str.lower() == bond).idxmax(), 'id']
name = bonds.loc[(bonds['name'].str.lower() == bond).idxmax(), 'name']
full_name = bonds.loc[(bonds['name'].str.lower() == bond).idxmax(), 'full_name']
id_ = bonds.loc[(bonds['name'].apply(unidecode).str.lower() == bond).idxmax(), 'id']
name = bonds.loc[(bonds['name'].apply(unidecode).str.lower() == bond).idxmax(), 'name']
full_name = bonds.loc[(bonds['name'].apply(unidecode).str.lower() == bond).idxmax(), 'full_name']

final = list()

Expand Down Expand Up @@ -643,11 +643,11 @@ def get_bond_information(bond, as_json=False):

bond = unidecode(bond.strip().lower())

if bond not in list(bonds['name'].str.lower()):
if bond not in list(bonds['name'].apply(unidecode).str.lower()):
raise RuntimeError("ERR#0068: bond " + bond + " not found, check if it is correct.")

name = bonds.loc[(bonds['name'].str.lower() == bond).idxmax(), 'name']
tag = bonds.loc[(bonds['name'].str.lower() == bond).idxmax(), 'tag']
name = bonds.loc[(bonds['name'].apply(unidecode).str.lower() == bond).idxmax(), 'name']
tag = bonds.loc[(bonds['name'].apply(unidecode).str.lower() == bond).idxmax(), 'tag']

url = "https://www.investing.com/rates-bonds/" + tag

Expand Down
22 changes: 11 additions & 11 deletions investpy/certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,12 @@ def get_certificate_recent_data(certificate, country, as_json=False, order='asce

certificate = unidecode(certificate.strip().lower())

if certificate not in list(certificates['name'].str.lower()):
if certificate not in list(certificates['name'].apply(unidecode).str.lower()):
raise RuntimeError("ERR#0101: certificate " + certificate + " not found, check if it is correct.")

symbol = certificates.loc[(certificates['name'].str.lower() == certificate).idxmax(), 'symbol']
id_ = certificates.loc[(certificates['name'].str.lower() == certificate).idxmax(), 'id']
name = certificates.loc[(certificates['name'].str.lower() == certificate).idxmax(), 'name']
symbol = certificates.loc[(certificates['name'].apply(unidecode).str.lower() == certificate).idxmax(), 'symbol']
id_ = certificates.loc[(certificates['name'].apply(unidecode).str.lower() == certificate).idxmax(), 'id']
name = certificates.loc[(certificates['name'].apply(unidecode).str.lower() == certificate).idxmax(), 'name']

header = symbol + ' Historical Data'

Expand Down Expand Up @@ -510,12 +510,12 @@ def get_certificate_historical_data(certificate, country, from_date, to_date, as

certificate = unidecode(certificate.strip().lower())

if certificate not in list(certificates['name'].str.lower()):
if certificate not in list(certificates['name'].apply(unidecode).str.lower()):
raise RuntimeError("ERR#0101: certificate " + certificate + " not found, check if it is correct.")

symbol = certificates.loc[(certificates['name'].str.lower() == certificate).idxmax(), 'symbol']
id_ = certificates.loc[(certificates['name'].str.lower() == certificate).idxmax(), 'id']
name = certificates.loc[(certificates['name'].str.lower() == certificate).idxmax(), 'name']
symbol = certificates.loc[(certificates['name'].apply(unidecode).str.lower() == certificate).idxmax(), 'symbol']
id_ = certificates.loc[(certificates['name'].apply(unidecode).str.lower() == certificate).idxmax(), 'id']
name = certificates.loc[(certificates['name'].apply(unidecode).str.lower() == certificate).idxmax(), 'name']

header = symbol + ' Historical Data'

Expand Down Expand Up @@ -690,11 +690,11 @@ def get_certificate_information(certificate, country, as_json=False):

certificate = unidecode(certificate.strip().lower())

if certificate not in list(certificates['name'].str.lower()):
if certificate not in list(certificates['name'].apply(unidecode).str.lower()):
raise RuntimeError("ERR#0101: certificate " + certificate + " not found, check if it is correct.")

tag = certificates.loc[(certificates['name'].str.lower() == certificate).idxmax(), 'tag']
name = certificates.loc[(certificates['name'].str.lower() == certificate).idxmax(), 'name']
tag = certificates.loc[(certificates['name'].apply(unidecode).str.lower() == certificate).idxmax(), 'tag']
name = certificates.loc[(certificates['name'].apply(unidecode).str.lower() == certificate).idxmax(), 'name']

url = "https://www.investing.com/certificates/" + tag

Expand Down
32 changes: 16 additions & 16 deletions investpy/commodities.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,11 @@ def get_commodity_recent_data(commodity, country=None, as_json=False, order='asc

commodity = unidecode(commodity.strip().lower())

if commodity not in list(commodities['name'].str.lower()):
if commodity not in list(commodities['name'].apply(unidecode).str.lower()):
raise RuntimeError("ERR#0079: commodity " + commodity + " not found, check if it is correct.")

if country is None:
found_commodities = commodities[commodities['name'].str.lower() == commodity]
found_commodities = commodities[commodities['name'].apply(unidecode).str.lower() == commodity]

if len(found_commodities) > 1:
msg = "Note that the displayed commodity data can differ depending on the country. " \
Expand All @@ -276,11 +276,11 @@ def get_commodity_recent_data(commodity, country=None, as_json=False, order='asc

commodities = commodities[commodities['country'] == country]

full_name = commodities.loc[(commodities['name'].str.lower() == commodity).idxmax(), 'full_name']
id_ = commodities.loc[(commodities['name'].str.lower() == commodity).idxmax(), 'id']
name = commodities.loc[(commodities['name'].str.lower() == commodity).idxmax(), 'name']
full_name = commodities.loc[(commodities['name'].apply(unidecode).str.lower() == commodity).idxmax(), 'full_name']
id_ = commodities.loc[(commodities['name'].apply(unidecode).str.lower() == commodity).idxmax(), 'id']
name = commodities.loc[(commodities['name'].apply(unidecode).str.lower() == commodity).idxmax(), 'name']

currency = commodities.loc[(commodities['name'].str.lower() == commodity).idxmax(), 'currency']
currency = commodities.loc[(commodities['name'].apply(unidecode).str.lower() == commodity).idxmax(), 'currency']

header = full_name + ' Historical Data'

Expand Down Expand Up @@ -516,11 +516,11 @@ def get_commodity_historical_data(commodity, from_date, to_date, country=None, a

commodity = unidecode(commodity.strip().lower())

if commodity not in list(commodities['name'].str.lower()):
if commodity not in list(commodities['name'].apply(unidecode).str.lower()):
raise RuntimeError("ERR#0079: commodity " + commodity + " not found, check if it is correct.")

if country is None:
found_commodities = commodities[commodities['name'].str.lower() == commodity]
found_commodities = commodities[commodities['name'].apply(unidecode).str.lower() == commodity]

if len(found_commodities) > 1:
msg = "Note that the displayed commodity data can differ depending on the country. " \
Expand All @@ -537,11 +537,11 @@ def get_commodity_historical_data(commodity, from_date, to_date, country=None, a

commodities = commodities[commodities['country'] == country]

full_name = commodities.loc[(commodities['name'].str.lower() == commodity).idxmax(), 'full_name']
id_ = commodities.loc[(commodities['name'].str.lower() == commodity).idxmax(), 'id']
name = commodities.loc[(commodities['name'].str.lower() == commodity).idxmax(), 'name']
full_name = commodities.loc[(commodities['name'].apply(unidecode).str.lower() == commodity).idxmax(), 'full_name']
id_ = commodities.loc[(commodities['name'].apply(unidecode).str.lower() == commodity).idxmax(), 'id']
name = commodities.loc[(commodities['name'].apply(unidecode).str.lower() == commodity).idxmax(), 'name']

currency = commodities.loc[(commodities['name'].str.lower() == commodity).idxmax(), 'currency']
currency = commodities.loc[(commodities['name'].apply(unidecode).str.lower() == commodity).idxmax(), 'currency']

header = full_name + ' Historical Data'

Expand Down Expand Up @@ -720,11 +720,11 @@ def get_commodity_information(commodity, country=None, as_json=False):

commodity = unidecode(commodity.strip().lower())

if commodity not in list(commodities['name'].str.lower()):
if commodity not in list(commodities['name'].apply(unidecode).str.lower()):
raise RuntimeError("ERR#0079: commodity " + commodity + " not found, check if it is correct.")

if country is None:
found_commodities = commodities[commodities['name'].str.lower() == commodity]
found_commodities = commodities[commodities['name'].apply(unidecode).str.lower() == commodity]

if len(found_commodities) > 1:
msg = "Note that the displayed commodity information can differ depending on the country. " \
Expand All @@ -741,8 +741,8 @@ def get_commodity_information(commodity, country=None, as_json=False):

commodities = commodities[commodities['country'] == country]

name = commodities.loc[(commodities['name'].str.lower() == commodity).idxmax(), 'name']
tag = commodities.loc[(commodities['name'].str.lower() == commodity).idxmax(), 'tag']
name = commodities.loc[(commodities['name'].apply(unidecode).str.lower() == commodity).idxmax(), 'name']
tag = commodities.loc[(commodities['name'].apply(unidecode).str.lower() == commodity).idxmax(), 'tag']

url = "https://www.investing.com/commodities/" + tag

Expand Down
30 changes: 15 additions & 15 deletions investpy/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,16 @@ def get_crypto_recent_data(crypto, as_json=False, order='ascending', interval='D

crypto = unidecode(crypto.strip().lower())

if crypto not in list(cryptos['name'].str.lower()):
if crypto not in list(cryptos['name'].apply(unidecode).str.lower()):
raise RuntimeError("ERR#0085: crypto currency: " + crypto + ", not found, check if it is correct.")

status = cryptos.loc[(cryptos['name'].str.lower() == crypto).idxmax(), 'status']
status = cryptos.loc[(cryptos['name'].apply(unidecode).str.lower() == crypto).idxmax(), 'status']
if status == 'unavailable':
raise ValueError("ERR#0086: the selected crypto currency is not available for retrieval in Investing.com.")

crypto_name = cryptos.loc[(cryptos['name'].str.lower() == crypto).idxmax(), 'name']
crypto_id = cryptos.loc[(cryptos['name'].str.lower() == crypto).idxmax(), 'id']
crypto_currency = cryptos.loc[(cryptos['name'].str.lower() == crypto).idxmax(), 'currency']
crypto_name = cryptos.loc[(cryptos['name'].apply(unidecode).str.lower() == crypto).idxmax(), 'name']
crypto_id = cryptos.loc[(cryptos['name'].apply(unidecode).str.lower() == crypto).idxmax(), 'id']
crypto_currency = cryptos.loc[(cryptos['name'].apply(unidecode).str.lower() == crypto).idxmax(), 'currency']

header = crypto_name + ' Historical Data'

Expand Down Expand Up @@ -455,16 +455,16 @@ def get_crypto_historical_data(crypto, from_date, to_date, as_json=False, order=

crypto = unidecode(crypto.strip().lower())

if crypto not in list(cryptos['name'].str.lower()):
if crypto not in list(cryptos['name'].apply(unidecode).str.lower()):
raise RuntimeError("ERR#0085: crypto currency: " + crypto + ", not found, check if it is correct.")

status = cryptos.loc[(cryptos['name'].str.lower() == crypto).idxmax(), 'status']
status = cryptos.loc[(cryptos['name'].apply(unidecode).str.lower() == crypto).idxmax(), 'status']
if status == 'unavailable':
raise ValueError("ERR#0086: the selected crypto currency is not available for retrieval in Investing.com.")

crypto_name = cryptos.loc[(cryptos['name'].str.lower() == crypto).idxmax(), 'name']
crypto_id = cryptos.loc[(cryptos['name'].str.lower() == crypto).idxmax(), 'id']
crypto_currency = cryptos.loc[(cryptos['name'].str.lower() == crypto).idxmax(), 'currency']
crypto_name = cryptos.loc[(cryptos['name'].apply(unidecode).str.lower() == crypto).idxmax(), 'name']
crypto_id = cryptos.loc[(cryptos['name'].apply(unidecode).str.lower() == crypto).idxmax(), 'id']
crypto_currency = cryptos.loc[(cryptos['name'].apply(unidecode).str.lower() == crypto).idxmax(), 'currency']

header = crypto_name + ' Historical Data'

Expand Down Expand Up @@ -628,16 +628,16 @@ def get_crypto_information(crypto, as_json=False):

crypto = unidecode(crypto.strip().lower())

if crypto not in list(cryptos['name'].str.lower()):
if crypto not in list(cryptos['name'].apply(unidecode).str.lower()):
raise RuntimeError("ERR#0085: crypto currency: " + crypto + ", not found, check if it is correct.")

status = cryptos.loc[(cryptos['name'].str.lower() == crypto).idxmax(), 'status']
status = cryptos.loc[(cryptos['name'].apply(unidecode).str.lower() == crypto).idxmax(), 'status']
if status == 'unavailable':
raise ValueError("ERR#0086: the selected crypto currency is not available for retrieval in Investing.com.")

name = cryptos.loc[(cryptos['name'].str.lower() == crypto).idxmax(), 'name']
currency = cryptos.loc[(cryptos['name'].str.lower() == crypto).idxmax(), 'currency']
tag = cryptos.loc[(cryptos['name'].str.lower() == crypto).idxmax(), 'tag']
name = cryptos.loc[(cryptos['name'].apply(unidecode).str.lower() == crypto).idxmax(), 'name']
currency = cryptos.loc[(cryptos['name'].apply(unidecode).str.lower() == crypto).idxmax(), 'currency']
tag = cryptos.loc[(cryptos['name'].apply(unidecode).str.lower() == crypto).idxmax(), 'tag']

url = "https://www.investing.com/crypto/" + tag

Expand Down
22 changes: 11 additions & 11 deletions investpy/currency_crosses.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,12 @@ def get_currency_cross_recent_data(currency_cross, as_json=False, order='ascendi

currency_cross = unidecode(currency_cross.strip().lower())

if currency_cross not in list(currency_crosses['name'].str.lower()):
if currency_cross not in list(currency_crosses['name'].apply(unidecode).str.lower()):
raise RuntimeError("ERR#0054: the introduced currency_cross " + str(currency_cross) + " does not exist.")

id_ = currency_crosses.loc[(currency_crosses['name'].str.lower() == currency_cross).idxmax(), 'id']
name = currency_crosses.loc[(currency_crosses['name'].str.lower() == currency_cross).idxmax(), 'name']
currency = currency_crosses.loc[(currency_crosses['name'].str.lower() == currency_cross).idxmax(), 'second']
id_ = currency_crosses.loc[(currency_crosses['name'].apply(unidecode).str.lower() == currency_cross).idxmax(), 'id']
name = currency_crosses.loc[(currency_crosses['name'].apply(unidecode).str.lower() == currency_cross).idxmax(), 'name']
currency = currency_crosses.loc[(currency_crosses['name'].apply(unidecode).str.lower() == currency_cross).idxmax(), 'second']

header = name + ' Historical Data'

Expand Down Expand Up @@ -508,12 +508,12 @@ def get_currency_cross_historical_data(currency_cross, from_date, to_date, as_js

currency_cross = unidecode(currency_cross.strip().lower())

if currency_cross not in list(currency_crosses['name'].str.lower()):
if currency_cross not in list(currency_crosses['name'].apply(unidecode).str.lower()):
raise RuntimeError("ERR#0054: the introduced currency_cross " + str(currency_cross) + " does not exist.")

id_ = currency_crosses.loc[(currency_crosses['name'].str.lower() == currency_cross).idxmax(), 'id']
name = currency_crosses.loc[(currency_crosses['name'].str.lower() == currency_cross).idxmax(), 'name']
currency = currency_crosses.loc[(currency_crosses['name'].str.lower() == currency_cross).idxmax(), 'second']
id_ = currency_crosses.loc[(currency_crosses['name'].apply(unidecode).str.lower() == currency_cross).idxmax(), 'id']
name = currency_crosses.loc[(currency_crosses['name'].apply(unidecode).str.lower() == currency_cross).idxmax(), 'name']
currency = currency_crosses.loc[(currency_crosses['name'].apply(unidecode).str.lower() == currency_cross).idxmax(), 'second']

final = list()

Expand Down Expand Up @@ -675,11 +675,11 @@ def get_currency_cross_information(currency_cross, as_json=False):

currency_cross = unidecode(currency_cross.strip().lower())

if currency_cross not in list(currency_crosses['name'].str.lower()):
if currency_cross not in list(currency_crosses['name'].apply(unidecode).str.lower()):
raise RuntimeError("ERR#0054: the introduced currency_cross " + str(currency_cross) + " does not exist.")

name = currency_crosses.loc[(currency_crosses['name'].str.lower() == currency_cross).idxmax(), 'name']
tag = currency_crosses.loc[(currency_crosses['name'].str.lower() == currency_cross).idxmax(), 'tag']
name = currency_crosses.loc[(currency_crosses['name'].apply(unidecode).str.lower() == currency_cross).idxmax(), 'name']
tag = currency_crosses.loc[(currency_crosses['name'].apply(unidecode).str.lower() == currency_cross).idxmax(), 'tag']

url = "https://www.investing.com/currencies/" + tag

Expand Down
Loading

0 comments on commit 3e42ea1

Please sign in to comment.