polygon-io / client-python

The official Python client library for the Polygon REST and WebSocket API.
https://polygon-api-client.readthedocs.io/
MIT License
744 stars 204 forks source link

list_tickers returns Units and Warrants when type="CS" #653

Closed stanbot8 closed 2 months ago

stanbot8 commented 2 months ago

client.list_tickers(market="stocks", type="CS", active=False, limit=1000) returns Warrants and Units, while the actual Polygon API filters them out correctly.

Expected behavior client.list_tickers(market="stocks", type="CS", active=False, limit=1000) should not include Warrants and Units in the response

justinpolygon commented 2 months ago

Thanks for reporting this @stanbot8. I'll check it out.

justinpolygon commented 2 months ago

Hey @stanbot8, I'm not able to reproduce this. Do you mind showing an example of what you're seeing? Here's what I'm doing on my end. I've added RESTClient(trace=True) which turns on debugging to show you the url being accessed and I'm getting the same data from the underlining API itself.

https://api.polygon.io/v3/reference/tickers?type=CS&market=stocks&active=true&limit=1000&sort=ticker&order=asc

Here's the example code:

from polygon import RESTClient

# docs
# https://polygon.io/docs/stocks/get_v3_reference_tickers
# https://polygon-api-client.readthedocs.io/en/latest/Reference.html#list-tickers

client = RESTClient(trace=True)  # POLYGON_API_KEY environment variable is used

tickers = []
for t in client.list_tickers(market="stocks", type="CS", active=True, limit=1000):
    tickers.append(t)
print(tickers)

Then here an example of the output:

Ticker(
    active=True, 
    cik='0001675149', 
    composite_figi='BBG00B3T3HD3', 
    currency_name='usd', 
    currency_symbol=None, 
    base_currency_symbol=None, 
    base_currency_name=None, 
    delisted_utc=None, 
    last_updated_utc='2024-04-23T00:00:00Z', 
    locale='us', 
    market='stocks', 
    name='Alcoa Corporation', 
    primary_exchange='XNYS', 
    share_class_figi='BBG00B3T3HF1', 
    ticker='AA', 
    type='CS', 
    source_feed=None
), 
Ticker(
    active=True, 
    cik='0001844817', 
    composite_figi='BBG011XR7306', 
    currency_name='usd', 
    currency_symbol=None, 
    base_currency_symbol=None, 
    base_currency_name=None, 
    delisted_utc=None, 
    last_updated_utc='2024-04-23T00:00:00Z', 
    locale='us', 
    market='stocks', 
    name='Armada Acquisition Corp. I Common Stock', 
    primary_exchange='XNAS', 
    share_class_figi='BBG011XR7315', 
    ticker='AACI', 
    type='CS', 
    source_feed=None
),

Let me know what you think.

stanbot8 commented 2 months ago

Hey @justinpolygon, thanks for looking into the matter. When active=True, it correctly filters out the warrant, units, etc. When active=False, they are included back in. I checked again through the polygon API and it seems to behave that way as well so it's okay, I can work with active=True.

justinpolygon commented 2 months ago

Great, thanks for getting back to me @stanbot8. I'll close this out.