SLOW EXECUTION IN GENERATING SESSION 29DEC23


  • Posting here as no response from email api@angelbroking.com

    I am facing slow execution problem in login and generating session
    constantly. Sometimes randomly I am getting fast execution during the
    day. It has already costed me money.
    Every single API call is fixated between 11.1-11.4 seconds. For example,
    rmslimit, tradedata, orderdata, ltpdata, positions, userprofile. I
    just don't seem to understand.

    My code is simple:

    print("a @ {}".format(datetime.datetime.now()))
    obj = SmartConnect(api_key = MY API KEY)
    #obj.terminateSession(MY CLIENT CODE)
    print("b @ {}".format(datetime.datetime.now()))
    data = obj.generateSession(MY CLIENT CODE, MY PIN, pyotp.TOTP(MY TOTP).now())
    print("c @ {}".format(datetime.datetime.now()))
    refreshToken = data['data']['refreshToken']
    feedToken=obj.getfeedToken()
    userProfile = obj.getProfile(refreshToken)
    print(userProfile)
    print("d @ {}".format(datetime.datetime.now()))

    OUTPUT in 33.3 to 36.7 seconds:
    a @ 2023-12-29 15:04:11.981063
    b @ 2023-12-29 15:04:11.982057
    c @ 2023-12-29 15:04:34.505860
    {'status': True, 'message': 'SUCCESS', 'errorcode': '', 'data': TRUNCATED}
    d @ 2023-12-29 15:04:45.774632