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

Fix: Remove hardcoded keys in Analysis #2194

Merged
merged 2 commits into from
Jan 1, 2025

Conversation

dhruvan2006
Copy link
Contributor

@dhruvan2006 dhruvan2006 commented Dec 26, 2024

Removed hard coded keys in the Analysis scraper functions to protect against Yahoo changing the keys in the future.

Changes

End result is more or else the same except:

  • Few column names have changed
  • Index has names

Earnings Estimate

Before:

image

After:

image

Revenue Estimate

Before:

image

After:

image

Earnings History

Before:

image

After:

image

EPS Trend

Before:

image

After:

image

EPS Revisions

Before:

image

After:

image

Growth Estimates

Before:

image

After:

image

Closes #2188

@R5dan
Copy link
Contributor

R5dan commented Dec 26, 2024

Surely it would be quicker and simpler to simply store the keys as lower case strings

@dhruvan2006
Copy link
Contributor Author

Surely it would be quicker and simpler to simply store the keys as lower case strings

I am aiming to keep backwards compatibility

@ValueRaider
Copy link
Collaborator

And what if Yahoo changes another key? Better if most hardcodings go - just unpack the json and use what Yahoo provides as much as possible. Try this:

dd = []
for item in self._earnings_trend:
    ddi = {'period': item['period']}
    for k,v in item['epsRevisions'].items():
        if not isinstance(v, dict) or len(v) == 0:
            continue
        ddi[k] = v['raw']
    dd.append(ddi)
self._eps_revisions = pd.DataFrame(dd).set_index('period')

@R5dan
Copy link
Contributor

R5dan commented Dec 29, 2024

And what if Yahoo changes another key?

Yes, especially as they already have added one: 90 days

@dhruvan2006 dhruvan2006 force-pushed the fix/eps-revisions branch 2 times, most recently from 34512be to eae74ae Compare December 30, 2024 12:59
@dhruvan2006 dhruvan2006 changed the title Fixed EPS Revisions modified keys Fixed hardcoded keys in EPS Revisions Dec 30, 2024
@ValueRaider
Copy link
Collaborator

Do you mind refactoring the other fetch functions?

@dhruvan2006 dhruvan2006 changed the title Fixed hardcoded keys in EPS Revisions Fix: Remove hardcoded keys in Analysis Dec 31, 2024
@dhruvan2006
Copy link
Contributor Author

Do you mind refactoring the other fetch functions?

Done. Edited PR description to show changes to end result

Refactor some fetch functions (duplicate logic).
Fix failing unit tests.
@ValueRaider ValueRaider merged commit 52f6462 into ranaroussi:dev Jan 1, 2025
2 checks passed
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