Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions polygon/rest/models/tickers.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,8 @@ class TickerDetails:
def from_dict(d):
return TickerDetails(
active=d.get("active", None),
address=None if "address" not in d else [Address.from_dict(d["address"])],
branding=None
if "branding" not in d
else [Branding.from_dict(d["branding"])],
address=None if "address" not in d else Address.from_dict(d["address"]),
branding=None if "branding" not in d else Branding.from_dict(d["branding"]),
cik=d.get("cik", None),
composite_figi=d.get("composite_figi", None),
currency_name=d.get("currency_name", None),
Expand Down
6 changes: 5 additions & 1 deletion polygon/rest/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ def get_ticker_details(
url = f"/v3/reference/tickers/{ticker}"

return self._get(
path=url, params=params, deserializer=TickerDetails.from_dict, raw=raw
path=url,
params=params,
deserializer=TickerDetails.from_dict,
raw=raw,
result_key="results",
)

def list_ticker_news(
Expand Down
2 changes: 2 additions & 0 deletions rest-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
print(aggs)
aggs = client.get_aggs("AAPL", 1, "day", date(2005, 4, 4), datetime(2005, 4, 4))
print(aggs)
details = client.get_ticker_details('AAPL')
print(details)
70 changes: 37 additions & 33 deletions test_rest/mocks/v3/reference/tickers/AAPL.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
{
"ticker": "AAPL",
"name": "Apple Inc.",
"market": "stocks",
"locale": "us",
"primary_exchange": "XNAS",
"type": "CS",
"active": true,
"currency_name": "usd",
"cik": "0000320193",
"composite_figi": "BBG000B9XRY4",
"share_class_figi": "BBG001S5N8V8",
"market_cap": 2671492491700.0,
"phone_number": "(408) 996-1010",
"address": {
"address1": "ONE APPLE PARK WAY",
"city": "CUPERTINO",
"state": "CA",
"postal_code": "95014"
},
"description": "Apple designs a wide variety of consumer electronic devices, including smartphones (iPhone), tablets (iPad), PCs (Mac), smartwatches (Apple Watch), AirPods, and TV boxes (Apple TV), among others. The iPhone makes up the majority of Apples total revenue. In addition, Apple offers its customers a variety of services such as Apple Music, iCloud, Apple Care, Apple TV+, Apple Arcade, Apple Card, and Apple Pay, among others. Apples products run internally developed software and semiconductors, and the firm is well known for its integration of hardware, software and services. Apples products are distributed online as well as through company-owned stores and third-party retailers. The company generates roughly 40 of its revenue from the Americas, with the remainder earned internationally.",
"sic_code": "3571",
"sic_description": "ELECTRONIC COMPUTERS",
"ticker_root": "AAPL",
"homepage_url": "https://www.apple.com",
"total_employees": 154000,
"list_date": "1980-12-12",
"branding": {
"logo_url": "https://api.polygon.io/v1/reference/company-branding/d3d3LmFwcGxlLmNvbQ/images/2022-02-01_logo.svg",
"icon_url": "https://api.polygon.io/v1/reference/company-branding/d3d3LmFwcGxlLmNvbQ/images/2022-02-01_icon.png"
},
"share_class_shares_outstanding": 16319440000,
"weighted_shares_outstanding": 16319441000
}
"results": {
"ticker": "AAPL",
"name": "Apple Inc.",
"market": "stocks",
"locale": "us",
"primary_exchange": "XNAS",
"type": "CS",
"active": true,
"currency_name": "usd",
"cik": "0000320193",
"composite_figi": "BBG000B9XRY4",
"share_class_figi": "BBG001S5N8V8",
"market_cap": 2488795282370,
"phone_number": "(408) 996-1010",
"address": {
"address1": "ONE APPLE PARK WAY",
"city": "CUPERTINO",
"state": "CA",
"postal_code": "95014"
},
"description": "Apple designs a wide variety of consumer electronic devices, including smartphones (iPhone), tablets (iPad), PCs (Mac), smartwatches (Apple Watch), AirPods, and TV boxes (Apple TV), among others. The iPhone makes up the majority of Apple's total revenue. In addition, Apple offers its customers a variety of services such as Apple Music, iCloud, Apple Care, Apple TV+, Apple Arcade, Apple Card, and Apple Pay, among others. Apple's products run internally developed software and semiconductors, and the firm is well known for its integration of hardware, software and services. Apple's products are distributed online as well as through company-owned stores and third-party retailers. The company generates roughly 40% of its revenue from the Americas, with the remainder earned internationally.",
"sic_code": "3571",
"sic_description": "ELECTRONIC COMPUTERS",
"ticker_root": "AAPL",
"homepage_url": "https://www.apple.com",
"total_employees": 154000,
"list_date": "1980-12-12",
"branding": {
"logo_url": "https://api.polygon.io/v1/reference/company-branding/d3d3LmFwcGxlLmNvbQ/images/2022-05-01_logo.svg",
"icon_url": "https://api.polygon.io/v1/reference/company-branding/d3d3LmFwcGxlLmNvbQ/images/2022-05-01_icon.png"
},
"share_class_shares_outstanding": 16319440000,
"weighted_shares_outstanding": 16185181000
},
"status": "OK",
"request_id": "ce8688b5f3a571351376ebd77acd146e"
}
30 changes: 13 additions & 17 deletions test_rest/test_tickers.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,31 +93,27 @@ def test_get_ticker_details(self):
details = self.c.get_ticker_details("AAPL")
expected = TickerDetails(
active=True,
address=[
Address(
address1="ONE APPLE PARK WAY",
city="CUPERTINO",
state="CA",
postal_code="95014",
)
],
branding=[
Branding(
icon_url="https://api.polygon.io/v1/reference/company-branding/d3d3LmFwcGxlLmNvbQ/images/2022-02-01_icon.png",
logo_url="https://api.polygon.io/v1/reference/company-branding/d3d3LmFwcGxlLmNvbQ/images/2022-02-01_logo.svg",
)
],
address=Address(
address1="ONE APPLE PARK WAY",
city="CUPERTINO",
state="CA",
postal_code="95014",
),
branding=Branding(
icon_url="https://api.polygon.io/v1/reference/company-branding/d3d3LmFwcGxlLmNvbQ/images/2022-05-01_icon.png",
logo_url="https://api.polygon.io/v1/reference/company-branding/d3d3LmFwcGxlLmNvbQ/images/2022-05-01_logo.svg",
),
cik="0000320193",
composite_figi="BBG000B9XRY4",
currency_name="usd",
delisted_utc=None,
description="Apple designs a wide variety of consumer electronic devices, including smartphones (iPhone), tablets (iPad), PCs (Mac), smartwatches (Apple Watch), AirPods, and TV boxes (Apple TV), among others. The iPhone makes up the majority of Apples total revenue. In addition, Apple offers its customers a variety of services such as Apple Music, iCloud, Apple Care, Apple TV+, Apple Arcade, Apple Card, and Apple Pay, among others. Apples products run internally developed software and semiconductors, and the firm is well known for its integration of hardware, software and services. Apples products are distributed online as well as through company-owned stores and third-party retailers. The company generates roughly 40 of its revenue from the Americas, with the remainder earned internationally.",
description="Apple designs a wide variety of consumer electronic devices, including smartphones (iPhone), tablets (iPad), PCs (Mac), smartwatches (Apple Watch), AirPods, and TV boxes (Apple TV), among others. The iPhone makes up the majority of Apple's total revenue. In addition, Apple offers its customers a variety of services such as Apple Music, iCloud, Apple Care, Apple TV+, Apple Arcade, Apple Card, and Apple Pay, among others. Apple's products run internally developed software and semiconductors, and the firm is well known for its integration of hardware, software and services. Apple's products are distributed online as well as through company-owned stores and third-party retailers. The company generates roughly 40% of its revenue from the Americas, with the remainder earned internationally.",
ticker_root="AAPL",
homepage_url="https://www.apple.com",
list_date="1980-12-12",
locale="us",
market="stocks",
market_cap=2671492491700.0,
market_cap=2488795282370,
name="Apple Inc.",
phone_number="(408) 996-1010",
primary_exchange="XNAS",
Expand All @@ -128,7 +124,7 @@ def test_get_ticker_details(self):
ticker="AAPL",
total_employees=154000,
type="CS",
weighted_shares_outstanding=16319441000,
weighted_shares_outstanding=16185181000,
)
self.assertEqual(details, expected)

Expand Down