So I am new to python I wrote a code which gives me spot LTP in a loop. but I wanted it to give me the live data.
I want it to give me the live updated data after every 1.5 seconds. Again Sorry I'm New
#importing Required Modules
from nsetools import Nse
import time as time
#Welcome
print("A Product of iTrenzy Technologies")
#Making the Symbol UpperCase
symbol = input("Enter Symbol: ")
symbol_1 = symbol.upper()
#Getting the Data
nse = Nse()
#Syncing index symbols and stock symbols
try:
q = nse.get_index_quote(symbol_1)
v = (q["lastPrice"])
except:
q = nse.get_quote(symbol_1)
v = (q["lastPrice"])
#Building Loops
while True:
print(f"The Current Spot Price of {symbol_1} is", v )
time.sleep(1.5)
You've already defined the price by the time you're printing every 1.5 seconds.
In the code below the data is updated every 1.5 seconds instead of being static. I've also changed your while loop to a for loop to print the price a set number of times instead of until the code is interrupted: