SSLCertVerificationError Traceback (most recent call last)
Cell In[1], line 127
125 pair = "btcusdt"
126 market = "crypto"
--> 127 main(pair, market)
Cell In[1], line 104, in main(pair, market)
102 trading_view_socket = "wss://data.tradingview.com/socket.io/websocket"
103 headers = json.dumps({"Origin": "https://data.tradingview.com/"})
--> 104 ws = create_connection(trading_view_socket, headers=headers)
105 session = generate_session()
107 send_message(ws, "quote_create_session", [session])
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websocket/core.py:608, in create_connection(url, timeout, class, **options)
603 websock = class_(sockopt=sockopt, sslopt=sslopt,
604 fire_cont_frame=fire_cont_frame,
605 enable_multithread=enable_multithread,
606 skip_utf8_validation=skip_utf8_validation, **options)
607 websock.settimeout(timeout if timeout is not None else getdefaulttimeout())
--> 608 websock.connect(url, **options)
609 return websock
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websocket/_core.py:249, in WebSocket.connect(self, url, **options)
202 """
203 Connect to url. url is websocket url scheme.
204 ie. ws://host:port/resource
(...)
246 Pre-initialized stream socket.
247 """
248 self.sock_opt.timeout = options.get('timeout', self.sock_opt.timeout)
--> 249 self.sock, addrs = connect(url, self.sock_opt, proxy_info(**options),
250 options.pop('socket', None))
252 try:
253 self.handshake_response = handshake(self.sock, url, *addrs, **options)
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websocket/_http.py:136, in connect(url, options, proxy, socket)
134 if is_secure:
135 if HAVE_SSL:
--> 136 sock = _ssl_socket(sock, options.sslopt, hostname)
137 else:
138 raise WebSocketException("SSL not available.")
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websocket/_http.py:271, in _ssl_socket(sock, user_sslopt, hostname)
268 hostname = sslopt['server_hostname']
270 check_hostname = sslopt.get('check_hostname', True)
--> 271 sock = _wrap_sni_socket(sock, sslopt, hostname, check_hostname)
273 return sock
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/websocket/_http.py:247, in _wrap_sni_socket(sock, sslopt, hostname, check_hostname)
244 if 'ecdh_curve' in sslopt:
245 context.set_ecdh_curve(sslopt['ecdh_curve'])
--> 247 return context.wrap_socket(
248 sock,
249 do_handshake_on_connect=sslopt.get('do_handshake_on_connect', True),
250 suppress_ragged_eofs=sslopt.get('suppress_ragged_eofs', True),
251 server_hostname=hostname,
252 )
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py:517, in SSLContext.wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
511 def wrap_socket(self, sock, server_side=False,
512 do_handshake_on_connect=True,
513 suppress_ragged_eofs=True,
514 server_hostname=None, session=None):
515 # SSLSocket class handles server_hostname encoding before it calls
516 # ctx._wrap_socket()
--> 517 return self.sslsocket_class._create(
518 sock=sock,
519 server_side=server_side,
520 do_handshake_on_connect=do_handshake_on_connect,
521 suppress_ragged_eofs=suppress_ragged_eofs,
522 server_hostname=server_hostname,
523 context=self,
524 session=session
525 )
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py:1075, in SSLSocket._create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
1072 if timeout == 0.0:
1073 # non-blocking
1074 raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
-> 1075 self.do_handshake()
1076 except (OSError, ValueError):
1077 self.close()
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py:1346, in SSLSocket.do_handshake(self, block)
1344 if timeout == 0.0 and block:
1345 self.settimeout(None)
-> 1346 self._sslobj.do_handshake()
1347 finally:
1348 self.settimeout(timeout)
SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1002)