Error:
Order placement failed for XXXXXPE. Error: string indices must be integers
Invalid totp, error code = AB1050
If you are facing above mentioned errors recently, This is due to the Implementation of totp while generating session.
The version of smartapi and websocket-client pakages should be latest. ie., smartapi-python-1.3.0 & websocket-client-1.4.1
Uninstall the existing packages and Install the latest one.
Uninstall
PS C:\Users> pip uninstall smartapi-python
Found existing installation: smartapi-python 1.2.9
Uninstalling smartapi-python-1.2.9:
PS C:\Users> pip uninstall websocket-client
Found existing installation: websocket-client 1.2.1
Uninstalling websocket-client-1.2.1:
Successfully uninstalled websocket-client-1.2.1
Install
PS C:\Users> pip install smartapi-python
Collecting smartapi-python
Downloading smartapi-python-1.3.0.tar.gz (13 kB)
Preparing metadata (setup.py) ... done
Successfully built smartapi-python
Installing collected packages: smartapi-python
Successfully installed smartapi-python-1.3.0
PS C:\Users> pip install websocket-client
Collecting websocket-client
Downloading websocket_client-1.4.1-py3-none-any.whl (55 kB)
---------------------------------------- 55.0/55.0 kB 2.8 MB/s eta 0:00:00
Installing collected packages: websocket-client
Successfully installed websocket-client-1.4.1
Cause:
Older version of SmartConnect only takes 3 values Including apikey
def generateSession(self,clientCode,password):
params={"clientcode":clientCode,"password":password}
Latest Version
def generateSession(self,clientCode,password,totp):
params={"clientcode":clientCode,"password":password,"totp":totp}