unable to import websocket
-
WebSocket
from smartapi import WebSocket
FEED_TOKEN= "your feed token"
CLIENT_CODE="your client Id"
token="channel you want the information of" #"nse_cm|2885&nse_cm|1594&nse_cm|11536"ss = WebSocket(FEED_TOKEN, CLIENT_CODE)
def on_tick(ws, tick):
print("Ticks: {}".format(tick))def on_connect(ws, response):
ws.send_request(token)def on_close(ws, code, reason):
ws.stop()Assign the callbacks.
ss.on_ticks = on_tick
ss.on_connect = on_connect
ss.on_close = on_closess.connect( )
This code giving error 1 line itself.
-
Please don't confuse on ws.send_request()
-
-
@djdenish thanx
-
@lavly
open cmd type : pip install pyOpenSSL
hit enter.
after successful installation run your code again. -
@djdenish from smartapi import WebSocket
Errorr
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-47-fd07382cedc0> in <module>()
----> 1 from smartapi import WebSocket2 frames
/usr/local/lib/python3.7/dist-packages/twisted/internet/ssl.py in <module>()
56
57 # System imports
---> 58 from OpenSSL import SSL
59
60 from zope.interface import implementer, implementer_only, implementedByModuleNotFoundError: No module named 'OpenSSL'
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.To view examples of installing some common dependencies, click the
"Open Examples" button below. -
@rajanprabu no
-
@lavly said in unable to import websocket:
wrong indentation
This is a python error..
@lavly said in unable to import websocket:
But the codes given for WebSocket, order placement and gtt giving errors,
One step at a time. are you getting websockt data ?
-
@lavly
Post your code and error -
@djdenish installed. I'm getting my profile. But the codes given for WebSocket, order placement and gtt giving errors, like module not found or wrong indentation , define e. Etc
-
@lavly
Have you installed Smart API library??
If not then go to cmd type : pip install smartapi-python
Hit enter. -
@James-Bond it suppor pip pip3 is not working
-
@James-Bond i am working with Google collaboratory. I'm getting my profile. Evry thing is ok.
When I put cmd from smartapi import Web Socket it shows error no module found -
@lavly
Which pip version (pip or pip3) you used to install SmartAPI Python SDK and which Python version you're using ?
Most probably this error occurs due to conflicting versions of pip and python while installing library. -