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 Diluted EPS(Earnings-Per-Share) #801

Closed
wants to merge 2 commits into from

Conversation

Raptorly1
Copy link

Fixes #792

This pull request includes changes to the polygon/rest/models/financials.py file, primarily focusing on the addition of DilutedEarningsPerShare and the inclusion of this in the IncomeStatement class. Additionally, there are corresponding updates to the test file test_rest/test_financials.py.

New Class Addition:

  • Added a new class DilutedEarningsPerShare to represent diluted earnings per share data for an income statement. This class includes the standard attributes I saw: formula, label, order, unit, value, and xpath, along with a from_dict method.

Updates to Existing Classes:

  • Updated the IncomeStatement class to include an optional diluted_earnings_per_share attribute.
  • Modified the from_dict method of the IncomeStatement class to handle the new diluted_earnings_per_share attribute.

Test Updates:

  • Added DilutedEarningsPerShare to the import statements in the test_rest/test_financials.py file.
  • Updated the test_list_stock_financials method to test the new diluted_earnings_per_share attribute in the IncomeStatement class.

@Raptorly1 Raptorly1 changed the title Add Diluted EPS(Earnings-Per-Share Add Diluted EPS(Earnings-Per-Share) Dec 6, 2024
@justinpolygon
Copy link
Contributor

Hey @Raptorly1, thanks for the PR. I ended up putting together a much large fix that aligns with how we use the other APIs. I'm going to close this PR but this is fixed now via #817 and is in the latest release https://github.com/polygon-io/client-python/releases/tag/v1.14.3.

You should be able to just run pip install -U polygon-api-client to get the latest update.

Here's an example for fetching diluted_earnings_per_share and net_income_loss:

from polygon import RESTClient

client = RESTClient()  # POLYGON_API_KEY environment variable is used

financials = []
for f in client.vx.list_stock_financials("AAPL", filing_date="2024-11-01"):
    financials.append(f)

    # get diluted_earnings_per_share
    print(f.financials.income_statement.diluted_earnings_per_share)

    # get net_income_loss
    print(f.financials.income_statement.net_income_loss)

Here's the output:

$ python3 examples/rest/stocks-stock_financials.py

DataPoint(
    label="Diluted Earnings Per Share",
    order=4300,
    unit="USD / shares",
    value=6.08,
    derived_from=None,
    formula=None,
    source=None,
    xpath=None,
)
DataPoint(
    label="Net Income/Loss",
    order=3200,
    unit="USD",
    value=93736000000.0,
    derived_from=None,
    formula=None,
    source=None,
    xpath=None,
)
DataPoint(
    label="Diluted Earnings Per Share",
    order=4300,
    unit="USD / shares",
    value=6.08,
    derived_from=None,
    formula=None,
    source=None,
    xpath=None,
)
DataPoint(
    label="Net Income/Loss",
    order=3200,
    unit="USD",
    value=93736000000.0,
    derived_from=None,
    formula=None,
    source=None,
    xpath=None,
)

@Raptorly1
Copy link
Author

Thank you @justinpolygon . Is there anything like Slack or a roadmap for Polygon so I can see if a fix is already being worked on?

@Raptorly1 Raptorly1 deleted the Diluted-EPS branch January 10, 2025 01:26
@Raptorly1 Raptorly1 restored the Diluted-EPS branch January 10, 2025 01:26
@justinpolygon
Copy link
Contributor

Hey @Raptorly1, we have a public roadmap here and you can also ask for things you're interested in too.

https://polygon.io/product-roadmap

Cheers,
Justin

@Raptorly1
Copy link
Author

Good to know! Thanks!

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.

Missing diluted earnings-per-share from Financials.income_statement
2 participants