Skip to content

Commit 77a7a7e

Browse files
author
clickingbuttons
authored
fix financials and add example (#173)
* fix financials and add example * style
1 parent 49442ae commit 77a7a7e

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

examples/rest/financials.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from polygon import RESTClient
2+
3+
client = RESTClient()
4+
5+
financials = client.get_ticker_details("NFLX")
6+
print(financials)

polygon/rest/models/tickers.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44

55

66
@dataclass
7-
class Address:
7+
class CompanyAddress:
88
"Contains address data for a ticker detail."
99
address1: Optional[str] = None
10+
address2: Optional[str] = None
1011
city: Optional[str] = None
1112
state: Optional[str] = None
13+
country: Optional[str] = None
1214
postal_code: Optional[str] = None
1315

1416
@staticmethod
1517
def from_dict(d):
16-
return Address(**d)
18+
return CompanyAddress(**d)
1719

1820

1921
@dataclass
@@ -69,7 +71,7 @@ def from_dict(d):
6971
class TickerDetails:
7072
"TickerDetails contains data for a specified ticker symbol."
7173
active: Optional[bool] = None
72-
address: Optional[Address] = None
74+
address: Optional[CompanyAddress] = None
7375
branding: Optional[Branding] = None
7476
cik: Optional[str] = None
7577
composite_figi: Optional[str] = None
@@ -98,7 +100,9 @@ class TickerDetails:
98100
def from_dict(d):
99101
return TickerDetails(
100102
active=d.get("active", None),
101-
address=None if "address" not in d else Address.from_dict(d["address"]),
103+
address=None
104+
if "address" not in d
105+
else CompanyAddress.from_dict(d["address"]),
102106
branding=None if "branding" not in d else Branding.from_dict(d["branding"]),
103107
cik=d.get("cik", None),
104108
composite_figi=d.get("composite_figi", None),

test_rest/test_tickers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
TickerTypes,
66
Publisher,
77
Branding,
8-
Address,
8+
CompanyAddress,
99
)
1010
from base import BaseTest
1111

@@ -93,7 +93,7 @@ def test_get_ticker_details(self):
9393
details = self.c.get_ticker_details("AAPL")
9494
expected = TickerDetails(
9595
active=True,
96-
address=Address(
96+
address=CompanyAddress(
9797
address1="ONE APPLE PARK WAY",
9898
city="CUPERTINO",
9999
state="CA",

0 commit comments

Comments
 (0)