Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync main -> dev #2184

Merged
merged 10 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .github/workflows/ci.yml

This file was deleted.

18 changes: 18 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
Change Log
===========

0.2.51
------
Fixes:
- earnings_dates #2169
Features:
- Screener tweaks #2168
- Search #2160
- get_news() expose count #2173

0.2.50
------
Fixes:
- price repair #2111 #2139
- download() appearance 2109
- isin() error #2099
- growth_estimates #2127
Also new docs #2132

0.2.49
------
Fix prices-clean rarely discarding good data #2122
Expand Down
2 changes: 1 addition & 1 deletion meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "yfinance" %}
{% set version = "0.2.49" %}
{% set version = "0.2.51" %}

package:
name: "{{ name|lower }}"
Expand Down
19 changes: 0 additions & 19 deletions mkdocs.yml

This file was deleted.

50 changes: 30 additions & 20 deletions yfinance/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import pandas as pd
import requests
from datetime import date

from . import utils, cache
from .data import YfData
Expand Down Expand Up @@ -598,7 +599,7 @@ def get_earnings_dates(self, limit=12, proxy=None) -> Optional[pd.DataFrame]:
page_offset = 0
dates = None
while True:
url = f"{_ROOT_URL_}/calendar/earnings?symbol={self.ticker}&offset={page_offset}&size={page_size}"
url = f"{_ROOT_URL_}/calendar/earnings?day={date.today()}&symbol={self.ticker}&offset={page_offset}&size={page_size}"
data = self._data.cache_get(url=url, proxy=proxy).text

if "Will be right back" in data:
Expand Down Expand Up @@ -639,31 +640,40 @@ def get_earnings_dates(self, limit=12, proxy=None) -> Optional[pd.DataFrame]:
# Drop redundant columns
dates = dates.drop(["Symbol", "Company"], axis=1)

# Compatibility
dates = dates.rename(columns={'Surprise (%)': 'Surprise(%)'})

# Drop empty rows
for i in range(len(dates)-1, -1, -1):
if dates.iloc[i].isna().all():
dates = dates.drop(i)

# Convert types
for cn in ["EPS Estimate", "Reported EPS", "Surprise(%)"]:
dates.loc[dates[cn] == '-', cn] = float("nan")
dates[cn] = dates[cn].astype(float)

# Convert % to range 0->1:
dates["Surprise(%)"] *= 0.01

# Parse earnings date string
cn = "Earnings Date"
# - remove AM/PM and timezone from date string
tzinfo = dates[cn].str.extract('([AP]M[a-zA-Z]*)$')
dates[cn] = dates[cn].replace(' [AP]M[a-zA-Z]*$', '', regex=True)
# - split AM/PM from timezone
tzinfo = tzinfo[0].str.extract('([AP]M)([a-zA-Z]*)', expand=True)
tzinfo.columns = ["AM/PM", "TZ"]
# - combine and parse
dates[cn] = dates[cn] + ' ' + tzinfo["AM/PM"]
dates[cn] = pd.to_datetime(dates[cn], format="%b %d, %Y, %I %p")
# - instead of attempting decoding of ambiguous timezone abbreviation, just use 'info':
self._quote.proxy = proxy or self.proxy
tz = self._get_ticker_tz(proxy=proxy, timeout=30)
dates[cn] = dates[cn].dt.tz_localize(tz)

dates = dates.set_index("Earnings Date")
try:
dates_backup = dates.copy()
# - extract timezone because Yahoo stopped returning in UTC
tzy = dates[cn].str.split(' ').str.get(-1)
tzy[tzy.isin(['EDT', 'EST'])] = 'US/Eastern'
# - tidy date string
dates[cn] = dates[cn].str.split(' ').str[:-1].str.join(' ')
dates[cn] = dates[cn].replace(' at', ',', regex=True)
# - parse
dates[cn] = pd.to_datetime(dates[cn], format="%B %d, %Y, %I %p")
# - convert to exchange timezone
self._quote.proxy = proxy or self.proxy
tz = self._get_ticker_tz(proxy=proxy, timeout=30)
dates[cn] = [dates[cn].iloc[i].tz_localize(tzy.iloc[i], ambiguous=True).tz_convert(tz) for i in range(len(dates))]

dates = dates.set_index("Earnings Date")
except Exception as e:
utils.get_yf_logger().info(f"{self.ticker}: Problem parsing earnings_dates: {str(e)}")
dates = dates_backup

self._earnings_dates[limit] = dates

Expand All @@ -676,4 +686,4 @@ def get_funds_data(self, proxy=None) -> Optional[FundsData]:
if not self._funds_data:
self._funds_data = FundsData(self._data, self.ticker)

return self._funds_data
return self._funds_data
2 changes: 1 addition & 1 deletion yfinance/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "0.2.49"
version = "0.2.51"
Loading