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

Update StockFinancial model (net income, EPS, and parent net income loss) #817

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

justinpolygon
Copy link
Contributor

@justinpolygon justinpolygon commented Dec 24, 2024

Enhance StockFinancial model with additional financial fields for net income, EPS, and parent net income loss.

Here's an example:

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)
print(financials)

Here's the output:

$ python3 examples/rest/stocks-stock_financials.py

[
    StockFinancial(
        cik="0000320193",
        company_name="Apple Inc.",
        end_date="2024-09-28",
        filing_date="2024-11-01",
        financials=Financials(
            balance_sheet={
                "liabilities": DataPoint(
                    label="Liabilities",
                    order=600,
                    unit="USD",
                    value=308030000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "equity": DataPoint(
                    label="Equity",
                    order=1400,
                    unit="USD",
                    value=56950000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "assets": DataPoint(
                    label="Assets",
                    order=100,
                    unit="USD",
                    value=364980000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "other_current_liabilities": DataPoint(
                    label="Other Current Liabilities",
                    order=740,
                    unit="USD",
                    value=107432000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "liabilities_and_equity": DataPoint(
                    label="Liabilities And Equity",
                    order=1900,
                    unit="USD",
                    value=364980000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "other_noncurrent_assets": DataPoint(
                    label="Other Non-current Assets",
                    order=350,
                    unit="USD",
                    value=166313000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "noncurrent_liabilities": DataPoint(
                    label="Noncurrent Liabilities",
                    order=800,
                    unit="USD",
                    value=131638000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "accounts_payable": DataPoint(
                    label="Accounts Payable",
                    order=710,
                    unit="USD",
                    value=68960000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "other_noncurrent_liabilities": DataPoint(
                    label="Other Non-current Liabilities",
                    order=820,
                    unit="USD",
                    value=34976000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "equity_attributable_to_noncontrolling_interest": DataPoint(
                    label="Equity Attributable To Noncontrolling Interest",
                    order=1500,
                    unit="USD",
                    value=0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "inventory": DataPoint(
                    label="Inventory",
                    order=230,
                    unit="USD",
                    value=7286000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "long_term_debt": DataPoint(
                    label="Long-term Debt",
                    order=810,
                    unit="USD",
                    value=96662000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "other_current_assets": DataPoint(
                    label="Other Current Assets",
                    order=250,
                    unit="USD",
                    value=145701000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "equity_attributable_to_parent": DataPoint(
                    label="Equity Attributable To Parent",
                    order=1600,
                    unit="USD",
                    value=56950000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "current_liabilities": DataPoint(
                    label="Current Liabilities",
                    order=700,
                    unit="USD",
                    value=176392000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "noncurrent_assets": DataPoint(
                    label="Noncurrent Assets",
                    order=300,
                    unit="USD",
                    value=211993000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "current_assets": DataPoint(
                    label="Current Assets",
                    order=200,
                    unit="USD",
                    value=152987000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "fixed_assets": DataPoint(
                    label="Fixed Assets",
                    order=320,
                    unit="USD",
                    value=45680000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
            },
            cash_flow_statement={
                "net_cash_flow_continuing": DataPoint(
                    label="Net Cash Flow, Continuing",
                    order=1200,
                    unit="USD",
                    value=-794000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "net_cash_flow_from_investing_activities_continuing": DataPoint(
                    label="Net Cash Flow From Investing Activities, Continuing",
                    order=500,
                    unit="USD",
                    value=2935000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "net_cash_flow": DataPoint(
                    label="Net Cash Flow",
                    order=1100,
                    unit="USD",
                    value=-794000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "net_cash_flow_from_operating_activities_continuing": DataPoint(
                    label="Net Cash Flow From Operating Activities, Continuing",
                    order=200,
                    unit="USD",
                    value=118254000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "net_cash_flow_from_financing_activities_continuing": DataPoint(
                    label="Net Cash Flow From Financing Activities, Continuing",
                    order=800,
                    unit="USD",
                    value=-121983000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "net_cash_flow_from_investing_activities": DataPoint(
                    label="Net Cash Flow From Investing Activities",
                    order=400,
                    unit="USD",
                    value=2935000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "net_cash_flow_from_financing_activities": DataPoint(
                    label="Net Cash Flow From Financing Activities",
                    order=700,
                    unit="USD",
                    value=-121983000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "net_cash_flow_from_operating_activities": DataPoint(
                    label="Net Cash Flow From Operating Activities",
                    order=100,
                    unit="USD",
                    value=118254000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
            },
            comprehensive_income={
                "other_comprehensive_income_loss": DataPoint(
                    label="Other Comprehensive Income/Loss",
                    order=400,
                    unit="USD",
                    value=98016000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "comprehensive_income_loss_attributable_to_parent": DataPoint(
                    label="Comprehensive Income/Loss Attributable To Parent",
                    order=300,
                    unit="USD",
                    value=98016000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "other_comprehensive_income_loss_attributable_to_parent": DataPoint(
                    label="Other Comprehensive Income/Loss Attributable To Parent",
                    order=600,
                    unit="USD",
                    value=4280000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "comprehensive_income_loss_attributable_to_noncontrolling_interest": DataPoint(
                    label="Comprehensive Income/Loss Attributable To Noncontrolling Interest",
                    order=200,
                    unit="USD",
                    value=0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "comprehensive_income_loss": DataPoint(
                    label="Comprehensive Income/Loss",
                    order=100,
                    unit="USD",
                    value=98016000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
            },
            income_statement={
                "net_income_loss_attributable_to_parent": DataPoint(
                    label="Net Income/Loss Attributable To Parent",
                    order=3500,
                    unit="USD",
                    value=93736000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "net_income_loss": DataPoint(
                    label="Net Income/Loss",
                    order=3200,
                    unit="USD",
                    value=93736000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "nonoperating_income_loss": DataPoint(
                    label="Nonoperating Income/Loss",
                    order=900,
                    unit="USD",
                    value=269000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "gross_profit": DataPoint(
                    label="Gross Profit",
                    order=800,
                    unit="USD",
                    value=180683000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "participating_securities_distributed_and_undistributed_earnings_loss_basic": DataPoint(
                    label="Participating Securities, Distributed And Undistributed Earnings/Loss, Basic",
                    order=3800,
                    unit="USD",
                    value=0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "diluted_average_shares": DataPoint(
                    label="Diluted Average Shares",
                    order=4500,
                    unit="shares",
                    value=15408095000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "operating_expenses": DataPoint(
                    label="Operating Expenses",
                    order=1000,
                    unit="USD",
                    value=57467000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "operating_income_loss": DataPoint(
                    label="Operating Income/Loss",
                    order=1100,
                    unit="USD",
                    value=123216000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "income_loss_from_continuing_operations_after_tax": DataPoint(
                    label="Income/Loss From Continuing Operations After Tax",
                    order=1400,
                    unit="USD",
                    value=93736000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "revenues": DataPoint(
                    label="Revenues",
                    order=100,
                    unit="USD",
                    value=391035000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "benefits_costs_expenses": DataPoint(
                    label="Benefits Costs and Expenses",
                    order=200,
                    unit="USD",
                    value=267550000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "income_tax_expense_benefit": DataPoint(
                    label="Income Tax Expense/Benefit",
                    order=2200,
                    unit="USD",
                    value=29749000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "costs_and_expenses": DataPoint(
                    label="Costs And Expenses",
                    order=600,
                    unit="USD",
                    value=267550000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "preferred_stock_dividends_and_other_adjustments": DataPoint(
                    label="Preferred Stock Dividends And Other Adjustments",
                    order=3900,
                    unit="USD",
                    value=0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "basic_earnings_per_share": DataPoint(
                    label="Basic Earnings Per Share",
                    order=4200,
                    unit="USD / shares",
                    value=6.11,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "diluted_earnings_per_share": DataPoint(
                    label="Diluted Earnings Per Share",
                    order=4300,
                    unit="USD / shares",
                    value=6.08,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "basic_average_shares": DataPoint(
                    label="Basic Average Shares",
                    order=4400,
                    unit="shares",
                    value=15343783000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "selling_general_and_administrative_expenses": DataPoint(
                    label="Selling, General, and Administrative Expenses",
                    order=1010,
                    unit="USD",
                    value=26097000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "research_and_development": DataPoint(
                    label="Research and Development",
                    order=1030,
                    unit="USD",
                    value=31370000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "net_income_loss_available_to_common_stockholders_basic": DataPoint(
                    label="Net Income/Loss Available To Common Stockholders, Basic",
                    order=3700,
                    unit="USD",
                    value=93736000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "cost_of_revenue": DataPoint(
                    label="Cost Of Revenue",
                    order=300,
                    unit="USD",
                    value=210352000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "net_income_loss_attributable_to_noncontrolling_interest": DataPoint(
                    label="Net Income/Loss Attributable To Noncontrolling Interest",
                    order=3300,
                    unit="USD",
                    value=0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
                "income_loss_from_continuing_operations_before_tax": DataPoint(
                    label="Income/Loss From Continuing Operations Before Tax",
                    order=1500,
                    unit="USD",
                    value=123485000000.0,
                    derived_from=None,
                    formula=None,
                    source=None,
                    xpath=None,
                ),
            },
        ),
        fiscal_period="TTM",
        fiscal_year="2024",
        source_filing_file_url="http://api.polygon.io/v1/reference/sec/filings/0000320193-24-000123/files/aapl-20240928_htm.xml",
        source_filing_url="https://api.polygon.io/v1/reference/sec/filings/0000320193-24-000123",
        start_date="2023-10-01",
    )
]

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.

1 participant