client-python icon indicating copy to clipboard operation
client-python copied to clipboard

Adding net income loss fields

Open tsugumi-sys opened this issue 1 year ago • 2 comments

close #715

tsugumi-sys avatar Jul 24 '24 12:07 tsugumi-sys

@justinpolygon Hey, could you review this, will it take much longer for the review???

tsugumi-sys avatar Aug 18 '24 12:08 tsugumi-sys

Sorry for all the notifications here. I'm just making sure all the fields match and then getting the tests to run correctly. Move to draft to stop all the notifications while we iron things out.

justinpolygon avatar Aug 27 '24 18:08 justinpolygon

Hey @tsugumi-sys, 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 https://github.com/polygon-io/client-python/pull/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,
)

justinpolygon avatar Jan 09 '25 17:01 justinpolygon

@justinpolygon Thank you very much!

tsugumi-sys avatar Jan 11 '25 04:01 tsugumi-sys