10000 Add IPOs support (#816) · polygon-io/client-python@d89bcec · GitHub
[go: up one dir, main page]

Skip to content

Commit d89bcec

Browse files
Add IPOs support (#816)
1 parent 0ebde26 commit d89bcec

File tree

3 files changed

+113
-2
lines changed

3 files changed

+113
-2
lines changed

examples/rest/stocks-ipos.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from polygon import RESTClient
2+
3+
# docs
4+
# https://polygon.io/docs/stocks/get_vx_reference_ipos
5+
6+
# client = RESTClient("XXXXXX") # hardcoded api_key is used
7+
client = RESTClient() # POLYGON_API_KEY environment variable is used
8+
9+
ipos = []
10+
for ipo in client.vx.list_ipos(ticker="RDDT"):
11+
ipos.append(ipo)
12+
13+
print(ipos)

polygon/rest/models/tickers.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,60 @@ class TickerChangeResults:
253253
@staticmethod
254254
def from_dict(d):
255255
return TickerChangeResults(**d)
256+
257+
258+
from typing import Optional
259+
from ...modelclass import modelclass
260+
261+
262+
@modelclass
263+
class IPOListing:
264+
"""
265+
IPO Listing data as returned by the /vX/reference/ipos endpoint.
266+
"""
267+
268+
announced_date: Optional[str] = None
269+
currency_code: Optional[str] = None
270+
final_issue_price: Optional[float] = None
271+
highest_offer_price: Optional[float] = None
272+
ipo_status: Optional[str] = None
273+
isin: Optional[str] = None
274+
issuer_name: Optional[str] = None
275+
last_updated: Optional[str] = None
276+
listing_date: Optional[str] = None
277+
lot_size: Optional[int] = None
278+
lowest_offer_price: Optional[float] = None
279+
max_shares_offered: Optional[int] = None
280+
min_shares_offered: Optional[int] = None
281+
primary_exchange: Optional[str] = None
282+
security_description: Optional[str] = None
283+
security_type: Optional[str] = None
284+
shares_outstanding: Optional[int] = None
285+
ticker: Optional[str] = None
286+
total_offer_size: Optional[float] = None
287+
us_code: Optional[str] = None
288+
289+
@staticmethod
290+
def from_dict(d):
291+
return IPOListing(
292+
announced_date=d.get("announced_date"),
293+
currency_code=d.get("currency_code"),
294+
final_issue_price=d.get("final_issue_price"),
295+
highest_offer_price=d.get("highest_offer_price"),
296+
ipo_status=d.get("ipo_status"),
297+
isin=d.get("isin"),
298+
issuer_name=d.get("issuer_name"),
299+
last_updated=d.get("last_updated"),
300+
listing_date=d.get("listing_date"),
301+
lot_size=d.get("lot_size"),
302+
lowest_offer_price=d.get("lowest_offer_price"),
303+
max_shares_offered=d.get("max_shares_offered"),
304+
min_shares_offered=d.get("min_shares_offered"),
305+
primary_exchange=d.get("primary_exchange"),
306+
security_description=d.get("security_description"),
307+
security_type=d.get("security_type"),
308+
shares_outstanding=d.get("shares_outstanding"),
309+
ticker=d.get("ticker"),
310+
total_offer_size=d.get("total_offer_size"),
311+
us_code=d.get("us_code"),
312+
)

polygon/rest/vX.py

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from .base import BaseClient
2-
from typing import Optional, Any, Dict, Union, Iterator
3-
from .models import StockFinancial, Timeframe, Sort, Order
2+
from typing import Optional, Any, Dict, List, Union, Iterator
3+
from .models import StockFinancial, IPOListing, Timeframe, Sort, Order
44
from urllib3 import HTTPResponse
55
from datetime import datetime, date
66

@@ -70,3 +70,44 @@ def list_stock_financials(
7070
deserializer=StockFinancial.from_dict,
7171
options=options,
7272
)
73+
74+
def list_ipos(
75+
self,
76+
ticker: Optional[str] = None,
77+
us_code: Optional[str] = None,
78+
isin: Optional[str] = None,
79+
listing_date: Optional[str] = None,
80+
ipo_status: Optional[str] = None,
81+
limit: Optional[int] = None,
82+
sort: Optional[Union[str, Sort]] = None,
83+
order: Optional[Union[str, Order]] = None,
84+
params: Optional[Dict[str, Any]] = None,
85+
raw: bool = False,
86+
options: Optional[RequestOptionBuilder] = None,
87+
) -> Union[List[IPOListing], HTTPResponse]:
88+
"""
89+
Retrieve upcoming or historical IPOs.
90+
91+
:param ticker: Filter by a case-sensitive ticker symbol.
92+
:param us_code: Filter by a US code (unique identifier for a North American financial security).
93+
:param isin: Filter by an International Securities Identification Number (ISIN).
94+
:param listing_date: Filter by the listing date (YYYY-MM-DD).
95+
:param ipo_status: Filter by IPO status (e.g. "new", "pending", "history", etc.).
96+
:param limit: Limit the number of results per page. Default 10, max 1000.
97+
:param sort: Field to sort by. Default is "listing_date".
98+
:param order: Order results based on the sort field ("asc" or "desc"). Default "desc".
99+
:param params: Additional query params.
100+
:param raw: Return raw HTTPResponse object if True, else return List[IPOListing].
101+
:param options: RequestOptionBuilder for additional headers or params.
102+
:return: A list of IPOListing objects or HTTPResponse if raw=True.
103+
"""
104+
url = "/vX/reference/ipos"
105+
106+
return self._paginate(
107+
path=url,
108+
params=self._get_params(self.list_ipos, locals()),
109+
deserializer=IPOListing.from_dict,
110+
raw=raw,
111+
result_key="results",
112+
options=options,
113+
)

0 commit comments

Comments
 (0)
0