I cant login since this morning. Any issue going one?
Best posts made by Vignesha
-
RE: Guide to secure your SmartAPI Account with two factor authentication
Looks like the automation code provided by @aj_Brk worked. Thanks for that and 1 thing I had to change the IF condition as data['status'] (to make my code simpler to read - just my choice)
if data['status']: #it should be TRUE if successfully connected
breakFull code:
obj = SmartConnect(apikey)
totp = pyotp.TOTP(s='key_below_the_qr')
attempts = 5
while attempts > 0:
data = obj.generateSession(username, pwd, totp.now())
attempts = attempts-1
print(totp.now())#printed the opt just to cross check with google auth
if data['status']:
break
time.sleep(2)`
refreshToken = data['data']['refreshToken']Overall it is good @aj_Brk thanks once again.
@admin thanks for the effort of making the API trading safer much appreciated and if you're working on anything new then I would suggest
- trying to fix already existing bugs like recent auto API deletion and other issues
- making documentation easier to read with all the latest updates
- Issue with this website where clicking these icons while typing doesn't have any format effect and i have to type `` for code and ** ** for bold.(Not sure if I'm doing anything wrong)
-
RE: WebSocket 2.0 Streaming is not Receiving the Live Price Feed
I have this issue but seems no one is talking about it not really sure whats happening with the smart api @admin can this be addressed? Github example is not working at all if there is any issue let us know so we can wait
-
RE: WebSocket 2.0 Streaming is not Receiving the Live Price Feed
@Ashok Thanks for the reply yes I have issue with getting live data from smartapi. I even can get historical data, ltp but i just cant get live data from it... It would be great if you cold help.
This is my codefrom cred import username, apikey, pwd from smartapi import SmartConnect from smartapi import SmartWebSocket import pandas as pd import pyotp import time <Authentication part> token = "nse_cm|2885" task = "mw" ss = SmartWebSocket(feedToken, username) def on_message(ws, message): print("Ticks: {}".format(message)) def on_open(ws): print("on open") ss.subscribe(task, token) def on_error(ws, error): print(error) def on_close(ws): print("Close") # 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()
Since today is sunday cant test this will try it tomorrow and let you know if it has started to work...
Can you please let me know if my code is right and also out of this topic - is there a way to stock fetching the live data? previous when it worked i had to interpret the code for this to stop fetching the data
-
Returning user - Would need help understanding the issue
Hi Can anyone help connect to the WebSocket and sub-unsub and disconnect?
I used to use Smartapi then focused more on other things now I came back to using APIs. Can anyone help me with a code that is useful to do the above tasks mentioned right now.
This is my old code. Right now I can see my holdings but i cant fetch any real date. Tried connecting to IRCTC but I'm getting no output
from smartapi import SmartConnect import pyotp import time username = *** apikey= *** pwd = *** token = *** try: obj = SmartConnect(apikey) totp = pyotp.TOTP(s='token') attempts = 5 while attempts > 0: data = obj.generateSession(username, pwd, totp.now()) attempts = attempts-1 if data['status']: break time.sleep(2) refreshToken= data['data']['refreshToken'] feedToken=obj.getfeedToken() userProfile= obj.getProfile(refreshToken) print("Connecting to SMART API: {}".format(userProfile['message'])) except: print("Connection failed") #%% print(obj.holding()) Above code are working --------------------- #%% from smartapi import SmartWebSocket token = "nse_cm|13611" task = "mw" # mw|sfi|dp ss = SmartWebSocket(feedToken, username) def on_message(ws, message): print("Ticks: {}".format(message)) def on_open(ws): print("on open") ss.subscribe(task, token) def on_error(ws, error): print(error) def on_close(ws): print("Close") # 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() #%%
Output getting right now
__on_open################ {'task': 'cn', 'channel': 'NONLM', 'token': '0895067909', 'user': 'my_username', 'acctid': 'my_account'} 2023-02-07 11:39:13.684251 : Start task in the background on open {'task': 'hb', 'channel': '', 'token': '0895067909', 'user': 'my_username', 'acctid': 'my_account'} Ticks: [{'ak': 'nk', 'msg': 'cn', 'task': 'cn'}]Ticks: [{'ak': 'nk', 'msg': 'mw', 'task': 'mw'}] Ticks: [{'ak': 'nk', 'msg': 'hb', 'task': 'hb'}] 2023-02-07 11:39:43.688366 : Start task in the background {'task': 'hb', 'channel': '', 'token': '0895067909', 'user': 'my_username', 'acctid': 'my_account'}
Replaced my user name and accountid but this the error
-
Ran my code this morning and got URLError
I've been running this code since 4 months and make sure I'm keeping updated but this morning when I download all the dependencies and run it, it failed due to url error while placing the order.
- I download the requirement module from github everyday so saying my module is outdated isnt correct
- Tried running with different device and wifi but still failing
Anyone know how to fix this?
URLError: <urlopen error [Errno 111] Connection refused>