Nasdaq / data-link-python

A Python library for Nasdaq Data Link's RESTful API
MIT License
464 stars 76 forks source link

ResourceWarning: unclosed <ssl.SSLSocket #27

Closed tommedema closed 2 years ago

tommedema commented 2 years ago

I just purchased a subscription but am getting errors.

Can you also confirm if this is the right way to filter for specific columns?

Code:

import nasdaqdatalink

sharadarKeyFile = './keys/nasdaqdatalinkapikey'

nasdaqdatalink.read_key(filename = sharadarKeyFile)

SHARADAR_TABLE_NAME = 'SHARADAR/SEP'

liveSEP = nasdaqdatalink.get_table(
        SHARADAR_TABLE_NAME,
        date = {'gte': '2022-08-01'},
        paginate = True,
        qopts = {
            'columns': ','.join(['ticker', 'date', 'open', 'close', 'closeadj', 'closeunadj'])
        }
    )

Throws the following exceptions:

Exception ignored in: <ssl.SSLSocket fd=80, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.225', 59345), raddr=('45.60.150.18', 443)>
Traceback (most recent call last):
  File "/Users/tommedema/opt/anaconda3/lib/python3.9/site-packages/nasdaqdatalink/model/datatable.py", line 31, in data
    return Data.page(self, **options)
ResourceWarning: unclosed <ssl.SSLSocket fd=80, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.225', 59345), raddr=('45.60.150.18', 443)>
Exception ignored in: <ssl.SSLSocket fd=79, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.225', 59237), raddr=('45.60.150.18', 443)>
Traceback (most recent call last):
  File "/Users/tommedema/opt/anaconda3/lib/python3.9/re.py", line 291, in _compile
    if isinstance(flags, RegexFlag):
ResourceWarning: unclosed <ssl.SSLSocket fd=79, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.225', 59237), raddr=('45.60.150.18', 443)>
Exception ignored in: <ssl.SSLSocket fd=78, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.225', 59329), raddr=('45.60.150.18', 443)>
Traceback (most recent call last):
  File "/Users/tommedema/opt/anaconda3/lib/python3.9/re.py", line 291, in _compile
    if isinstance(flags, RegexFlag):
ResourceWarning: unclosed <ssl.SSLSocket fd=78, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.225', 59329), raddr=('45.60.150.18', 443)>
Exception ignored in: <ssl.SSLSocket fd=80, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.225', 59347), raddr=('45.60.150.18', 443)>
Traceback (most recent call last):
  File "/Users/tommedema/opt/anaconda3/lib/python3.9/site-packages/nasdaqdatalink/model/datatable.py", line 31, in data
    return Data.page(self, **options)
ResourceWarning: unclosed <ssl.SSLSocket fd=80, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('192.168.1.225', 59347), raddr=('45.60.150.18', 443)>
tommedema commented 2 years ago

A related question I have is if I need to define the export parameter in qopts? This is recommended by the docs but don't see it back in this library.

couture-ql commented 2 years ago

Hi @tommedema

The SSL issue you're experiencing is a strange one. If you're still experiencing issues, please email connect@data.nasdaq.com. We can further investigate by asking more details so we can check our logs. Our customer support team will be able to ask you more details you shouldn't share in this thread.

As for export, I'm assuming you're looking to download the entire table history. You can use the export_table feature.

With respect to your initial question regarding columns filtering, yes you can use qpots keyword argument. It's a bit clumsy at the moment, but you can fall back on some of our coding snippets.

A more complete example would be something like:

import nasdaqdatalink as ndl

table = ndl.get_table('ZACKS/FC', ticker=['AAPL','MSFT'])
print(table)

table = ndl.get_table('ZACKS/FC', ticker=['AAPL','MSFT'], qopts={'columns':['ticker', 'per_end_date']})
print(table)
tommedema commented 2 years ago

Thanks I'll email connect@data.nasdaq.com re the SSL issue