Unable to get to tick data
-
@admin , I used to get the tick data by using the below code, in the recent past it was NOT providing the tick data, can you pl help me know if anything needs to be updated?
from smartapi import SmartConnect # or from smartapi.smartConnect import SmartConnect
#from smartapiwebsocket import SmartWebSocket
from smartapi import SmartWebSocketANGEL_API_KEY = "XXXXXX"
#ANGEL_SEC_KEY = "XXXXX"
TOTP="XXXXX"ANGEL_CLIENT_ID = "XXXXXX"
ANGEL_PASSSWORD = "XXXXX"refreshToken = None
feedToken = None
smartObj = Nonetokens = None
ss = None
task = Nonedef smartApiInitialization():
global refreshToken
global feedToken
global smartObjtry:
smartObj = SmartConnect(api_key=ANGEL_API_KEY)
totp = pyotp.TOTP(TOTP) #'replace with Text that appears below QR code'
totp = totp.now()
print("pasrse: ",totp)
attempts = 5
while attempts > 0:
attempts = attempts - 1data = self.smartObj.generateSession(ANGEL_CLIENT_ID,ANGEL_PASSSWORD,totp)
print(data)
if data['status']:
break
time.sleep(2)refreshToken = data['data']['refreshToken']
print(refreshToken)fetch the feedtoken
feedToken = self.smartObj.getfeedToken()
print(feedToken)
time.sleep(1)except Exception as ex:
print("Exception in smartApiInitialization method : {}".format(str(ex)))
def on_message(ws, message):
print("Ticks: {}".format(message))
def on_open(ws):
global tokens
global task
global ssprint("on open") ss.subscribe(task, tokens)
def on_error(ws, error):
print(error)def on_close(ws):
print("Close")def initialize_websocket():
global tokens
global ss
global task
global feedTokentry: tokens = "nse_cm|26000&nse_cm|26009" task = "mw" ss = SmartWebSocket(feedToken, ANGEL_CLIENT_ID) # Assign the callbacks. ss._on_open = on_open ss._on_message = on_message ss._on_error = on_error ss._on_close = on_close ss.connect() except Exception as ex: print('exception in initialize_websocket : {}'.format(ex))
if name == 'main':
smartApiInitialization() initialize_websocket()
-
@Ramesh
Same here.. tick data does not work with both websocket1 and websocket2 -
@admin, do we have any active support or not?
-
@admin pl reply
-
@mohan1710 @admin pl help us
-
@Ramesh i am facing similar issue and no response for my post as well