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

add calendar for next events #1781

Closed
wants to merge 9 commits into from
Closed

add calendar for next events #1781

wants to merge 9 commits into from

Conversation

bot-unit
Copy link

Add a calendar of upcoming ticker events
Only dividends and earnings, if available
Yahoo does not provide splits or merges in this query

add a calendar of upcoming ticker events
only dividends and earnings, if available
Yahoo does not provide splits in this query
@ValueRaider
Copy link
Collaborator

ValueRaider commented Dec 13, 2023

Good but need to be smarter with earningsDate. When Yahoo only knows the earnings week not day, it returns 2 dates: Monday, Friday. The old Ticker.calendar used to return two dates in a completely different format to single date - here is my old code:

cal = dat.calendar
if cal is None or cal.shape[1] == 0:
  cal = None
if cal is not None:
  if cal.shape[1] == 1:
    release_dates = [cal["Value"]['Earnings Date']]
  else:
    release_dates = [cal[i]["Earnings Date"] for i in range(cal.shape[1])]	

Not saying you have to preserve structure, just is hard to do worse.

@bot-unit
Copy link
Author

@ValueRaider Where can I see your old code? Because this property was marked as Not Implemented

And it's not replacment of data from calendar page

@ValueRaider
Copy link
Collaborator

ValueRaider commented Dec 13, 2023

By old code, I mean code that used to access Ticker.calendar. Implementation is here (warning broken by Yahoo), and no this didn't fetch from calendar page either. Branch release/0.1

@bot-unit
Copy link
Author

@ValueRaider
I not sure, that we should include earnings stat, because we have special property for it. In my opinion, calendar should return only events dates

from yfinance import Ticker
ticker = Ticker("AAPL")
print(ticker.ticker)
print(ticker.calendar)
print(ticker.calendar.attrs["earnings"])

ticker = Ticker("LLY")
print(ticker.ticker)
print(ticker.calendar.head())
print(ticker.calendar.attrs["earnings"])

output is:

AAPL
              Event                     Date
0     Dividend Date               2023-11-16
1  Ex-Dividend Date               2023-11-10
2     Earnings Date  2024-01-31 - 2024-02-05
                                   Value
Key                                     
earningsDate     2024-01-31 - 2024-02-05
earningsAverage                     1.94
earningsLow                         1.88
earningsHigh                         2.0
revenueAverage              109127000000
revenueLow                  107955000000
revenueHigh                 114869000000
LLY
              Event        Date
0     Dividend Date  2024-03-08
1  Ex-Dividend Date  2024-02-14
2     Earnings Date  2024-02-06
                      Value
Key                        
earningsDate     2024-02-06
earningsAverage        2.78
earningsLow            2.64
earningsHigh           2.88
revenueAverage   8943460000
revenueLow       8632000000
revenueHigh      9224180000

@ValueRaider
Copy link
Collaborator

A flat dict might be best. What analysis is made harder by calendar dates not being a Pandas.Series?

# Conflicts:
#	yfinance/scrapers/quote.py
add calendar events
return is dict
test passed
add calendar events
return is dict
test passed
@bot-unit
Copy link
Author

@ValueRaider

AAPL
{'Dividend Date': datetime.date(2023, 11, 16),
 'Earnings Average': 1.94,
 'Earnings Date': [datetime.date(2024, 1, 31), datetime.date(2024, 2, 5)],
 'Earnings High': 2.0,
 'Earnings Low': 1.88,
 'Ex-Dividend Date': datetime.date(2023, 11, 10),
 'Revenue Average': 109127000000,
 'Revenue High': 114869000000,
 'Revenue Low': 107955000000}
LLY
{'Dividend Date': datetime.date(2024, 3, 8),
 'Earnings Average': 2.78,
 'Earnings Date': [datetime.date(2024, 2, 6)],
 'Earnings High': 2.88,
 'Earnings Low': 2.64,
 'Ex-Dividend Date': datetime.date(2024, 2, 14),
 'Revenue Average': 8943460000,
 'Revenue High': 9224180000,
 'Revenue Low': 8632000000}

bot-unit and others added 2 commits December 15, 2023 00:07
add calendar events
return is dict
test passed
add calendar events
return is dict
test passed
@bot-unit
Copy link
Author

bot-unit commented Dec 14, 2023

I cann't squash commits. So if everything is ok, i can recreate PR with one clean commit

@ValueRaider
Copy link
Collaborator

ValueRaider commented Dec 15, 2023

The complication was merging in dev. Go ahead with new branch.

@bot-unit bot-unit closed this Dec 16, 2023
@bot-unit bot-unit deleted the feature/calendar branch December 16, 2023 11:55
@bot-unit bot-unit restored the feature/calendar branch December 16, 2023 11:55
@bot-unit bot-unit deleted the feature/calendar branch December 16, 2023 12:05
This was referenced Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants