Tried the WebSocket Streaming 2.0 and I am not getting market data


  • Tried the WebSocket Streaming 2.0 and I am not getting market data. Can someone help me on this.
    I am using python library
    This is my code

    """
    Created on Monday Feb 2 2022

    @author: Nishant Jain
    
    :copyright: (c) 2022 by Angel One Limited
    

    """

    from SmartApi import SmartWebSocketV2
    from smartapi import SmartConnect #or from smartapi.smartConnect import SmartConnect
    #import smartapi.smartExceptions(for smartExceptions)
    API_KEY = 'xxxxxx'
    CLIENT_CODE = 'xxxxxxx'

    #create object of call
    obj=SmartConnect(api_key=API_KEY)

    #login api call

    data = obj.generateSession(CLIENT_CODE,"xxxx",'xxxxxx')
    print(data)
    refreshToken = data['data']['refreshToken']

    #fetch the feedtoken
    feedToken = obj.getfeedToken()
    #fetch User Profile
    userProfile = obj.getProfile(refreshToken)
    AUTH_TOKEN = data['data']['jwtToken']
    FEED_TOKEN = feedToken

    correlation_id = "ABCDEF1235"
    action = 1
    mode = 2

    #token_list = [{"exchangeType": 1, "tokens": ["26009"]}]

    token_list = [{"exchangeType": 5, "tokens": ["240284"]}]

    sws = SmartWebSocketV2(AUTH_TOKEN, API_KEY, CLIENT_CODE, FEED_TOKEN)

    def on_data(wsapp, message):
    print("Ticks: {}".format(message))

    def on_open(wsapp):
    print("on open")
    sws.subscribe(correlation_id, mode, token_list)

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

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

    Assign the callbacks.

    sws.on_open = on_open
    sws.on_data = on_data
    sws.on_error = on_error
    sws.on_close = on_close

    sws.connect()


  • Hi @skgkrish

    Apologies for delayed response.
    Websocket 2.0 is working fine from our end now. Kindly reverify and let us know if any issue occurs still.

    Thanks & Regards,
    SmartAPI team