Issue in LTP


  • I used the below Python code to fetch the LTP, but not receiving any data from the last week, please suggest if any correction is needed in the below code.

    from smartapi import SmartWebSocket

    FEED_TOKEN="********"
    CLIENT_CODE="*******"

    token = "nse_cm|1594&nse_cm|1330" #INFY and HDFC cash equities
    task = 'mw' # mw|sfi|dp
    ss = SmartWebSocket(FEED_TOKEN,CLIENT_CODE)

    def on_tick(ws, tick):
    print("Ticks: {}".format(tick))

    def on_connect(ws, response):
    print("On Connet")
    ws.send_request(token)

    def on_close(ws, code, reason):
    print("Before Connect")
    ws.stop()

    ss.on_ticks = on_tick
    ss.on_connect = on_connect
    ss.on_close = on_close

    ss.connect()

    Output:

    {'task': 'hb', 'channel': '', 'token': '', 'user': 'R117172', 'acctid': ''}
    2023-03-08 12:29:07.993649 : Start task in the background
    {'task': 'hb', 'channel': '', 'token': '', 'user': '', 'acctid': 'R117172'}
    2023-03-08 12:29:37.994828 : Start task in the background
    {'task': 'hb', 'channel': '', 'token': '', 'user': '', 'acctid': 'R117172'}
    2023-03-08 12:30:07.996269 : Start task in the background
    {'task': 'hb', 'channel': '', 'token': '', 'user': 'R117172', 'acctid': ''}
    2023-03-08 12:30:37.997054 : Start task in the background
    {'task': 'hb', 'channel': '', 'token': '', 'user': 'R117172', 'acctid': ''}

    Note - token & acctid are hide (*)


  • I have been facing the same issue for many days. No data is coming at all. Please, @admin, look into this. Thanks