Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs
    1. Home
    2. balaSP
    B
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    balaSP

    @balaSP

    0
    Reputation
    3
    Posts
    4
    Profile views
    2
    Followers
    0
    Following
    Joined Last Online

    balaSP Follow

    Best posts made by balaSP

    This user hasn't posted anything yet.

    Latest posts made by balaSP

    • RE: Unable to get live feed.

      @admin Please explain about two fields AUTH_TOKEN and correlation_id. How to get values for these two fields?

      posted in Python SDK
      B
      balaSP
    • RE: Unable to get live feed.

      @nehak During market hours, live data is coming.

      posted in Python SDK
      B
      balaSP
    • Unable to get live feed.

      @admin I am able to get historical as well as ltp data. but when trying for live feed getting following output.
      __on_open################
      {'task': 'cn', 'channel': 'NONLM', 'token': '0968926247', 'user': 'B96820', 'acctid': 'B96820'}
      2022-05-29 13:27:52.873895 : Start task in the background
      {'task': 'hb', 'channel': '', 'token': '0968926247', 'user': 'B96820', 'acctid': 'B96820'}
      on open
      Ticks: [{'ak': 'ok', 'msg': 'connected', 'task': 'cn'}]
      Ticks: [{'ak': 'ok', 'msg': 'heartbeat', 'task': 'hb'}]
      Ticks: [{'ak': 'ok', 'msg': 'mw', 'task': 'mw'}]
      Ticks: [{'ak': 'ok', 'msg': 'mw', 'task': 'mw'}]
      Ticks: [{'ak': 'ok', 'msg': 'mw', 'task': 'mw'}]
      Ticks: [{'ak': 'ok', 'msg': 'mw', 'task': 'mw'}]
      2022-05-29 13:28:22.890306 : Start task in the background
      {'task': 'hb', 'channel': '', 'token': '0968926247', 'user': 'B96820', 'acctid': 'B96820'}
      Ticks: [{'ak': 'ok', 'msg': 'heartbeat', 'task': 'hb'}]
      @admin Will you please look where is the problem?
      Thank you.
      Following is the Code that I am using for live feed.

      from smartapi import SmartConnect
      from smartapi import SmartWebSocket

      apikey = 'MlxYOLdb'
      username = 'B96820'
      pwd = 'password'
      obj = SmartConnect(api_key=apikey)
      data = obj.generateSession(username,pwd)
      refreshToken= data['data']['refreshToken']
      feedToken=obj.getfeedToken()
      FEED_TOKEN = feedToken#"0980248722"
      CLIENT_CODE = username
      token = "nse_fo|108809&nse_fo|56855&nse_fo|5694&nse_fo|56906"
      ss = SmartWebSocket(FEED_TOKEN, CLIENT_CODE)
      task = "mw"

      def on_message(ws, message):
      print("Ticks: {}".format(message))

      def on_open(ws):
      ss.subscribe(task, token)
      print("on open")
      ss.subscribe(task, token)

      def on_error(ws, error):
      print(error)

      def on_close(ws):
      print("Close")

      ss._on_open = on_open
      ss._on_message = on_message
      ss._on_error = on_error
      ss._on_close = on_close

      ss.connect()

      posted in Python SDK
      B
      balaSP