Neither requests nor websocket working

My Code1:
import requests
response = requests.get("")
Response [200]
My Code1:
kws = WebSocket("api_key", "public_token", "user_id")
Above 3 values are assigned already without any errors.

def on_tick(tick,ws):
print tick, "\n"

def on_connect(ws):

kws.on_tick = on_tick
kws.on_connect = on_connect

kiteconnect.WebSocket object at 0x0000000003630780
  • vishnus
    Code 1.
    You should be printing response.text. Not response object

    Code 2.
    The instrument token 53287175 is invalid. I tried with a valid token and it works fine. Please retry again
  • gaurav1235
    thanks @vishnus Code1 ran.
    For Code2:
    After checking on each of valid token of 4716033 & 25601, I am getting:
    kiteconnect.WebSocket object at 0x000000000245B860
  • gaurav1235
    Can anyone help here for Code2? I tried below also

    def on_connect(ws):
    ws.subscribe([738561, 5633])
    ws.set_mode(ws.MODE_FULL, [738561])

    But the result is coming same(Just last 7 digits keep on changing):
    kiteconnect.WebSocket object at 0x00000000037FD9B0

  • vishnus
    if you just give tick instead of print tick it gives that object message. I could reproduce the same like that. So try print tick, "\n"
  • gaurav1235
    @vishnus Check my code in the post, its exactly same as your suggestion:

    def on_tick(tick,ws):
    print tick, "\n"

    Where's the difference?
  • soumyadeep
    print(tick, "\n")
    Are you using python 3?
  • Vivek
    @gaurav1235 You can dump the object as JSON to make it readable in console.
    import json
Sign In or Register to comment.