I cant login since this morning. Any issue going one?
Vignesha
@Vignesha
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)
-
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
-
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
-
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>
-
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
Latest posts made by Vignesha
-
RE: Ran my code this morning and got URLError
@mudit236 @admin has there been any change in the urls that is not updated in SDK? I only use python SDK and download the packages based on requirement txt file which is in github.
-
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>
-
RE: Announcing EDIS API for SmartAPI Users
I havent done this one but I cant even verify sell using TPIN. Because of this does the TPIN auth got decommissioned?
-
Sell order not working
I'm trying to place a sell order from portfolio and its not working. I cant even verify tpin from mobile app
-
RE: Did stop loss and shorting stopped working?
@DIYD20997 Thanks for confirming. The above param. itself somehow started to work.
-
RE: Did stop loss and shorting stopped working?
@godboleamit Got it... Also for some reason the above param. i pasted started to work idk what i did but now i can short and give stop loss to an order...
Thanks for the advice on this -
RE: ROBO order example with Trailing SL
@Pavithra I posted a similar question but regarding regular stop loss @admin @SmartAPI-Admin has not answered it. Have you tried normal stop loss and did it work? For me, I'm just running my bot and tracking the data, and using that as a trialing stop-loss, I dont think smartapi support trailing stop loss
-
RE: Did stop loss and shorting stopped working?
@admin any update on this?
I know lot of things are going on but could you please help with this issue? I followed the exact thing from documentation but unable to place Stop loss or Shorting order... Can you let me know if its enabled or not? -
Did stop loss and shorting stopped working?
Hi I'm trying to use shorting and stop loss it seems it isnt working...
Here is my code for shorting @admin @SmartAPI-Admin can you let me know if this is the case or do you think the param is wrong?
orderparams = { "variety": "NORMAL", "tradingsymbol": "SBIN-EQ", "symboltoken": "3045", "transactiontype": "SELL", "exchange": "NSE", "ordertype": "LIMIT", "producttype": "INTRADAY", "duration": "DAY", "price": "19500", "squareoff": "0", "stoploss": "0", "quantity": "1" } orderId=obj.placeOrder(orderparams)
-
RE: Getting timeout error - Anyone can help
@Vignesha Now just getting
'NoneType' object has no attribute 'get' randomly not at every rmslimit call