tedchou12 / webull

Unofficial APIs for Webull.
MIT License
596 stars 181 forks source link

StreamConn CERTIFICATE_VERIFY_FAILED #431

Open nvnk3 opened 5 months ago

nvnk3 commented 5 months ago

Hello,

I'm trying to use "StreamConn" like following way by manually setting valid did and access_token and I getting this ssl error, will you let me know what am I missing here?

Traceback (most recent call last):
  File "/Users/nk/Development/NKATS/research/options2/auto/mqtt/webull/quotes.py", line 42, in <module>
    conn.connect(did, access_token=access_token)
  File "/Users/nk/Development/NKATS/research/options2/auto/mqtt/webull/webull/streamconn.py", line 171, in connect
    self.client_order_upd.connect('wspush.webullbroker.com', 443, 30)
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/paho/mqtt/client.py", line 914, in connect
    return self.reconnect()
           ^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/paho/mqtt/client.py", line 1073, in reconnect
    sock.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py", line 1346, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)
from webull import StreamConn, webull

def on_price_message(topic, data):
    print (data)
    #the following fields will vary by topic number you recieve (topic 105 in this case)
    print(f"Ticker: {topic['tickerId']}, Price: {data['deal']['price']}, "
        + f"Volume: {data['deal']['volume']}, Trade time: {data['tradeTime']}")
    #all your algo precessing code goes here

def on_order_message(topic, data):
    print(data)

conn = StreamConn(debug_flg=True)

conn.price_func = on_price_message
conn.order_func = on_order_message

did='m5wraqr77pafi34qmyio7w5ote35l1a5'
access_token="dc_us_tech1.17d653bbc96-cf243ff9dab58732a07a1d56d3ec5563"

conn.connect(did, access_token=access_token)
conn.subscribe(tId='913256135') #AAPL
conn.run_loop_once()
conn.run_blocking_loop()