Skip to content

Commit

Permalink
solved gmt conversion with .timezone('GMT') #282
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarobartt committed Feb 6, 2021
1 parent feaeb7d commit ce02097
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions investpy/bonds.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def get_bond_recent_data(bond, as_json=False, order='ascending', interval='Daily
for nested_ in elements_.xpath(".//td"):
info.append(nested_.get('data-real-value'))

bond_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
bond_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

bond_close = float(info[1].replace(',', ''))
bond_open = float(info[2].replace(',', ''))
Expand Down Expand Up @@ -542,7 +542,7 @@ def get_bond_historical_data(bond, from_date, to_date, as_json=False, order='asc
for nested_ in elements_.xpath(".//td"):
info.append(nested_.get('data-real-value'))

bond_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
bond_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

bond_close = float(info[1].replace(',', ''))
bond_open = float(info[2].replace(',', ''))
Expand Down
4 changes: 2 additions & 2 deletions investpy/certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def get_certificate_recent_data(certificate, country, as_json=False, order='asce
for nested_ in elements_.xpath(".//td"):
info.append(nested_.get('data-real-value'))

certificate_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
certificate_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

certificate_close = float(info[1].replace(',', ''))
certificate_open = float(info[2].replace(',', ''))
Expand Down Expand Up @@ -573,7 +573,7 @@ def get_certificate_historical_data(certificate, country, from_date, to_date, as
info.append(nested_.get('data-real-value'))

if data_flag is True:
certificate_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
certificate_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

certificate_close = float(info[1].replace(',', ''))
certificate_open = float(info[2].replace(',', ''))
Expand Down
4 changes: 2 additions & 2 deletions investpy/commodities.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def get_commodity_recent_data(commodity, country=None, as_json=False, order='asc
for nested_ in elements_.xpath(".//td"):
info.append(nested_.get('data-real-value'))

commodity_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
commodity_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

commodity_close = float(info[1].replace(',', ''))
commodity_open = float(info[2].replace(',', ''))
Expand Down Expand Up @@ -599,7 +599,7 @@ def get_commodity_historical_data(commodity, from_date, to_date, country=None, a
info.append(nested_.get('data-real-value'))

if data_flag is True:
commodity_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
commodity_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

commodity_close = float(info[1].replace(',', ''))
commodity_open = float(info[2].replace(',', ''))
Expand Down
4 changes: 2 additions & 2 deletions investpy/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def get_crypto_recent_data(crypto, as_json=False, order='ascending', interval='D
for nested_ in elements_.xpath(".//td"):
info.append(nested_.get('data-real-value'))

crypto_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
crypto_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

crypto_close = float(info[1].replace(',', ''))
crypto_open = float(info[2].replace(',', ''))
Expand Down Expand Up @@ -526,7 +526,7 @@ def get_crypto_historical_data(crypto, from_date, to_date, as_json=False, order=
info.append(nested_.get('data-real-value'))

if data_flag is True:
crypto_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
crypto_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

crypto_close = float(info[1].replace(',', ''))
crypto_open = float(info[2].replace(',', ''))
Expand Down
4 changes: 2 additions & 2 deletions investpy/currency_crosses.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def get_currency_cross_recent_data(currency_cross, as_json=False, order='ascendi
for nested_ in elements_.xpath(".//td"):
info.append(nested_.get('data-real-value'))

currency_cross_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
currency_cross_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

currency_cross_close = float(info[1].replace(',', ''))
currency_cross_open = float(info[2].replace(',', ''))
Expand Down Expand Up @@ -575,7 +575,7 @@ def get_currency_cross_historical_data(currency_cross, from_date, to_date, as_js
data_flag = True

if data_flag is True:
currency_cross_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
currency_cross_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

currency_cross_close = float(info[1].replace(',', ''))
currency_cross_open = float(info[2].replace(',', ''))
Expand Down
4 changes: 2 additions & 2 deletions investpy/etfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def get_etf_recent_data(etf, country, stock_exchange=None, as_json=False, order=
for nested_ in elements_.xpath(".//td"):
info.append(nested_.get('data-real-value'))

etf_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
etf_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

etf_close = float(info[1].replace(',', ''))
etf_open = float(info[2].replace(',', ''))
Expand Down Expand Up @@ -690,7 +690,7 @@ def get_etf_historical_data(etf, country, from_date, to_date, stock_exchange=Non
info.append(nested_.get('data-real-value'))

if data_flag is True:
etf_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
etf_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

etf_close = float(info[1].replace(',', ''))
etf_open = float(info[2].replace(',', ''))
Expand Down
4 changes: 2 additions & 2 deletions investpy/funds.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def get_fund_recent_data(fund, country, as_json=False, order='ascending', interv
for nested_ in elements_.xpath(".//td"):
info.append(nested_.get('data-real-value'))

fund_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
fund_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

fund_close = float(info[1].replace(',', ''))
fund_open = float(info[2].replace(',', ''))
Expand Down Expand Up @@ -565,7 +565,7 @@ def get_fund_historical_data(fund, country, from_date, to_date, as_json=False, o
info.append(nested_.get('data-real-value'))

if data_flag is True:
fund_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
fund_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

fund_close = float(info[1].replace(',', ''))
fund_open = float(info[2].replace(',', ''))
Expand Down
4 changes: 2 additions & 2 deletions investpy/indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def get_index_recent_data(index, country, as_json=False, order='ascending', inte
for nested_ in elements_.xpath(".//td"):
info.append(nested_.get('data-real-value'))

index_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
index_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

index_close = float(info[1].replace(',', ''))
index_open = float(info[2].replace(',', ''))
Expand Down Expand Up @@ -573,7 +573,7 @@ def get_index_historical_data(index, country, from_date, to_date, as_json=False,
info.append(nested_.get('data-real-value'))

if data_flag is True:
index_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
index_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

index_close = float(info[1].replace(',', ''))
index_open = float(info[2].replace(',', ''))
Expand Down
2 changes: 1 addition & 1 deletion investpy/news.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def economic_calendar(time_zone=None, time_filter='time_only', countries=None, i
for row in table:
id_ = row.get("id")
if id_ == None:
curr_date = datetime.fromtimestamp(int(row.xpath("td")[0].get("id").replace("theDay", "")), tz=pytz.gmt).strftime("%d/%m/%Y")
curr_date = datetime.fromtimestamp(int(row.xpath("td")[0].get("id").replace("theDay", "")), tz=pytz.timezone('GMT')).strftime("%d/%m/%Y")
else:
id_ = id_.replace('eventRowId_', '')

Expand Down
4 changes: 2 additions & 2 deletions investpy/stocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def get_stock_recent_data(stock, country, as_json=False, order='ascending', inte
for nested_ in elements_.xpath(".//td"):
info.append(nested_.get('data-real-value'))

stock_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
stock_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

stock_close = float(info[1].replace(',', ''))
stock_open = float(info[2].replace(',', ''))
Expand Down Expand Up @@ -580,7 +580,7 @@ def get_stock_historical_data(stock, country, from_date, to_date, as_json=False,
info.append(nested_.get('data-real-value'))

if data_flag is True:
stock_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
stock_date = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

stock_close = float(info[1].replace(',', ''))
stock_open = float(info[2].replace(',', ''))
Expand Down
2 changes: 1 addition & 1 deletion investpy/utils/search_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def _data_retrieval(self, product, head, params):
raise IndexError("ERR#0033: information unavailable or not found.")
info.append(val)

date_ = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.gmt).date()), '%Y-%m-%d')
date_ = datetime.strptime(str(datetime.fromtimestamp(int(info[0]), tz=pytz.timezone('GMT')).date()), '%Y-%m-%d')

close_ = float(info[1].replace(',', ''))
open_ = float(info[2].replace(',', ''))
Expand Down

0 comments on commit ce02097

Please sign in to comment.