ltpdata


  • please provide complete script of print LTP data


  • Login to get session token

    try:
    data = smartapi.generateSession(client_id, pwd, totp_code)
    refresh_token = data['data']['refreshToken']
    access_token = data['data']['jwtToken']
    feed_token = smartapi.getfeedToken()
    print("Login Successful. Access Token:", access_token)

    except Exception as e:
    print("Login Failed:", e)

    stock_symbol_token_NIFTY = '99926000' # NIFTY token for NSE
    exchange_NIFTY = 'NSE'
    trading_symbol_NIFTY = 'NIFTY'

    stock_data_NIFTY = smartapi.ltpData(exchange_NIFTY, trading_symbol_NIFTY, stock_symbol_token_NIFTY)

    print(stock_data_NIFTY['data']['ltp'])


  • @msuthar0157
    you must have to first genrate a session and then you can simply add this line when you need to fetch LTP data

    LTP = self.obj.ltpData(self.EXCHANGE, script, token)
    LTP_price= LTP["data"]["ltp"]

    LTP_price will contain your LTP

    also you have to pass a 3 parameters as you can see