Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    Is there need any aditional parameter to stream the F&O data???

    General Discussion
    3
    3
    25
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      nayan_nandi last edited by

      I want to stream this scripts' data___
      "64911": "TATAMOTORS29APR21FUT",
      "64719": "ITC29APR21FUT",
      "64815": "SAIL29APR21FUT"

      This is my code___

      from smartapi import SmartConnect
      from smartapi import WebSocket
      import creds
      
      obj = SmartConnect(api_key=creds.api_key)
      # print(obj)
      
      data = obj.generateSession(creds.client_token, creds.password)
      refreshToken = data['data']['refreshToken']
      # print(refreshToken)
      
      feedToken = obj.getfeedToken()
      # print(feedToken)
      
      userProfile = obj.getProfile(refreshToken)
      # print(userProfile)
      
      FEED_TOKEN = feedToken
      CLIENT_CODE = creds.client_token
      
      token = "nse_cm|64911&nse_cm|64719&nse_cm|64815"
      task = "mw"  # "mw"|"sfi"|"dp"
      
      ss = WebSocket(FEED_TOKEN, CLIENT_CODE)
      
      trading_portfolios = {"64911": "TATAMOTORS29APR21FUT",
                            "64719": "ITC29APR21FUT",
                            "64815": "SAIL29APR21FUT"}
      
      
      def on_tick(ws, tick):
          print(tick)
      
      
      def on_connect(ws, response):
          ws.websocket_connection()
          ws.send_request(token, task)
      
      
      # Assign the callbacks.
      ss.on_ticks = on_tick
      ss.on_connect = on_connect
      
      ss.connect()
      
      

      But when I trying to stream the data, it's printing something like this______
      fghgh.PNG

      1 Reply Last reply Reply Quote 0
      • A
        admin last edited by

        Hi @nayan_nandi can you please elaborate on which line of code you have passed your trading portfolio dictionary to receive data from web socket.

        S 1 Reply Last reply Reply Quote 0
        • S
          Surya 1 @admin last edited by

          @admin

          you need FnO data but using exchange as cash market.. for Fno data you need nse_fo.

          token = "nse_fo|64911&nse_fo|64719&nse_fo|64815"

          1 Reply Last reply Reply Quote 0
          • First post
            Last post