Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IPOs support #816

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions examples/rest/stocks-ipos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from polygon import RESTClient

# docs
# https://polygon.io/docs/stocks/get_vx_reference_ipos

# client = RESTClient("XXXXXX") # hardcoded api_key is used
client = RESTClient() # POLYGON_API_KEY environment variable is used

ipos = []
for ipo in client.vx.list_ipos(ticker="RDDT"):
ipos.append(ipo)

print(ipos)
57 changes: 57 additions & 0 deletions polygon/rest/models/tickers.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,60 @@ class TickerChangeResults:
@staticmethod
def from_dict(d):
return TickerChangeResults(**d)


from typing import Optional
from ...modelclass import modelclass


@modelclass
class IPOListing:
"""
IPO Listing data as returned by the /vX/reference/ipos endpoint.
"""

announced_date: Optional[str] = None
currency_code: Optional[str] = None
final_issue_price: Optional[float] = None
highest_offer_price: Optional[float] = None
ipo_status: Optional[str] = None
isin: Optional[str] = None
issuer_name: Optional[str] = None
last_updated: Optional[str] = None
listing_date: Optional[str] = None
lot_size: Optional[int] = None
lowest_offer_price: Optional[float] = None
max_shares_offered: Optional[int] = None
min_shares_offered: Optional[int] = None
primary_exchange: Optional[str] = None
security_description: Optional[str] = None
security_type: Optional[str] = None
shares_outstanding: Optional[int] = None
ticker: Optional[str] = None
total_offer_size: Optional[float] = None
us_code: Optional[str] = None

@staticmethod
def from_dict(d):
return IPOListing(
announced_date=d.get("announced_date"),
currency_code=d.get("currency_code"),
final_issue_price=d.get("final_issue_price"),
highest_offer_price=d.get("highest_offer_price"),
ipo_status=d.get("ipo_status"),
isin=d.get("isin"),
issuer_name=d.get("issuer_name"),
last_updated=d.get("last_updated"),
listing_date=d.get("listing_date"),
lot_size=d.get("lot_size"),
lowest_offer_price=d.get("lowest_offer_price"),
max_shares_offered=d.get("max_shares_offered"),
min_shares_offered=d.get("min_shares_offered"),
primary_exchange=d.get("primary_exchange"),
security_description=d.get("security_description"),
security_type=d.get("security_type"),
shares_outstanding=d.get("shares_outstanding"),
ticker=d.get("ticker"),
total_offer_size=d.get("total_offer_size"),
us_code=d.get("us_code"),
)
45 changes: 43 additions & 2 deletions polygon/rest/vX.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .base import BaseClient
from typing import Optional, Any, Dict, Union, Iterator
from .models import StockFinancial, Timeframe, Sort, Order
from typing import Optional, Any, Dict, List, Union, Iterator
from .models import StockFinancial, IPOListing, Timeframe, Sort, Order
from urllib3 import HTTPResponse
from datetime import datetime, date

Expand Down Expand Up @@ -70,3 +70,44 @@ def list_stock_financials(
deserializer=StockFinancial.from_dict,
options=options,
)

def list_ipos(
self,
ticker: Optional[str] = None,
us_code: Optional[str] = None,
isin: Optional[str] = None,
listing_date: Optional[str] = None,
ipo_status: Optional[str] = None,
limit: Optional[int] = None,
sort: Optional[Union[str, Sort]] = None,
order: Optional[Union[str, Order]] = None,
params: Optional[Dict[str, Any]] = None,
raw: bool = False,
options: Optional[RequestOptionBuilder] = None,
) -> Union[List[IPOListing], HTTPResponse]:
"""
Retrieve upcoming or historical IPOs.

:param ticker: Filter by a case-sensitive ticker symbol.
:param us_code: Filter by a US code (unique identifier for a North American financial security).
:param isin: Filter by an International Securities Identification Number (ISIN).
:param listing_date: Filter by the listing date (YYYY-MM-DD).
:param ipo_status: Filter by IPO status (e.g. "new", "pending", "history", etc.).
:param limit: Limit the number of results per page. Default 10, max 1000.
:param sort: Field to sort by. Default is "listing_date".
:param order: Order results based on the sort field ("asc" or "desc"). Default "desc".
:param params: Additional query params.
:param raw: Return raw HTTPResponse object if True, else return List[IPOListing].
:param options: RequestOptionBuilder for additional headers or params.
:return: A list of IPOListing objects or HTTPResponse if raw=True.
"""
url = "/vX/reference/ipos"

return self._paginate(
path=url,
params=self._get_params(self.list_ipos, locals()),
deserializer=IPOListing.from_dict,
raw=raw,
result_key="results",
options=options,
)
Loading