Fetch scrip name and LTP from websocket market data. I am new to algo. I am able to get market data using websocket. I am trying to get print o/p filtered to show only Symbol and LTP. But not sure what the response type is (list/dictionary). nothing is working to modify subscriber output
Hi Maneet,
The response that is provided on successful connection is always in json/dictionary, you can fetch the value you want and you will get it , just use type function and you will be able to know the type, like print(type(value)). IF the problem still exist then can you please share us the response and exact details you want.
Hope this Helps,
Happy Trading.
Hi Arka,
Thanks for your response.
This is the response, that i received for an order update now. i am using the order update script shared in fyers api v2 documents for subscribing to order updates. In below response, i am trying to extract “id” and “message” to a variable. can you please suggest how can i do that.
Response:{“s”: “ok”, “d”: {“orderDateTime”: 1640873968, “id”: “2211230253825”, “exchOrdId”: “1400000142775242”, “side”: 1, “segment”: “D”, “instrument”: “”, “productType”: “INTRADAY”, “status”: 1, “qty”: 25, “remainingQuantity”: 0, “filledQty”: 0, “limitPrice”: 0.85, “stopPrice”: 0.8, “type”: 4, “discloseQty”: 0, “dqQtyRem”: 0, “orderValidity”: “DAY”, “slNo”: 2, “offlineOrder”: false, “message”: “CONFIRMED”, “orderNumStatus”: “2211230253825:1”, “tradedPrice”: 0.0, “fyToken”: “1011XXXXXXXXXXX”, “symbol”: “NSE:BANKNIFTY21DEC36500CE”}, “ws_type”: 1}
This is the section that i think prints the response.
HI Maneet,
Greetings from Fyers,
lets say,
response = {“s”: “ok”, “d”: {“orderDateTime”: 1640873968, “id”: “2211230253825”, “exchOrdId”: “1400000142775242”, “side”: 1, “segment”: “D”, “instrument”: “”, “productType”: “INTRADAY”, “status”: 1, “qty”: 25, “remainingQuantity”: 0, “filledQty”: 0, “limitPrice”: 0.85, “stopPrice”: 0.8, “type”: 4, “discloseQty”: 0, “dqQtyRem”: 0, “orderValidity”: “DAY”, “slNo”: 2, “offlineOrder”: False, “message”: “CONFIRMED”, “orderNumStatus”: “2211230253825:1”, “tradedPrice”: 0.0, “fyToken”: “1011XXXXXXXXXXX”, “symbol”: “NSE:BANKNIFTY21DEC36500CE”}, “ws_type”: 1}
Then we can store the id and message like,
id = response[“d”][“id”]
message = response[“d”][“message”]
Hope this Helps,
Happy Trading.