Shoonya-Dev / ShoonyaApi-py

139 stars 130 forks source link

'ShoonyaApiPy' object has no attribute '_NorenApi__username' Please help me to solve this issue. #65

Closed bhautikkeraliya closed 1 year ago

bhautikkeraliya commented 1 year ago

I am getting below error today. Yesterday my code working fine but i got this error today. Please help me to solve this issue.

My Code:

import pyotp
from NorenRestApiPy.NorenApi import NorenApi

#credentials
userid  = "XXXXXX"
pwd     = "XXXXXXX"
factor2 = "XXXXXX"
vc      = "XXXXXXXXXXX"
app_key = "XXXXXXXXXXXXXXXXXXXXXXXX"
imei    = "XXXXXXXXXX"

class ShoonyaApiPy(NorenApi):
    def __init__(self):
        NorenApi.__init__(self, host='https://shoonyatrade.finvasia.com/NorenWClientTP/', websocket='wss://shoonyatrade.finvasia.com/NorenWSTP/', eodhost='https://shoonya.finvasia.com/chartApi/getdata/')
        global api
        api = self

api = ShoonyaApiPy()      

ret = api.login(userid=userid, password=pwd, twoFA=factor2, vendor_code=vc, api_secret=app_key, imei=imei)

print(ret)

api.searchscrip(exchange='NSE', searchtext='REL')

Error:

AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_26769/4283264877.py in <module>
     23 ret = api.login(userid=userid, password=pwd, twoFA=factor2, vendor_code=vc, api_secret=app_key, imei=imei)
     24 
---> 25 api.get_limits()

~/anaconda3/lib/python3.9/site-packages/NorenRestApiPy/NorenApi.py in get_limits(self, product_type, segment, exchange)
    975 
    976         values              = {}
--> 977         values["uid"]       = self.__username
    978         values["actid"]     = self.__accountid
    979 

AttributeError: 'ShoonyaApiPy' object has no attribute '_NorenApi__username'
githubofakash commented 1 year ago

No error on my system

githubofakash commented 1 year ago

If u are still facing issue ping here -> https://twitter.com/aakash_gudadhe

Shoonya-Dev commented 1 year ago

check the ret value from api.login if it fails subsequent requests will fail with this error. Enable Debug messages to discover error by

enable dbug to see request and responses

logging.basicConfig(level=logging.DEBUG)

mahesh918 commented 1 year ago

File "C:\Users\kumar\anaconda3\lib\site-packages\NorenRestApiPy\NorenApi.py", line 208, in start_websocket url = self.service_config['websocket_endpoint'].format(access_token=self.__susertoken) AttributeError: 'ShoonyaApiPy' object has no attribute '_NorenApisusertoken'

showing this error ,not able to connect API