Python Streaming Tick Data Problem.
-
@rjbanna said in Python Streaming Tick Data Problem.:
data = bytes((zlib.decompress(data)).decode("utf-8"), 'utf-8')
thankyou @rjbanna now it is working :)
-
@dorje I have modified the webSocket.py file code so it is now returning the parsable response and you can get data from it. Below is the code if you are interested and don't want to wait for the development team to fix it. You just need to replace _parse_text_message() function from env/lib/python3/site-packages/smartapi/webSocket.py file with below code. This will return dict.
def _parse_text_message(self, payload): """Parse text message.""" # Decode unicode data if not six.PY2 and type(payload) == bytes: payload = payload.decode("utf-8") data = base64.b64decode(payload) try: data = bytes((zlib.decompress(data)).decode("utf-8"), 'utf-8') data = json.loads(data.decode('utf8').replace("'", '"')) data = json.loads(json.dumps(data, indent=4, sort_keys=True)) except ValueError: return self.on_ticks(self, data)
-
@dorje I agree with you, they are doing kind of testing from our side by claiming free API.
-
@rjbanna ok..that i never thought silly of me thats why i was confused even when i was not using print function it was printing the streaming data. @admin and @bhaveshjain it is really bad that you advertising it as a free API but i think for full operation it will take some time, so at least give us time frame for full launch of the service.
-
@dorje @bhaveshjain I am having the same issue. Actually the values printed on the terminal is not from on_ticks() method. It is simple string that is being printed because in the webSocket.py file, there is print() function which only prints the data but it doesn't send any data to the client so we can't parse it. And also the API closes connection after 10 minutes and giving error code of 1000.
-
@admin ok now i have got the streaming output as:
[{"ak":"ok","task":"cn","msg":"connected"}] [{"ak":"ok","task":"mw","msg":"mw"}] [{"ak":"ok","task":"mw","msg":"mw"}] [] [{"tvalue":"10\/12\/2020 10:35:00","name":"tm"{"to":"5592405812.40","lo":"2001.00","e":"nse_cm","sp":"2008.00","c":"2026.95","ltp":"2008.00","ltq":"27","tk":"2885","bs":"714","ltt":"10\/12\/2020 10:35:00","tsq":"781238","v":"2780424","bp":"2007.95","cng":"-18.95","bq":"39","ap":"2011.35","nc":"-00.93","name":"sf","tbq":"518673"}, {"to":"2281841541.00","lo":"2785.05","e":"nse_cm","sp":"2792.35","c":"2810.80","ltp":"2792.35","ltq":"3","tk":"11536","bs":"9","ltt":"10\/12\/2020 10:35:00","tsq":"199536","v":"813926","bp":"2791.40","cng":"-18.45","bq":"15","ap":"2803.50","nc":"-00.66","name":"sf","tbq":"139632"}]
but issue is i'm not able to parse this dictionary in a list using python , or say get a data from dictionary, can anyone help me out in this one, also there is some using with streaming service in python as the connection closes on its own after sometime.
-
@admin yes thankyou now it is working
-
@dorje @mihirk We have updated our Python SDK.
Request you to please re-install and refer the following URL to establish a websocket connection: https://github.com/angelbroking-github/smartapi-python/blob/main/README.md
-
@mihirk yes but it was of no help
-
Hi @dorje ,
Did you check this one https://smartapi.angelbroking.com/topic/8/live-market-feed ?