Skip to content

Commit

Permalink
Merge pull request ranaroussi#1922 from ranaroussi/fix/datetime-utc-w…
Browse files Browse the repository at this point in the history
…arning
ValueRaider authored May 9, 2024
2 parents 84ba6d7 + dc5c718 commit 098e776
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tests/prices.py
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ def test_duplicatingHourly(self):
dat = yf.Ticker(tkr, session=self.session)
tz = dat._get_ticker_tz(proxy=None, timeout=None)

dt_utc = _tz.timezone("UTC").localize(_dt.datetime.utcnow())
dt_utc = _pd.Timestamp.utcnow()
dt = dt_utc.astimezone(_tz.timezone(tz))
start_d = dt.date() - _dt.timedelta(days=7)
df = dat.history(start=start_d, interval="1h")
@@ -82,7 +82,7 @@ def test_duplicatingDaily(self):
dat = yf.Ticker(tkr, session=self.session)
tz = dat._get_ticker_tz(proxy=None, timeout=None)

dt_utc = _tz.timezone("UTC").localize(_dt.datetime.utcnow())
dt_utc = _pd.Timestamp.utcnow()
dt = dt_utc.astimezone(_tz.timezone(tz))
if dt.time() < _dt.time(17, 0):
continue
2 changes: 1 addition & 1 deletion yfinance/scrapers/history.py
Original file line number Diff line number Diff line change
@@ -210,7 +210,7 @@ def history(self, period="1mo", interval="1d",
quotes = utils.parse_quotes(data["chart"]["result"][0])
# Yahoo bug fix - it often appends latest price even if after end date
if end and not quotes.empty:
endDt = pd.to_datetime(_datetime.datetime.utcfromtimestamp(end))
endDt = pd.to_datetime(end, unit='s')
if quotes.index[quotes.shape[0] - 1] >= endDt:
quotes = quotes.iloc[0:quotes.shape[0] - 1]
except Exception:

0 comments on commit 098e776

Please sign in to comment.