mohamadkhalaj / tradingview-api Goto Github PK
View Code? Open in Web Editor NEWGet any market real-time data from TradingView Socket/API with Python.
Get any market real-time data from TradingView Socket/API with Python.
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)
Hi @mohamadkhalaj - I am trying to get the data for the usdzar forex paid. When I load it in I just get the following and nothing more:
IDC:ZARUSD
'lp'
Any ideas? :)
Hi bro, first of all, I would like to thank you for the beautiful script that you wrote, just one
My question is, why and when does the extra data error occur? Should it be taken seriously or is it nothing special?
ERROR: Extra data: line 1 column 94 (char 93)
TradingView message:
m93m{"m":"qsd","p":["qs_gsraxvjlbvhn",{"n":"BINANCE:EURUSDT","s":"ok","v":{"volume":8664094.8}}]}m128m{"m":"qsd","p":["qs_gsraxvjlbvhn",{"n":"BINANCE:EURUSDT","s":"ok","v":{"volume":8664194.8,"lp":1.0869,"chp":0.03,"ch":0.0003}}]}
Hi @mohamadkhalaj, thanks for this work, really appreciate it. I´m using your code to learn, but the volume I get bumps every 20 minutes. For example at 15:50, 16:10, 16:30, 16:50, 17:10... shows a very big peak and doesn´t show the real image of the volume. Any suggestion to fix it?
I attach you a file to show the volume over the time for a given stock: NFLX, 18 December (entire session)
Thanks mate!!
Hi, how to handle this error?
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.