Skip to content

Commit 610ea11

Browse files
committed
addinf net income loss fields
1 parent c2f955e commit 610ea11

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

polygon/rest/models/financials.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,66 @@ def from_dict(d):
248248
return Revenues(**d)
249249

250250

251+
@modelclass
252+
class NetIncomeLoss:
253+
"Contains net income loss data for an income statement."
254+
formula: Optional[str] = None
255+
label: Optional[str] = None
256+
order: Optional[int] = None
257+
unit: Optional[str] = None
258+
value: Optional[float] = None
259+
xpath: Optional[str] = None
260+
261+
@staticmethod
262+
def from_dict(d):
263+
return NetIncomeLoss(**d)
264+
265+
266+
@modelclass
267+
class NetIncomeLossAttributableToNoncontrollingInterest:
268+
"Contains net income loss attributable to noncontrolling interest data for an income statement."
269+
formula: Optional[str] = None
270+
label: Optional[str] = None
271+
order: Optional[int] = None
272+
unit: Optional[str] = None
273+
value: Optional[float] = None
274+
xpath: Optional[str] = None
275+
276+
@staticmethod
277+
def from_dict(d):
278+
return NetIncomeLossAttributableToNoncontrollingInterest(**d)
279+
280+
281+
@modelclass
282+
class NetIncomeLossAttributableToParent:
283+
"Contains net income loss attributable to parent data for an income statement."
284+
formula: Optional[str] = None
285+
label: Optional[str] = None
286+
order: Optional[int] = None
287+
unit: Optional[str] = None
288+
value: Optional[float] = None
289+
xpath: Optional[str] = None
290+
291+
@staticmethod
292+
def from_dict(d):
293+
return NetIncomeLossAttributableToParent(**d)
294+
295+
296+
@modelclass
297+
class NetIncomeLossAvailableToCommonStockholdersBasic:
298+
"Contains net income loss available to common stockholders basic data for an income statement."
299+
formula: Optional[str] = None
300+
label: Optional[str] = None
301+
order: Optional[int] = None
302+
unit: Optional[str] = None
303+
value: Optional[float] = None
304+
xpath: Optional[str] = None
305+
306+
@staticmethod
307+
def from_dict(d):
308+
return NetIncomeLossAvailableToCommonStockholdersBasic(**d)
309+
310+
251311
@modelclass
252312
class IncomeStatement:
253313
"Contains income statement data."
@@ -256,6 +316,16 @@ class IncomeStatement:
256316
gross_profit: Optional[GrossProfit] = None
257317
operating_expenses: Optional[OperatingExpenses] = None
258318
revenues: Optional[Revenues] = None
319+
net_income_loss: Optional[NetIncomeLoss] = None
320+
net_income_loss_attributable_to_noncontrolling_interest: Optional[
321+
NetIncomeLossAttributableToNoncontrollingInterest
322+
] = None
323+
net_income_loss_attributable_to_parent: Optional[
324+
NetIncomeLossAttributableToParent
325+
] = None
326+
net_income_loss_available_to_common_stockholders_basic: Optional[
327+
NetIncomeLossAvailableToCommonStockholdersBasic
328+
] = None
259329

260330
@staticmethod
261331
def from_dict(d):
@@ -281,6 +351,32 @@ def from_dict(d):
281351
else OperatingExpenses.from_dict(d["operating_expenses"])
282352
),
283353
revenues=None if "revenues" not in d else Revenues.from_dict(d["revenues"]),
354+
net_income_loss=(
355+
None
356+
if "net_income_loss" not in d
357+
else NetIncomeLoss.from_dict(d["net_income_loss"])
358+
),
359+
net_income_loss_attributable_to_noncontrolling_interest=(
360+
None
361+
if "net_income_loss_attributable_to_noncontrolling_interest" not in d
362+
else NetIncomeLoss.from_dict(
363+
d["net_income_loss_attributable_to_noncontrolling_interest"]
364+
)
365+
),
366+
net_income_loss_attributable_to_parent=(
367+
None
368+
if "net_income_loss_attributable_to_parent" not in d
369+
else NetIncomeLoss.from_dict(
370+
d["net_income_loss_attributable_to_parent"]
371+
)
372+
),
373+
net_income_loss_available_to_common_stockholders_basic=(
374+
None
375+
if "net_income_loss_available_to_common_stockholders_basic" not in d
376+
else NetIncomeLoss.from_dict(
377+
d["net_income_loss_available_to_common_stockholders_basic"]
378+
)
379+
),
284380
)
285381

286382

test_rest/test_financials.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
GrossProfit,
1717
OperatingExpenses,
1818
Revenues,
19+
NetIncomeLoss,
20+
NetIncomeLossAttributableToNoncontrollingInterest,
21+
NetIncomeLossAttributableToParent,
22+
NetIncomeLossAvailableToCommonStockholdersBasic,
1923
)
2024
from base import BaseTest
2125

@@ -221,6 +225,38 @@ def test_list_stock_financials(self):
221225
value=3136000000.0,
222226
xpath=None,
223227
),
228+
net_income_loss=NetIncomeLoss(
229+
formula=None,
230+
label="Net Income/Loss",
231+
value=6.66e08,
232+
unit="USD",
233+
order=3200,
234+
xpath=None,
235+
),
236+
net_income_loss_attributable_to_noncontrolling_interest=NetIncomeLossAttributableToNoncontrollingInterest(
237+
formula=None,
238+
label="Net Income/Loss Attributable To Noncontrolling Interest",
239+
value=9e06,
240+
unit="USD",
241+
order=3200,
242+
xpath=None,
243+
),
244+
net_income_loss_attributable_to_parent=NetIncomeLossAttributableToParent(
245+
formula=None,
246+
label="Net Income/Loss Attributable To Parent",
247+
value=6.57e08,
248+
unit="USD",
249+
order=3500,
250+
xpath=None,
251+
),
252+
net_income_loss_available_to_common_stockholders_basic=NetIncomeLossAvailableToCommonStockholdersBasic(
253+
formula=None,
254+
label="Net Income/Loss Available To Common Stockholders, Basic",
255+
value=6.57e08,
256+
unit="USD",
257+
order=3700,
258+
xpath=None,
259+
),
224260
),
225261
),
226262
fiscal_period="Q1",

0 commit comments

Comments
 (0)