Update StockFinancial model (net income, EPS, and parent net income loss) #817
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactored the balance_sheet, income_statement, cash_flow_statement, and comprehensive_income sections to use typed classes and explicit fields rather than raw dictionaries. Now, each possible field from the openapi spec is represented as an optional
DataPoint
, ensuring we can reliably access typed data without manual dictionary lookups.This aligns with how other APIs in the repo handle typed fields (e.g., ticker details). It provides a more user-friendly interface, improves code consistency, and reduces the risk of missing or mistyping field names. Note that fields will only be present if their values were directly reported, or if they can be computed based on other data points in the underlying data.
Each field has a direct, typed attribute (
Optional[DataPoint]
). If a field is absent in the API response, it gets set toNone
, ensuring consistent typed access. Thefrom_dict(...)
constructors build each typed object from the JSON response automatically.Here's an example for fetching
diluted_earnings_per_share
andnet_income_loss
:Here's the output:
Here's an example of getting everything:
Here's the output: