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

Retrieve the next earnings date for a ticker but did receive a float not a date #18

Closed
optional12 opened this issue Feb 6, 2024 · 3 comments

Comments

@optional12
Copy link

My idea was to retrieve the next earnings date for a ticker so I checked your code and I think I found the corresponding column to use.
So I tried the customer screener with this query:

Python code used:
tmp = (Query()
.select('name', 'earnings_release_date','Recent Earnings Date','earnings_release_next_date')
.get_scanner_data())
df = tmp[1]
df[df.name == 'PFE']['earnings_release_next_date']

but getting floats instead of dates:

  ticker name  earnings_release_date  earnings_release_date earnings_release_next_date

48 NYSE:PFE PFE 1.706615e+09 1.706615e+09 1.714478e+09

Can you please help/fix?

@shner-elmo
Copy link
Owner

Sure, so that number is a Unix/Epoch time. You can convert it to a datetime using the datetime.datetime.utcfromtimestamp().

_, df = Query().select('price', 'earnings_release_date').get_scanner_data()
df['earnings_release_date'] = df['earnings_release_date'].map(dt.datetime.utcfromtimestamp, na_action='ignore')
>>> df
          ticker        close earnings_release_date
0    NASDAQ:NVDA     672.8286   2023-11-21 21:21:00
1    NASDAQ:TSLA     183.1301   2024-01-24 21:19:00
2       AMEX:SPY     492.2399                   NaT
3     NASDAQ:QQQ     425.5300                   NaT
4    NASDAQ:SMCI     648.0000   2024-01-29 21:06:00
5     NASDAQ:AMD     166.6300   2024-01-30 21:15:00
6    NASDAQ:META     457.3000   2024-02-01 21:05:00
7      NYSE:PLTR      21.5800   2024-02-05 21:05:00
8     NYSE:BRK.A  591250.0212   2023-11-04 21:11:00
9    NASDAQ:AAPL     188.5027   2024-02-01 21:30:00
...

@optional12
Copy link
Author

Your query uses a wrong field 'price', should be 'close'. But thanks for the clarification.

I know observed that not always data gets returned.
Today for eaxmple for CRUS
df[df.name == 'CRUS'][['name', 'close', 'earnings_release_date', 'earnings_release_next_date']]
Empty DataFrame
Columns: [name, close, earnings_release_date, earnings_release_next_date]
Index: []

but on TradingView Earnings View/Screener page they are listed for today after Market
image

@shner-elmo
Copy link
Owner

Good catch. Glad you got it working now.
As for the ticket not appearing in the result, please open a separate issue for that.

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

No branches or pull requests

2 participants