Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs
    1. Home
    2. swathi priya
    S
    • Profile
    • Following 0
    • Followers 0
    • Topics 6
    • Posts 11
    • Best 0
    • Groups 0

    swathi priya

    @swathi priya

    1
    Reputation
    2
    Profile views
    11
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    swathi priya Unfollow Follow

    Latest posts made by swathi priya

    • Key error Timestamp

      This is the error i am facing while running my backtesting code
      File ~\anaconda3\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
      exec(code, globals, locals)

      File c:\users\kswat\downloads\orb_strategy.py:16
      key_secret = open("key.txt","r").read().split()

      FileNotFoundError: [Errno 2] No such file or directory: 'key.txt'

      runfile('C:/Users/kswat/Downloads/orb_strategy.py', wdir='C:/Users/kswat/Downloads')
      [I 250106 13:24:29 smartConnect:121] in pool
      Traceback (most recent call last):

      File index.pyx:609 in pandas._libs.index.DatetimeEngine.get_loc

      File pandas\_libs\hashtable_class_helper.pxi:2606 in pandas._libs.hashtable.Int64HashTable.get_item

      File pandas\_libs\hashtable_class_helper.pxi:2630 in pandas._libs.hashtable.Int64HashTable.get_item

      KeyError: 1736154900000000000

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):

      File ~\anaconda3\Lib\site-packages\pandas\core\indexes\base.py:3805 in get_loc
      return self._engine.get_loc(casted_key)

      File index.pyx:577 in pandas._libs.index.DatetimeEngine.get_loc

      File index.pyx:611 in pandas._libs.index.DatetimeEngine.get_loc

      KeyError: Timestamp('2025-01-06 09:15:00')

      The above exception was the direct cause of the following exception:

      Traceback (most recent call last):

      File ~\anaconda3\Lib\site-packages\pandas\core\indexes\datetimes.py:630 in get_loc
      return Index.get_loc(self, key)

      File ~\anaconda3\Lib\site-packages\pandas\core\indexes\base.py:3812 in get_loc
      raise KeyError(key) from err

      KeyError: Timestamp('2025-01-06 09:15:00')

      The above exception was the direct cause of the following exception:

      Traceback (most recent call last):

      File ~\anaconda3\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
      exec(code, globals, locals)

      File c:\users\kswat\downloads\orb_strategy.py:144
      tickers = filtered_tickers(data_0920) #identify tickers with maximum gap up/down

      File c:\users\kswat\downloads\orb_strategy.py:107 in filtered_tickers
      temp.loc[ticker] = data[ticker].loc[date,"gap"]

      File ~\anaconda3\Lib\site-packages\pandas\core\indexing.py:1183 in getitem
      return self.obj._get_value(*key, takeable=self._takeable)

      File ~\anaconda3\Lib\site-packages\pandas\core\frame.py:4221 in _get_value
      row = self.index.get_loc(index)

      File ~\anaconda3\Lib\site-packages\pandas\core\indexes\datetimes.py:632 in get_loc
      raise KeyError(orig_key) from err

      KeyError: Timestamp('2025-01-06 09:15:00')

      posted in Test
      S
      swathi priya
    • RE: error

      @Moderator_3 I am using tls 1.3

      posted in Python SDK
      S
      swathi priya
    • RE: error

      @Moderator_3 tell me how to check which version of TLS I am using and how to update the tls

      posted in Python SDK
      S
      swathi priya
    • error

      @Moderator_1 this is my code

      from SmartApi import SmartConnect
      import os
      import urllib
      import json
      import pandas as pd
      import time
      from pyotp import TOTP

      key_path = r"C:\Users\kswat\angelone"
      os.chdir(key_path)

      key_secret = open("angeloneapi.txt","r").read().split()
      obj=SmartConnect(api_key=key_secret[0])
      data = obj.generateSession(key_secret[2],key_secret[3],TOTP(key_secret[4]).now())

      instrument_url = "https://margincalculator.angelbroking.com/OpenAPI_File/files/OpenAPIScripMaster.json"
      response = urllib.request.urlopen(instrument_url)
      instrument_list = json.loads(response.read())

      tickers = ["WIPRO","ULTRACEMCO","UPL","TITAN","TECHM","TATASTEEL","TATAMOTORS",
      "TATACONSUM","TCS","SUNPHARMA","SBIN","SBILIFE","RELIANCE","POWERGRID",
      "ONGC","NESTLEIND","NTPC","MARUTI","M&M","LT","KOTAKBANK","JSWSTEEL",
      "INFY","INDUSINDBK","ITC","ICICIBANK","HINDUNILVR","HINDALCO",
      "HEROMOTOCO","HDFCLIFE","HDFCBANK","HCLTECH","GRASIM","EICHERMOT",
      "DRREDDY","DIVISLAB","COALINDIA","CIPLA","BRITANNIA","BHARTIARTL",
      "BPCL","BAJAJFINSV","BAJFINANCE","BAJAJ-AUTO","AXISBANK","ASIANPAINT",
      "APOLLOHOSP","ADANIPORTS","ADANIENT"]

      bktst_start_dt = "2021-06-01 09:15"
      bktst_end_dt = "2022-10-21 15:30"

      def token_lookup(ticker, instrument_list, exchange="NSE"):
      for instrument in instrument_list:
      if instrument["name"] == ticker and instrument["exch_seg"] == exchange and instrument["symbol"].split('-')[-1] == "EQ":
      return instrument["token"]

      def symbol_lookup(token, instrument_list, exchange="NSE"):
      for instrument in instrument_list:
      if instrument["token"] == token and instrument["exch_seg"] == exchange and instrument["symbol"].split('-')[-1] == "EQ":
      return instrument["name"]

      def hist_data_daily(tickers,instrument_list,exchange="NSE"):
      hist_data_tickers = {}
      for ticker in tickers:
      time.sleep(0.3)
      params = {
      "exchange": exchange,
      "symboltoken": token_lookup(ticker,instrument_list),
      "interval": "ONE_DAY",
      "fromdate": bktst_start_dt,
      "todate": bktst_end_dt
      }
      hist_data = obj.getCandleData(params)
      df_data = pd.DataFrame(hist_data["data"],
      columns = ["date","open","high","low","close","volume"])
      df_data.set_index("date",inplace=True)
      df_data.index = pd.to_datetime(df_data.index)
      df_data.index = df_data.index.tz_localize(None)
      df_data["gap"] = ((df_data["open"]/df_data["close"].shift(1))-1)*100
      df_data["avvol"] = df_data["volume"].rolling(10).mean().shift(1)
      hist_data_tickers[ticker] = df_data
      return hist_data_tickers

      def hist_data_intraday(ticker,datestamp,interval,instrument_list,exchange="NSE"):
      params = {
      "exchange": exchange,
      "symboltoken": token_lookup(ticker,instrument_list),
      "interval": interval,
      "fromdate": datestamp.strftime("%Y-%m-%d")+ " 09:15",
      "todate": datestamp.strftime("%Y-%m-%d") + " 15:30"
      }
      hist_data = obj.getCandleData(params)
      df_data = pd.DataFrame(hist_data["data"],
      columns = ["date","open","high","low","close","volume"])
      df_data.set_index("date",inplace=True)
      df_data.index = pd.to_datetime(df_data.index)
      df_data.index = df_data.index.tz_localize(None)
      return df_data

      candle_data = hist_data_daily(tickers, instrument_list)

      def topGap(data):
      top_gap_by_date = {}
      dates = data[tickers[0]].index.to_list()
      for date in dates:
      temp = pd.Series()
      for ticker in data:
      try:
      temp.loc[ticker] = data[ticker].loc[date,"gap"]
      except:
      pass
      top_gap_by_date[date] = (abs(temp[abs(temp)>1.5])).sort_values(ascending=False)[:5].index.to_list()
      print("top 5 gap stocks on {}".format(date))
      print((abs(temp[abs(temp)>1.5])).sort_values(ascending=False)[:5])

      return top_gap_by_date
      

      top_gap_by_date = topGap(candle_data)

      def backtest(top_gap_by_date, candle_data):
      date_stats = {}
      for date in top_gap_by_date:
      date_orgnl = date.strftime("%Y-%m-%d %H:%M")
      date_stats[date] = {}
      for ticker in top_gap_by_date[date]:
      try:
      intraday_df = hist_data_intraday(ticker,date,'FIVE_MINUTE',instrument_list)
      hi_price = intraday_df.iloc[0]['high']
      lo_price = intraday_df.iloc[0]['low']
      open_price = ''
      direction = ''
      date_stats[date][ticker] = 0
      for i in range(1,len(intraday_df[1:])):
      if intraday_df.iloc[i]["volume"] > 2*(candle_data[ticker].loc[date_orgnl,"avvol"])/75
      and intraday_df.iloc[i]["high"] > hi_price
      and open_price == '':
      open_price = 0.8intraday_df.iloc[i+1]["open"] + 0.2intraday_df.iloc[i+1]["high"] #factoring in slippage
      direction = 'long'
      elif intraday_df.iloc[i]["volume"] > 2*(candle_data[ticker].loc[date_orgnl,"avvol"])/75
      and intraday_df.iloc[i]["low"] < lo_price
      and open_price == '':
      open_price = 0.8intraday_df.iloc[i+1]["open"] + 0.2intraday_df.iloc[i+1]["low"] #factoring in slippage
      direction = 'short'

                      if open_price != '' and direction == 'long':
                          if intraday_df.iloc[i]["high"] > hi_price*1.05:
                              ticker_return = ((hi_price*1.05)/open_price)-1
                              date_stats[date][ticker] = ticker_return
                              break
                          elif intraday_df.iloc[i]["low"] < lo_price:
                              ticker_return = (lo_price/open_price) - 1
                              date_stats[date][ticker] = ticker_return
                              break
                          else:
                              ticker_return = (intraday_df.iloc[i]["close"]/open_price) - 1
                              date_stats[date][ticker] = ticker_return
                              
                      if open_price != '' and direction == 'short':
                          if intraday_df.iloc[i]["low"] < lo_price*0.95:
                              ticker_return = 1 - ((lo_price*0.95)/open_price)
                              date_stats[date][ticker] = ticker_return
                              break
                          elif intraday_df.iloc[i]["high"] > hi_price:
                              ticker_return = 1 - (hi_price/open_price)
                              date_stats[date][ticker] = ticker_return
                              break
                          else:
                              ticker_return = 1 - (intraday_df.iloc[i]["close"]/open_price)
                              date_stats[date][ticker] = ticker_return
              except:
                  print(ticker,date)
                                                   
      return date_stats
      

      date_stats = backtest(top_gap_by_date, candle_data)

      ###########################KPIs#####################################

      def abs_return(date_stats):
      df = pd.DataFrame(date_stats).T
      df["ret"] = df.mean(axis=1)
      df["ret"].fillna(0,inplace=True)
      return (1+df["ret"]).cumprod().iloc[-1] - 1

      def win_rate(date_stats):
      win_count = 0
      lose_count = 0
      for i in date_stats:
      for ticker in date_stats[i]:
      if date_stats[i][ticker] > 0:
      win_count+=1
      elif date_stats[i][ticker] < 0:
      lose_count+=1
      return (win_count/(win_count+lose_count))*100

      def mean_ret_winner(date_stats):
      win_ret = []
      for i in date_stats:
      for ticker in date_stats[i]:
      if date_stats[i][ticker] > 0:
      win_ret.append(date_stats[i][ticker])
      return sum(win_ret)/len(win_ret)

      def mean_ret_loser(date_stats):
      los_ret = []
      for i in date_stats:
      for ticker in date_stats[i]:
      if date_stats[i][ticker] < 0:
      los_ret.append(date_stats[i][ticker])
      return sum(los_ret)/len(los_ret)

      def equity_curve(date_stats):
      df = pd.DataFrame(date_stats).T
      df["ret"] = df.mean(axis=1)
      df["ret"].fillna(0,inplace=True)
      df["cum_ret"] = (1+df["ret"]).cumprod() - 1
      df["cum_ret"].plot(title="return profile")

      print("*Strategy Performance Statistics")
      print("total cumulative return = {}".format(round(abs_return(date_stats),4)))
      print("total win rate = {}".format(round(win_rate(date_stats),2)))
      print("mean return per win trade = {}".format(round(mean_ret_winner(date_stats),4)))
      print("mean return per loss trade = {}".format(round(mean_ret_loser(date_stats),4)))
      equity_curve(date_stats)

      @Moderator_1 this is the error that I am facing for past 3 weeks top 5 gap stocks on 2022-10-13 00:00:00
      WIPRO 5.135433
      HINDALCO 2.698651
      HCLTECH 2.106092
      dtype: float64
      top 5 gap stocks on 2022-10-14 00:00:00
      INFY 4.584830
      ICICIBANK 3.537957
      HDFCLIFE 2.640930
      ADANIPORTS 2.453011
      HINDALCO 2.415639
      dtype: float64
      top 5 gap stocks on 2022-10-17 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-10-18 00:00:00
      WIPRO 2.292722
      dtype: float64
      top 5 gap stocks on 2022-10-19 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-10-20 00:00:00
      HINDALCO 1.870356
      dtype: float64
      top 5 gap stocks on 2022-10-21 00:00:00
      AXISBANK 4.147242
      dtype: float64
      [E 240603 11:56:34 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Error: Something Went Wrong, Please Try After Sometime. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'exchange': 'NSE', 'symboltoken': '910', 'interval': 'FIVE_MINUTE', 'fromdate': '2021-11-04 09:15', 'todate': '2021-11-04 15:30'}, Response: {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}
      EICHERMOT 2021-11-04 00:00:00
      [E 240603 11:58:57 smartConnect:218] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB', 'Authorization': 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJ1c2VybmFtZSI6IlM1OTMzNTgwNiIsInJvbGVzIjowLCJ1c2VydHlwZSI6IlVTRVIiLCJ0b2tlbiI6ImV5SmhiR2NpT2lKSVV6VXhNaUlzSW5SNWNDSTZJa3BYVkNKOS5leUp6ZFdJaU9pSlROVGt6TXpVNE1EWWlMQ0psZUhBaU9qRTNNVGMwT1RRNU56Z3NJbWxoZENJNk1UY3hOek01TlRnd01Td2lhblJwSWpvaU5Ua3lOR0kxWm1ZdE1UVmtNeTAwTlRnM0xXSXlaamd0TW1ZeU5ERTBOR05sWlRRNUlpd2liMjF1WlcxaGJtRm5aWEpwWkNJNk1Td2ljMjkxY21ObGFXUWlPaUl6SWl3aWRYTmxjbDkwZVhCbElqb2lZMnhwWlc1MElpd2lkRzlyWlc1ZmRIbHdaU0k2SW5SeVlXUmxYMkZqWTJWemMxOTBiMnRsYmlJc0ltZHRYMmxrSWpveExDSnpiM1Z5WTJVaU9pSXpJaXdpWkdWMmFXTmxYMmxrSWpvaU5EWTVOVFptWVdZdE1UWTNOUzB6T1dZNUxXSm1PVFV0TVRGaU56Tm1Zall6TWpSbUlpd2lZV04wSWpwN2ZYMC5OLU1rZlVDcy1xZ0RzbGg5Rm9LLW1sMVdzMXhxZHdZU2ZLblJvWjlfNUppQ2hhbTd5Z0VBb3FmM0NieHV4SHl6MWRBOVN5d0FySTcydWpjR1AwMzBkQSIsIkFQSS1LRVkiOiJ0ZTJXcjlmSSIsImlhdCI6MTcxNzM5NTg2MSwiZXhwIjoxNzE3NDk0OTc4fQ.MgTimFvHRX-6rcOwfdJZ7fLDxqc1gfMUyBcummhbyilM71zlLbkS5mNs_sCS0SQsosfLu-nxtnuynGQtg_MSVw'}, Request: {'exchange': 'NSE', 'symboltoken': '15083', 'interval': 'FIVE_MINUTE', 'fromdate': '2022-04-05 09:15', 'todate': '2022-04-05 15:30'}, Response: HTTPSConnectionPool(host='apiconnect.angelbroking.com', port=443): Read timed out. (read timeout=7)
      ADANIPORTS 2022-04-05 00:00:00
      [E 240603 11:59:04 smartConnect:218] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB', 'Authorization': 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJ1c2VybmFtZSI6IlM1OTMzNTgwNiIsInJvbGVzIjowLCJ1c2VydHlwZSI6IlVTRVIiLCJ0b2tlbiI6ImV5SmhiR2NpT2lKSVV6VXhNaUlzSW5SNWNDSTZJa3BYVkNKOS5leUp6ZFdJaU9pSlROVGt6TXpVNE1EWWlMQ0psZUhBaU9qRTNNVGMwT1RRNU56Z3NJbWxoZENJNk1UY3hOek01TlRnd01Td2lhblJwSWpvaU5Ua3lOR0kxWm1ZdE1UVmtNeTAwTlRnM0xXSXlaamd0TW1ZeU5ERTBOR05sWlRRNUlpd2liMjF1WlcxaGJtRm5aWEpwWkNJNk1Td2ljMjkxY21ObGFXUWlPaUl6SWl3aWRYTmxjbDkwZVhCbElqb2lZMnhwWlc1MElpd2lkRzlyWlc1ZmRIbHdaU0k2SW5SeVlXUmxYMkZqWTJWemMxOTBiMnRsYmlJc0ltZHRYMmxrSWpveExDSnpiM1Z5WTJVaU9pSXpJaXdpWkdWMmFXTmxYMmxrSWpvaU5EWTVOVFptWVdZdE1UWTNOUzB6T1dZNUxXSm1PVFV0TVRGaU56Tm1Zall6TWpSbUlpd2lZV04wSWpwN2ZYMC5OLU1rZlVDcy1xZ0RzbGg5Rm9LLW1sMVdzMXhxZHdZU2ZLblJvWjlfNUppQ2hhbTd5Z0VBb3FmM0NieHV4SHl6MWRBOVN5d0FySTcydWpjR1AwMzBkQSIsIkFQSS1LRVkiOiJ0ZTJXcjlmSSIsImlhdCI6MTcxNzM5NTg2MSwiZXhwIjoxNzE3NDk0OTc4fQ.MgTimFvHRX-6rcOwfdJZ7fLDxqc1gfMUyBcummhbyilM71zlLbkS5mNs_sCS0SQsosfLu-nxtnuynGQtg_MSVw'}, Request: {'exchange': 'NSE', 'symboltoken': '20374', 'interval': 'FIVE_MINUTE', 'fromdate': '2022-04-08 09:15', 'todate': '2022-04-08 15:30'}, Response: HTTPSConnectionPool(host='apiconnect.angelbroking.com', port=443): Max retries exceeded with url: /rest/secure/angelbroking/historical/v1/getCandleData (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x000001EDE1DD0A90>, 'Connection to apiconnect.angelbroking.com timed out. (connect timeout=7)'))
      COALINDIA 2022-04-08 00:00:00
      [E 240603 11:59:11 smartConnect:218] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB', 'Authorization': 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJ1c2VybmFtZSI6IlM1OTMzNTgwNiIsInJvbGVzIjowLCJ1c2VydHlwZSI6IlVTRVIiLCJ0b2tlbiI6ImV5SmhiR2NpT2lKSVV6VXhNaUlzSW5SNWNDSTZJa3BYVkNKOS5leUp6ZFdJaU9pSlROVGt6TXpVNE1EWWlMQ0psZUhBaU9qRTNNVGMwT1RRNU56Z3NJbWxoZENJNk1UY3hOek01TlRnd01Td2lhblJwSWpvaU5Ua3lOR0kxWm1ZdE1UVmtNeTAwTlRnM0xXSXlaamd0TW1ZeU5ERTBOR05sWlRRNUlpd2liMjF1WlcxaGJtRm5aWEpwWkNJNk1Td2ljMjkxY21ObGFXUWlPaUl6SWl3aWRYTmxjbDkwZVhCbElqb2lZMnhwWlc1MElpd2lkRzlyWlc1ZmRIbHdaU0k2SW5SeVlXUmxYMkZqWTJWemMxOTBiMnRsYmlJc0ltZHRYMmxrSWpveExDSnpiM1Z5WTJVaU9pSXpJaXdpWkdWMmFXTmxYMmxrSWpvaU5EWTVOVFptWVdZdE1UWTNOUzB6T1dZNUxXSm1PVFV0TVRGaU56Tm1Zall6TWpSbUlpd2lZV04wSWpwN2ZYMC5OLU1rZlVDcy1xZ0RzbGg5Rm9LLW1sMVdzMXhxZHdZU2ZLblJvWjlfNUppQ2hhbTd5Z0VBb3FmM0NieHV4SHl6MWRBOVN5d0FySTcydWpjR1AwMzBkQSIsIkFQSS1LRVkiOiJ0ZTJXcjlmSSIsImlhdCI6MTcxNzM5NTg2MSwiZXhwIjoxNzE3NDk0OTc4fQ.MgTimFvHRX-6rcOwfdJZ7fLDxqc1gfMUyBcummhbyilM71zlLbkS5mNs_sCS0SQsosfLu-nxtnuynGQtg_MSVw'}, Request: {'exchange': 'NSE', 'symboltoken': '1594', 'interval': 'FIVE_MINUTE', 'fromdate': '2022-04-18 09:15', 'todate': '2022-04-18 15:30'}, Response: HTTPSConnectionPool(host='apiconnect.angelbroking.com', port=443): Max retries exceeded with url: /rest/secure/angelbroking/historical/v1/getCandleData (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x000001EDE1DD2C50>, 'Connection to apiconnect.angelbroking.com timed out. (connect timeout=7)'))
      INFY 2022-04-18 00:00:00

      posted in Python SDK
      S
      swathi priya
    • backtesting error

      runcell(0, 'C:/Users/kswat/Downloads/orb_bktst (2).py')
      [I 240602 12:05:02 smartConnect:121] in pool
      [E 240602 12:05:10 smartConnect:218] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/auth/angelbroking/user/v1/loginByPassword. Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'clientcode': 'S59335806', 'password': '1904', 'totp': '698173'}, Response: HTTPSConnectionPool(host='apiconnect.angelbroking.com', port=443): Read timed out. (read timeout=7)
      Traceback (most recent call last):

      File ~\anaconda3\Lib\site-packages\urllib3\connectionpool.py:467 in _make_request
      self._validate_conn(conn)

      File ~\anaconda3\Lib\site-packages\urllib3\connectionpool.py:1092 in _validate_conn
      conn.connect()

      File ~\anaconda3\Lib\site-packages\urllib3\connection.py:635 in connect
      sock_and_verified = _ssl_wrap_socket_and_match_hostname(

      File ~\anaconda3\Lib\site-packages\urllib3\connection.py:776 in _ssl_wrap_socket_and_match_hostname
      ssl_sock = ssl_wrap_socket(

      File ~\anaconda3\Lib\site-packages\urllib3\util\ssl_.py:466 in ssl_wrap_socket
      ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)

      File ~\anaconda3\Lib\site-packages\urllib3\util\ssl_.py:510 in _ssl_wrap_socket_impl
      return ssl_context.wrap_socket(sock, server_hostname=server_hostname)

      File ~\anaconda3\Lib\ssl.py:517 in wrap_socket
      return self.sslsocket_class._create(

      File ~\anaconda3\Lib\ssl.py:1108 in _create
      self.do_handshake()

      File ~\anaconda3\Lib\ssl.py:1383 in do_handshake
      self._sslobj.do_handshake()

      TimeoutError: _ssl.c:989: The handshake operation timed out

      The above exception was the direct cause of the following exception:

      Traceback (most recent call last):

      File ~\anaconda3\Lib\site-packages\requests\adapters.py:486 in send
      resp = conn.urlopen(

      File ~\anaconda3\Lib\site-packages\urllib3\connectionpool.py:844 in urlopen
      retries = retries.increment(

      File ~\anaconda3\Lib\site-packages\urllib3\util\retry.py:470 in increment
      raise reraise(type(error), error, _stacktrace)

      File ~\anaconda3\Lib\site-packages\urllib3\util\util.py:39 in reraise
      raise value

      File ~\anaconda3\Lib\site-packages\urllib3\connectionpool.py:790 in urlopen
      response = self._make_request(

      File ~\anaconda3\Lib\site-packages\urllib3\connectionpool.py:491 in _make_request
      raise new_e

      File ~\anaconda3\Lib\site-packages\urllib3\connectionpool.py:469 in _make_request
      self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)

      File ~\anaconda3\Lib\site-packages\urllib3\connectionpool.py:370 in _raise_timeout
      raise ReadTimeoutError(

      ReadTimeoutError: HTTPSConnectionPool(host='apiconnect.angelbroking.com', port=443): Read timed out. (read timeout=7)

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):

      File ~\anaconda3\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
      exec(code, globals, locals)

      File c:\users\kswat\downloads\orb_bktst (2).py:16
      data = obj.generateSession(key_secret[2],key_secret[3],TOTP(key_secret[4]).now())

      File ~\anaconda3\Lib\site-packages\SmartApi\smartConnect.py:268 in generateSession
      loginResultObject=self._postRequest("api.login",params)

      File ~\anaconda3\Lib\site-packages\SmartApi\smartConnect.py:260 in _postRequest
      return self._request(route, "POST", params)

      File ~\anaconda3\Lib\site-packages\SmartApi\smartConnect.py:219 in _request
      raise e

      File ~\anaconda3\Lib\site-packages\SmartApi\smartConnect.py:207 in _request
      r = requests.request(method,

      File ~\anaconda3\Lib\site-packages\requests\api.py:59 in request
      return session.request(method=method, url=url, **kwargs)

      File ~\anaconda3\Lib\site-packages\requests\sessions.py:589 in request
      resp = self.send(prep, **send_kwargs)

      File ~\anaconda3\Lib\site-packages\requests\sessions.py:703 in send
      r = adapter.send(request, **kwargs)

      File ~\anaconda3\Lib\site-packages\requests\adapters.py:532 in send
      raise ReadTimeout(e, request=request)

      ReadTimeout: HTTPSConnectionPool(host='apiconnect.angelbroking.com', port=443): Read timed out. (read timeout=7)

      posted in Python SDK
      S
      swathi priya
    • RE: backtesting error

      @Moderator_3 hi i have tried that but I am still getting this error

      posted in General Discussion
      S
      swathi priya
    • error fetching historical data

      bktst_start_dt = "2021-06-01 09:15"
      bktst_end_dt = "2022-10-21 15:30"

      if u look into this the start date is from 2021 but it doesn't fetch data from 2021 and throws me some error
      @moderator
      ONGC 1.694915
      HDFCLIFE 1.646978
      dtype: float64
      top 5 gap stocks on 2022-05-05 00:00:00
      WIPRO 1.881037
      HINDALCO 1.808730
      INDUSINDBK 1.707043
      TECHM 1.653199
      INFY 1.595520
      dtype: float64
      top 5 gap stocks on 2022-05-06 00:00:00
      HEROMOTOCO 3.663582
      HDFCLIFE 2.588855
      HINDALCO 2.512998
      BAJAJFINSV 2.399694
      KOTAKBANK 2.361482
      dtype: float64
      top 5 gap stocks on 2022-05-09 00:00:00
      SBILIFE 2.374546
      HINDALCO 2.230986
      AXISBANK 1.960202
      ICICIBANK 1.939520
      UPL 1.887272
      dtype: float64
      top 5 gap stocks on 2022-05-10 00:00:00
      ONGC 2.610015
      HINDALCO 2.049088
      UPL 1.851852
      ASIANPAINT 1.522336
      dtype: float64
      top 5 gap stocks on 2022-05-11 00:00:00
      CIPLA 1.52783
      dtype: float64
      top 5 gap stocks on 2022-05-12 00:00:00
      MARUTI 2.365324
      HDFCBANK 2.039152
      TATAMOTORS 1.584439
      HINDALCO 1.550112
      dtype: float64
      top 5 gap stocks on 2022-05-13 00:00:00
      TATAMOTORS 3.948429
      ONGC 2.236422
      BAJAJFINSV 2.165641
      DIVISLAB 1.927529
      ADANIENT 1.921572
      dtype: float64
      top 5 gap stocks on 2022-05-16 00:00:00
      EICHERMOT 3.586624
      JSWSTEEL 2.589724
      HINDALCO 2.010309
      TATASTEEL 2.005469
      TATAMOTORS 1.879792
      dtype: float64
      top 5 gap stocks on 2022-05-17 00:00:00
      HINDALCO 2.059087
      TATASTEEL 1.857725
      TITAN 1.678043
      ONGC 1.628664
      dtype: float64
      top 5 gap stocks on 2022-05-18 00:00:00
      BHARTIARTL 1.972986
      BPCL 1.752081
      dtype: float64
      top 5 gap stocks on 2022-05-19 00:00:00
      TATAMOTORS 3.649283
      APOLLOHOSP 3.357430
      ASIANPAINT 3.212800
      HINDALCO 3.210273
      WIPRO 3.137662
      dtype: float64
      top 5 gap stocks on 2022-05-20 00:00:00
      HINDALCO 3.597122
      TATASTEEL 3.582249
      JSWSTEEL 3.465511
      TATAMOTORS 2.847109
      INDUSINDBK 2.510823
      dtype: float64
      top 5 gap stocks on 2022-05-23 00:00:00
      TATASTEEL 6.287374
      JSWSTEEL 5.878625
      NTPC 3.208556
      MARUTI 2.814172
      HINDALCO 2.586810
      dtype: float64
      top 5 gap stocks on 2022-05-24 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-05-25 00:00:00
      ADANIPORTS 2.280130
      ASIANPAINT 1.550124
      dtype: float64
      top 5 gap stocks on 2022-05-26 00:00:00
      APOLLOHOSP 3.924184
      HINDALCO 2.431649
      COALINDIA 1.798561
      ITC 1.631830
      dtype: float64
      top 5 gap stocks on 2022-05-27 00:00:00
      HINDALCO 3.739120
      ONGC 2.040816
      ADANIPORTS 1.796151
      ADANIENT 1.641908
      DIVISLAB 1.632499
      dtype: float64
      top 5 gap stocks on 2022-05-30 00:00:00
      JSWSTEEL 3.355215
      M&M 2.035997
      ADANIENT 1.915727
      INFY 1.755226
      TECHM 1.749388
      dtype: float64
      top 5 gap stocks on 2022-05-31 00:00:00
      SUNPHARMA 2.369695
      dtype: float64
      top 5 gap stocks on 2022-06-01 00:00:00
      TITAN 1.759928
      SUNPHARMA 1.673251
      dtype: float64
      top 5 gap stocks on 2022-06-02 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-06-03 00:00:00
      ULTRACEMCO 1.7835
      dtype: float64
      top 5 gap stocks on 2022-06-06 00:00:00
      JSWSTEEL 1.680149
      dtype: float64
      top 5 gap stocks on 2022-06-07 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-06-08 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-06-09 00:00:00
      LT 1.789151
      ONGC 1.591187
      dtype: float64
      top 5 gap stocks on 2022-06-10 00:00:00
      HINDALCO 2.439024
      BAJAJ-AUTO 2.001985
      INFY 1.907591
      TECHM 1.721412
      WIPRO 1.652458
      dtype: float64
      top 5 gap stocks on 2022-06-13 00:00:00
      TATAMOTORS 3.072071
      KOTAKBANK 2.723518
      TECHM 2.581430
      BAJFINANCE 2.513454
      ICICIBANK 2.465278
      dtype: float64
      top 5 gap stocks on 2022-06-14 00:00:00
      ADANIENT 9.340065
      TECHM 1.706355
      ASIANPAINT 1.644273
      dtype: float64
      top 5 gap stocks on 2022-06-15 00:00:00
      TATASTEEL 4.236097
      dtype: float64
      top 5 gap stocks on 2022-06-16 00:00:00
      ICICIBANK 1.855220
      BAJAJFINSV 1.823078
      HCLTECH 1.727447
      TATASTEEL 1.604835
      JSWSTEEL 1.509769
      dtype: float64
      top 5 gap stocks on 2022-06-17 00:00:00
      APOLLOHOSP 1.737338
      TCS 1.591343
      dtype: float64
      top 5 gap stocks on 2022-06-20 00:00:00
      ONGC 2.014846
      dtype: float64
      top 5 gap stocks on 2022-06-21 00:00:00
      HINDALCO 1.897356
      TATAMOTORS 1.646198
      TATASTEEL 1.578825
      INDUSINDBK 1.530515
      dtype: float64
      top 5 gap stocks on 2022-06-22 00:00:00
      JSWSTEEL 1.553280
      HINDALCO 1.547531
      ONGC 1.545651
      dtype: float64
      top 5 gap stocks on 2022-06-23 00:00:00
      HEROMOTOCO 1.905366
      dtype: float64
      top 5 gap stocks on 2022-06-24 00:00:00
      ICICIBANK 1.680612
      POWERGRID 1.655904
      ONGC 1.632047
      HEROMOTOCO 1.529487
      dtype: float64
      top 5 gap stocks on 2022-06-27 00:00:00
      HINDALCO 2.854483
      ICICIBANK 2.158525
      POWERGRID 2.105801
      DRREDDY 2.092977
      TATASTEEL 2.063548
      dtype: float64
      top 5 gap stocks on 2022-06-28 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-06-29 00:00:00
      APOLLOHOSP 1.828084
      WIPRO 1.696899
      HCLTECH 1.681721
      BAJFINANCE 1.636404
      BPCL 1.569366
      dtype: float64
      top 5 gap stocks on 2022-06-30 00:00:00
      BAJAJ-AUTO 3.039392
      dtype: float64
      top 5 gap stocks on 2022-07-01 00:00:00
      TITAN 2.382486
      ONGC 1.715605
      BRITANNIA 1.569351
      dtype: float64
      top 5 gap stocks on 2022-07-04 00:00:00
      JSWSTEEL 2.893668
      dtype: float64
      top 5 gap stocks on 2022-07-05 00:00:00
      TATAMOTORS 1.603623
      dtype: float64
      top 5 gap stocks on 2022-07-06 00:00:00
      ONGC 3.453689
      ASIANPAINT 2.311501
      HINDALCO 1.578566
      dtype: float64
      top 5 gap stocks on 2022-07-07 00:00:00
      TITAN 5.783318
      HINDALCO 2.023757
      dtype: float64
      top 5 gap stocks on 2022-07-08 00:00:00
      M&M 4.557487
      ONGC 2.307692
      TATASTEEL 1.988889
      HINDALCO 1.755841
      dtype: float64
      top 5 gap stocks on 2022-07-11 00:00:00
      BHARTIARTL 2.898655
      TCS 1.815982
      HINDALCO 1.552230
      dtype: float64
      top 5 gap stocks on 2022-07-12 00:00:00
      HINDALCO 1.740595
      dtype: float64
      top 5 gap stocks on 2022-07-13 00:00:00
      ASIANPAINT 1.92866
      dtype: float64
      top 5 gap stocks on 2022-07-14 00:00:00
      POWERGRID 2.238249
      HINDALCO 1.605044
      APOLLOHOSP 1.517462
      dtype: float64
      top 5 gap stocks on 2022-07-15 00:00:00
      ADANIPORTS 1.828974
      dtype: float64
      top 5 gap stocks on 2022-07-18 00:00:00
      HINDALCO 1.526173
      dtype: float64
      top 5 gap stocks on 2022-07-19 00:00:00
      BHARTIARTL 1.802277
      dtype: float64
      top 5 gap stocks on 2022-07-20 00:00:00
      ONGC 5.551212
      RELIANCE 4.222297
      INDUSINDBK 2.061974
      HINDALCO 1.916021
      JSWSTEEL 1.820980
      dtype: float64
      top 5 gap stocks on 2022-07-21 00:00:00
      INDUSINDBK 2.695326
      TECHM 1.960784
      dtype: float64
      top 5 gap stocks on 2022-07-22 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-07-25 00:00:00
      INFY 1.739361
      ULTRACEMCO 1.698484
      JSWSTEEL 1.536613
      dtype: float64
      top 5 gap stocks on 2022-07-26 00:00:00
      BAJAJFINSV 3.014359
      dtype: float64
      top 5 gap stocks on 2022-07-27 00:00:00
      UPL 1.562608
      dtype: float64
      top 5 gap stocks on 2022-07-28 00:00:00
      TATASTEEL 2.251407
      BAJFINANCE 1.964402
      INFY 1.723259
      HINDUNILVR 1.667344
      BAJAJFINSV 1.502206
      dtype: float64
      top 5 gap stocks on 2022-07-29 00:00:00
      SBILIFE 5.980108
      TATASTEEL 2.640757
      BAJAJFINSV 2.444322
      DRREDDY 1.809838
      TECHM 1.637765
      dtype: float64
      top 5 gap stocks on 2022-08-01 00:00:00
      TATASTEEL 2.695167
      M&M 2.142642
      UPL 1.605721
      dtype: float64
      top 5 gap stocks on 2022-08-02 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-08-03 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-08-04 00:00:00
      HINDALCO 3.077852
      TATACONSUM 2.516149
      dtype: float64
      top 5 gap stocks on 2022-08-05 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-08-08 00:00:00
      BPCL 2.05113
      dtype: float64
      top 5 gap stocks on 2022-08-10 00:00:00
      HEROMOTOCO 1.714724
      NTPC 1.568381
      dtype: float64
      top 5 gap stocks on 2022-08-11 00:00:00
      EICHERMOT 3.215990
      COALINDIA 2.797362
      BAJAJFINSV 1.833384
      WIPRO 1.824945
      INFY 1.719242
      dtype: float64
      top 5 gap stocks on 2022-08-12 00:00:00
      APOLLOHOSP 1.796982
      dtype: float64
      top 5 gap stocks on 2022-08-16 00:00:00
      DIVISLAB 1.712200
      M&M 1.679304
      HEROMOTOCO 1.560520
      dtype: float64
      top 5 gap stocks on 2022-08-17 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-08-18 00:00:00
      DRREDDY 1.758613
      dtype: float64
      top 5 gap stocks on 2022-08-19 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-08-22 00:00:00
      KOTAKBANK 2.666489
      dtype: float64
      top 5 gap stocks on 2022-08-23 00:00:00
      INDUSINDBK 2.099886
      INFY 1.754831
      TECHM 1.548160
      dtype: float64
      top 5 gap stocks on 2022-08-24 00:00:00
      BHARTIARTL 1.999729
      dtype: float64
      top 5 gap stocks on 2022-08-25 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-08-26 00:00:00
      M&M 1.607589
      dtype: float64
      top 5 gap stocks on 2022-08-29 00:00:00
      HINDALCO 4.999432
      SBILIFE 4.392175
      COALINDIA 3.718200
      TECHM 3.643314
      HCLTECH 3.494951
      dtype: float64
      top 5 gap stocks on 2022-08-30 00:00:00
      BAJAJFINSV 1.887309
      TATASTEEL 1.573677
      dtype: float64
      top 5 gap stocks on 2022-09-01 00:00:00
      EICHERMOT 3.505769
      HINDALCO 3.416856
      SBILIFE 2.859078
      ICICIBANK 2.738645
      ONGC 2.597403
      dtype: float64
      top 5 gap stocks on 2022-09-02 00:00:00
      BAJAJFINSV 1.658011
      dtype: float64
      top 5 gap stocks on 2022-09-05 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-06 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-07 00:00:00
      HINDALCO 1.554705
      dtype: float64
      top 5 gap stocks on 2022-09-08 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-09 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-12 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-13 00:00:00
      HDFCLIFE 4.571774
      BAJAJFINSV 2.403417
      dtype: float64
      top 5 gap stocks on 2022-09-14 00:00:00
      WIPRO 3.229623
      INFY 3.103660
      TECHM 3.089459
      TCS 2.921641
      HINDALCO 2.439024
      dtype: float64
      top 5 gap stocks on 2022-09-15 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-16 00:00:00
      TECHM 1.66205
      dtype: float64
      top 5 gap stocks on 2022-09-19 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-20 00:00:00
      ADANIPORTS 1.521467
      dtype: float64
      top 5 gap stocks on 2022-09-21 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-22 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-23 00:00:00
      TATASTEEL 2.509653
      dtype: float64
      top 5 gap stocks on 2022-09-26 00:00:00
      RELIANCE 1.862989
      M&M 1.752731
      TATAMOTORS 1.678090
      HINDALCO 1.602119
      dtype: float64
      top 5 gap stocks on 2022-09-27 00:00:00
      POWERGRID 2.462825
      TATAMOTORS 1.610063
      TATASTEEL 1.502253
      dtype: float64
      top 5 gap stocks on 2022-09-28 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-29 00:00:00
      TATAMOTORS 2.981709
      TATASTEEL 1.890756
      INDUSINDBK 1.674117
      HINDALCO 1.663202
      BAJFINANCE 1.527247
      dtype: float64
      top 5 gap stocks on 2022-09-30 00:00:00
      GRASIM 1.642635
      dtype: float64
      top 5 gap stocks on 2022-10-03 00:00:00
      ONGC 3.864353
      EICHERMOT 2.979627
      MARUTI 1.606792
      dtype: float64
      top 5 gap stocks on 2022-10-04 00:00:00
      HINDALCO 3.950650
      SBIN 2.549303
      ADANIPORTS 2.498725
      ADANIENT 2.302600
      BAJFINANCE 2.275579
      dtype: float64
      top 5 gap stocks on 2022-10-06 00:00:00
      HINDALCO 2.017510
      ONGC 1.941748
      dtype: float64
      top 5 gap stocks on 2022-10-07 00:00:00
      TITAN 3.746842
      dtype: float64
      top 5 gap stocks on 2022-10-10 00:00:00
      TATAMOTORS 2.123013
      WIPRO 1.911296
      ASIANPAINT 1.905075
      HINDALCO 1.848699
      CIPLA 1.813357
      dtype: float64
      top 5 gap stocks on 2022-10-11 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-10-12 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-10-13 00:00:00
      WIPRO 5.135433
      HINDALCO 2.698651
      HCLTECH 2.106092
      dtype: float64
      top 5 gap stocks on 2022-10-14 00:00:00
      INFY 4.584830
      ICICIBANK 3.537957
      HDFCLIFE 2.640930
      ADANIPORTS 2.453011
      HINDALCO 2.415639
      dtype: float64
      top 5 gap stocks on 2022-10-17 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-10-18 00:00:00
      WIPRO 2.292722
      dtype: float64
      top 5 gap stocks on 2022-10-19 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-10-20 00:00:00
      HINDALCO 1.870356
      dtype: float64
      top 5 gap stocks on 2022-10-21 00:00:00
      AXISBANK 4.147242
      dtype: float64
      [E 240602 10:31:08 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Error: Something Went Wrong, Please Try After Sometime. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'exchange': 'NSE', 'symboltoken': '910', 'interval': 'FIVE_MINUTE', 'fromdate': '2021-11-04 09:15', 'todate': '2021-11-04 15:30'}, Response: {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}
      EICHERMOT 2021-11-04 00:00:00

      @Moderator_3 this is my code please check and give me an answer

      from SmartApi import SmartConnect
      import os
      import urllib
      import json
      import pandas as pd
      import time
      from pyotp import TOTP

      key_path = r"C:\Users\kswat\angelone"
      os.chdir(key_path)

      key_secret = open("angeloneapi.txt","r").read().split()
      obj=SmartConnect(api_key=key_secret[0])
      data = obj.generateSession(key_secret[2],key_secret[3],TOTP(key_secret[4]).now())

      instrument_url = "https://margincalculator.angelbroking.com/OpenAPI_File/files/OpenAPIScripMaster.json"
      response = urllib.request.urlopen(instrument_url)
      instrument_list = json.loads(response.read())

      tickers = ["WIPRO","ULTRACEMCO","UPL","TITAN","TECHM","TATASTEEL","TATAMOTORS",
      "TATACONSUM","TCS","SUNPHARMA","SBIN","SBILIFE","RELIANCE","POWERGRID",
      "ONGC","NESTLEIND","NTPC","MARUTI","M&M","LT","KOTAKBANK","JSWSTEEL",
      "INFY","INDUSINDBK","ITC","ICICIBANK","HINDUNILVR","HINDALCO",
      "HEROMOTOCO","HDFCLIFE","HDFCBANK","HCLTECH","GRASIM","EICHERMOT",
      "DRREDDY","DIVISLAB","COALINDIA","CIPLA","BRITANNIA","BHARTIARTL",
      "BPCL","BAJAJFINSV","BAJFINANCE","BAJAJ-AUTO","AXISBANK","ASIANPAINT",
      "APOLLOHOSP","ADANIPORTS","ADANIENT"]

      bktst_start_dt = "2021-06-01 09:15"
      bktst_end_dt = "2022-10-21 15:30"

      def token_lookup(ticker, instrument_list, exchange="NSE"):
      for instrument in instrument_list:
      if instrument["name"] == ticker and instrument["exch_seg"] == exchange and instrument["symbol"].split('-')[-1] == "EQ":
      return instrument["token"]

      def symbol_lookup(token, instrument_list, exchange="NSE"):
      for instrument in instrument_list:
      if instrument["token"] == token and instrument["exch_seg"] == exchange and instrument["symbol"].split('-')[-1] == "EQ":
      return instrument["name"]

      def hist_data_daily(tickers,instrument_list,exchange="NSE"):
      hist_data_tickers = {}
      for ticker in tickers:
      time.sleep(0.3)
      params = {
      "exchange": exchange,
      "symboltoken": token_lookup(ticker,instrument_list),
      "interval": "ONE_DAY",
      "fromdate": bktst_start_dt,
      "todate": bktst_end_dt
      }
      hist_data = obj.getCandleData(params)
      df_data = pd.DataFrame(hist_data["data"],
      columns = ["date","open","high","low","close","volume"])
      df_data.set_index("date",inplace=True)
      df_data.index = pd.to_datetime(df_data.index)
      df_data.index = df_data.index.tz_localize(None)
      df_data["gap"] = ((df_data["open"]/df_data["close"].shift(1))-1)*100
      df_data["avvol"] = df_data["volume"].rolling(10).mean().shift(1)
      hist_data_tickers[ticker] = df_data
      return hist_data_tickers

      def hist_data_intraday(ticker,datestamp,interval,instrument_list,exchange="NSE"):
      params = {
      "exchange": exchange,
      "symboltoken": token_lookup(ticker,instrument_list),
      "interval": interval,
      "fromdate": datestamp.strftime("%Y-%m-%d")+ " 09:15",
      "todate": datestamp.strftime("%Y-%m-%d") + " 15:30"
      }
      hist_data = obj.getCandleData(params)
      df_data = pd.DataFrame(hist_data["data"],
      columns = ["date","open","high","low","close","volume"])
      df_data.set_index("date",inplace=True)
      df_data.index = pd.to_datetime(df_data.index)
      df_data.index = df_data.index.tz_localize(None)
      return df_data

      candle_data = hist_data_daily(tickers, instrument_list)

      def topGap(data):
      top_gap_by_date = {}
      dates = data[tickers[0]].index.to_list()
      for date in dates:
      temp = pd.Series()
      for ticker in data:
      try:
      temp.loc[ticker] = data[ticker].loc[date,"gap"]
      except:
      pass
      top_gap_by_date[date] = (abs(temp[abs(temp)>1.5])).sort_values(ascending=False)[:5].index.to_list()
      print("top 5 gap stocks on {}".format(date))
      print((abs(temp[abs(temp)>1.5])).sort_values(ascending=False)[:5])

      return top_gap_by_date
      

      top_gap_by_date = topGap(candle_data)

      def backtest(top_gap_by_date, candle_data):
      date_stats = {}
      for date in top_gap_by_date:
      date_orgnl = date.strftime("%Y-%m-%d %H:%M")
      date_stats[date] = {}
      for ticker in top_gap_by_date[date]:
      try:
      intraday_df = hist_data_intraday(ticker,date,'FIVE_MINUTE',instrument_list)
      hi_price = intraday_df.iloc[0]['high']
      lo_price = intraday_df.iloc[0]['low']
      open_price = ''
      direction = ''
      date_stats[date][ticker] = 0
      for i in range(1,len(intraday_df[1:])):
      if intraday_df.iloc[i]["volume"] > 2*(candle_data[ticker].loc[date_orgnl,"avvol"])/75
      and intraday_df.iloc[i]["high"] > hi_price
      and open_price == '':
      open_price = 0.8intraday_df.iloc[i+1]["open"] + 0.2intraday_df.iloc[i+1]["high"] #factoring in slippage
      direction = 'long'
      elif intraday_df.iloc[i]["volume"] > 2*(candle_data[ticker].loc[date_orgnl,"avvol"])/75
      and intraday_df.iloc[i]["low"] < lo_price
      and open_price == '':
      open_price = 0.8intraday_df.iloc[i+1]["open"] + 0.2intraday_df.iloc[i+1]["low"] #factoring in slippage
      direction = 'short'

                      if open_price != '' and direction == 'long':
                          if intraday_df.iloc[i]["high"] > hi_price*1.05:
                              ticker_return = ((hi_price*1.05)/open_price)-1
                              date_stats[date][ticker] = ticker_return
                              break
                          elif intraday_df.iloc[i]["low"] < lo_price:
                              ticker_return = (lo_price/open_price) - 1
                              date_stats[date][ticker] = ticker_return
                              break
                          else:
                              ticker_return = (intraday_df.iloc[i]["close"]/open_price) - 1
                              date_stats[date][ticker] = ticker_return
                              
                      if open_price != '' and direction == 'short':
                          if intraday_df.iloc[i]["low"] < lo_price*0.95:
                              ticker_return = 1 - ((lo_price*0.95)/open_price)
                              date_stats[date][ticker] = ticker_return
                              break
                          elif intraday_df.iloc[i]["high"] > hi_price:
                              ticker_return = 1 - (hi_price/open_price)
                              date_stats[date][ticker] = ticker_return
                              break
                          else:
                              ticker_return = 1 - (intraday_df.iloc[i]["close"]/open_price)
                              date_stats[date][ticker] = ticker_return
              except:
                  print(ticker,date)
                                                   
      return date_stats
      

      date_stats = backtest(top_gap_by_date, candle_data)

      ###########################KPIs#####################################

      def abs_return(date_stats):
      df = pd.DataFrame(date_stats).T
      df["ret"] = df.mean(axis=1)
      df["ret"].fillna(0,inplace=True)
      return (1+df["ret"]).cumprod().iloc[-1] - 1

      def win_rate(date_stats):
      win_count = 0
      lose_count = 0
      for i in date_stats:
      for ticker in date_stats[i]:
      if date_stats[i][ticker] > 0:
      win_count+=1
      elif date_stats[i][ticker] < 0:
      lose_count+=1
      return (win_count/(win_count+lose_count))*100

      def mean_ret_winner(date_stats):
      win_ret = []
      for i in date_stats:
      for ticker in date_stats[i]:
      if date_stats[i][ticker] > 0:
      win_ret.append(date_stats[i][ticker])
      return sum(win_ret)/len(win_ret)

      def mean_ret_loser(date_stats):
      los_ret = []
      for i in date_stats:
      for ticker in date_stats[i]:
      if date_stats[i][ticker] < 0:
      los_ret.append(date_stats[i][ticker])
      return sum(los_ret)/len(los_ret)

      def equity_curve(date_stats):
      df = pd.DataFrame(date_stats).T
      df["ret"] = df.mean(axis=1)
      df["ret"].fillna(0,inplace=True)
      df["cum_ret"] = (1+df["ret"]).cumprod() - 1
      df["cum_ret"].plot(title="return profile")

      print("*Strategy Performance Statistics")
      print("total cumulative return = {}".format(round(abs_return(date_stats),4)))
      print("total win rate = {}".format(round(win_rate(date_stats),2)))
      print("mean return per win trade = {}".format(round(mean_ret_winner(date_stats),4)))
      print("mean return per loss trade = {}".format(round(mean_ret_loser(date_stats),4)))
      equity_curve(date_stats)

      posted in Python SDK
      S
      swathi priya
    • RE: backtesting error

      @Moderator_3 runcell(0, 'C:/Users/kswat/Downloads/orb_bktst (2).py')
      [I 240531 20:01:01 smartConnect:121] in pool
      [E 240531 20:01:09 smartConnect:218] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/auth/angelbroking/user/v1/loginByPassword. Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'clientcode': 'S59335806', 'password': '1904', 'totp': '243332'}, Response: HTTPSConnectionPool(host='apiconnect.angelbroking.com', port=443): Read timed out. (read timeout=7)
      Traceback (most recent call last):

      File ~\anaconda3\Lib\site-packages\urllib3\connectionpool.py:467 in _make_request
      self._validate_conn(conn)

      File ~\anaconda3\Lib\site-packages\urllib3\connectionpool.py:1092 in _validate_conn
      conn.connect()

      File ~\anaconda3\Lib\site-packages\urllib3\connection.py:635 in connect
      sock_and_verified = _ssl_wrap_socket_and_match_hostname(

      File ~\anaconda3\Lib\site-packages\urllib3\connection.py:776 in _ssl_wrap_socket_and_match_hostname
      ssl_sock = ssl_wrap_socket(

      File ~\anaconda3\Lib\site-packages\urllib3\util\ssl_.py:466 in ssl_wrap_socket
      ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)

      File ~\anaconda3\Lib\site-packages\urllib3\util\ssl_.py:510 in _ssl_wrap_socket_impl
      return ssl_context.wrap_socket(sock, server_hostname=server_hostname)

      File ~\anaconda3\Lib\ssl.py:517 in wrap_socket
      return self.sslsocket_class._create(

      File ~\anaconda3\Lib\ssl.py:1108 in _create
      self.do_handshake()

      File ~\anaconda3\Lib\ssl.py:1383 in do_handshake
      self._sslobj.do_handshake()

      TimeoutError: _ssl.c:989: The handshake operation timed out

      The above exception was the direct cause of the following exception:

      Traceback (most recent call last):

      File ~\anaconda3\Lib\site-packages\requests\adapters.py:486 in send
      resp = conn.urlopen(

      File ~\anaconda3\Lib\site-packages\urllib3\connectionpool.py:844 in urlopen
      retries = retries.increment(

      File ~\anaconda3\Lib\site-packages\urllib3\util\retry.py:470 in increment
      raise reraise(type(error), error, _stacktrace)

      File ~\anaconda3\Lib\site-packages\urllib3\util\util.py:39 in reraise
      raise value

      File ~\anaconda3\Lib\site-packages\urllib3\connectionpool.py:790 in urlopen
      response = self._make_request(

      File ~\anaconda3\Lib\site-packages\urllib3\connectionpool.py:491 in _make_request
      raise new_e

      File ~\anaconda3\Lib\site-packages\urllib3\connectionpool.py:469 in _make_request
      self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)

      File ~\anaconda3\Lib\site-packages\urllib3\connectionpool.py:370 in _raise_timeout
      raise ReadTimeoutError(

      ReadTimeoutError: HTTPSConnectionPool(host='apiconnect.angelbroking.com', port=443): Read timed out. (read timeout=7)

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):

      File ~\anaconda3\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
      exec(code, globals, locals)

      File c:\users\kswat\downloads\orb_bktst (2).py:16
      data = obj.generateSession(key_secret[2],key_secret[3],TOTP(key_secret[4]).now())

      File ~\anaconda3\Lib\site-packages\SmartApi\smartConnect.py:268 in generateSession
      loginResultObject=self._postRequest("api.login",params)

      File ~\anaconda3\Lib\site-packages\SmartApi\smartConnect.py:260 in _postRequest
      return self._request(route, "POST", params)

      File ~\anaconda3\Lib\site-packages\SmartApi\smartConnect.py:219 in _request
      raise e

      File ~\anaconda3\Lib\site-packages\SmartApi\smartConnect.py:207 in _request
      r = requests.request(method,

      File ~\anaconda3\Lib\site-packages\requests\api.py:59 in request
      return session.request(method=method, url=url, **kwargs)

      File ~\anaconda3\Lib\site-packages\requests\sessions.py:589 in request
      resp = self.send(prep, **send_kwargs)

      File ~\anaconda3\Lib\site-packages\requests\sessions.py:703 in send
      r = adapter.send(request, **kwargs)

      File ~\anaconda3\Lib\site-packages\requests\adapters.py:532 in send
      raise ReadTimeout(e, request=request)

      ReadTimeout: HTTPSConnectionPool(host='apiconnect.angelbroking.com', port=443): Read timed out. (read timeout=7)

      now this is the error that is occuring

      posted in General Discussion
      S
      swathi priya
    • RE: backtesting error

      @Moderator_3 I am already using that double quote only but still I am facing that issue

      posted in General Discussion
      S
      swathi priya
    • backtesting error

      @moderator please look into this
      top 5 gap stocks on 2022-07-21 00:00:00
      INDUSINDBK 2.695326
      TECHM 1.960784
      dtype: float64
      top 5 gap stocks on 2022-07-22 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-07-25 00:00:00
      INFY 1.739361
      ULTRACEMCO 1.698484
      JSWSTEEL 1.536613
      dtype: float64
      top 5 gap stocks on 2022-07-26 00:00:00
      BAJAJFINSV 3.014359
      dtype: float64
      top 5 gap stocks on 2022-07-27 00:00:00
      UPL 1.562608
      dtype: float64
      top 5 gap stocks on 2022-07-28 00:00:00
      TATASTEEL 2.251407
      BAJFINANCE 1.964402
      INFY 1.723259
      HINDUNILVR 1.667344
      BAJAJFINSV 1.502206
      dtype: float64
      top 5 gap stocks on 2022-07-29 00:00:00
      SBILIFE 5.980108
      TATASTEEL 2.640757
      BAJAJFINSV 2.444322
      DRREDDY 1.809838
      TECHM 1.637765
      dtype: float64
      top 5 gap stocks on 2022-08-01 00:00:00
      TATASTEEL 2.695167
      M&M 2.142642
      UPL 1.605721
      dtype: float64
      top 5 gap stocks on 2022-08-02 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-08-03 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-08-04 00:00:00
      HINDALCO 3.077852
      TATACONSUM 2.516149
      dtype: float64
      top 5 gap stocks on 2022-08-05 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-08-08 00:00:00
      BPCL 2.05113
      dtype: float64
      top 5 gap stocks on 2022-08-10 00:00:00
      HEROMOTOCO 1.714724
      NTPC 1.568381
      dtype: float64
      top 5 gap stocks on 2022-08-11 00:00:00
      EICHERMOT 3.215990
      BAJAJFINSV 1.833384
      WIPRO 1.824945
      INFY 1.719242
      TECHM 1.592115
      dtype: float64
      top 5 gap stocks on 2022-08-12 00:00:00
      APOLLOHOSP 1.796982
      dtype: float64
      top 5 gap stocks on 2022-08-16 00:00:00
      DIVISLAB 1.712200
      M&M 1.679304
      HEROMOTOCO 1.560520
      dtype: float64
      top 5 gap stocks on 2022-08-17 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-08-18 00:00:00
      DRREDDY 1.758613
      dtype: float64
      top 5 gap stocks on 2022-08-19 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-08-22 00:00:00
      KOTAKBANK 2.666489
      dtype: float64
      top 5 gap stocks on 2022-08-23 00:00:00
      INDUSINDBK 2.099886
      INFY 1.754831
      TECHM 1.548160
      dtype: float64
      top 5 gap stocks on 2022-08-24 00:00:00
      BHARTIARTL 1.999729
      dtype: float64
      top 5 gap stocks on 2022-08-25 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-08-26 00:00:00
      M&M 1.607589
      dtype: float64
      top 5 gap stocks on 2022-08-29 00:00:00
      HINDALCO 4.999432
      SBILIFE 4.392175
      TECHM 3.643314
      HCLTECH 3.494951
      INFY 3.483290
      dtype: float64
      top 5 gap stocks on 2022-08-30 00:00:00
      BAJAJFINSV 1.887309
      TATASTEEL 1.573677
      dtype: float64
      top 5 gap stocks on 2022-09-01 00:00:00
      EICHERMOT 3.505769
      HINDALCO 3.416856
      SBILIFE 2.859078
      ICICIBANK 2.738645
      ONGC 2.597403
      dtype: float64
      top 5 gap stocks on 2022-09-02 00:00:00
      BAJAJFINSV 1.658011
      dtype: float64
      top 5 gap stocks on 2022-09-05 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-06 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-07 00:00:00
      HINDALCO 1.554705
      dtype: float64
      top 5 gap stocks on 2022-09-08 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-09 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-12 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-13 00:00:00
      HDFCLIFE 4.571774
      BAJAJFINSV 2.403417
      dtype: float64
      top 5 gap stocks on 2022-09-14 00:00:00
      WIPRO 3.229623
      INFY 3.103660
      TECHM 3.089459
      TCS 2.921641
      HINDALCO 2.439024
      dtype: float64
      top 5 gap stocks on 2022-09-15 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-16 00:00:00
      TECHM 1.66205
      dtype: float64
      top 5 gap stocks on 2022-09-19 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-20 00:00:00
      ADANIPORTS 1.521467
      dtype: float64
      top 5 gap stocks on 2022-09-21 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-22 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-23 00:00:00
      TATASTEEL 2.509653
      dtype: float64
      top 5 gap stocks on 2022-09-26 00:00:00
      RELIANCE 1.862989
      M&M 1.752731
      TATAMOTORS 1.678090
      HINDALCO 1.602119
      dtype: float64
      top 5 gap stocks on 2022-09-27 00:00:00
      POWERGRID 2.462825
      TATAMOTORS 1.610063
      TATASTEEL 1.502253
      dtype: float64
      top 5 gap stocks on 2022-09-28 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-09-29 00:00:00
      TATAMOTORS 2.981709
      TATASTEEL 1.890756
      INDUSINDBK 1.674117
      HINDALCO 1.663202
      BAJFINANCE 1.527247
      dtype: float64
      top 5 gap stocks on 2022-09-30 00:00:00
      GRASIM 1.642635
      dtype: float64
      top 5 gap stocks on 2022-10-03 00:00:00
      ONGC 3.864353
      EICHERMOT 2.979627
      MARUTI 1.606792
      dtype: float64
      top 5 gap stocks on 2022-10-04 00:00:00
      HINDALCO 3.950650
      SBIN 2.549303
      ADANIPORTS 2.498725
      ADANIENT 2.302600
      BAJFINANCE 2.275579
      dtype: float64
      top 5 gap stocks on 2022-10-06 00:00:00
      HINDALCO 2.017510
      ONGC 1.941748
      dtype: float64
      top 5 gap stocks on 2022-10-07 00:00:00
      TITAN 3.746842
      dtype: float64
      top 5 gap stocks on 2022-10-10 00:00:00
      TATAMOTORS 2.123013
      WIPRO 1.911296
      ASIANPAINT 1.905075
      HINDALCO 1.848699
      CIPLA 1.813357
      dtype: float64
      top 5 gap stocks on 2022-10-11 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-10-12 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-10-13 00:00:00
      WIPRO 5.135433
      HINDALCO 2.698651
      HCLTECH 2.106092
      dtype: float64
      top 5 gap stocks on 2022-10-14 00:00:00
      INFY 4.584830
      ICICIBANK 3.537957
      HDFCLIFE 2.640930
      ADANIPORTS 2.453011
      HINDALCO 2.415639
      dtype: float64
      top 5 gap stocks on 2022-10-17 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-10-18 00:00:00
      WIPRO 2.292722
      dtype: float64
      top 5 gap stocks on 2022-10-19 00:00:00
      Series([], dtype: float64)
      top 5 gap stocks on 2022-10-20 00:00:00
      HINDALCO 1.870356
      dtype: float64
      top 5 gap stocks on 2022-10-21 00:00:00
      AXISBANK 4.147242
      dtype: float64
      [E 240531 11:57:49 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Error: Something Went Wrong, Please Try After Sometime. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'exchange': 'NSE', 'symboltoken': '910', 'interval': 'FIVE_MINUTE', 'fromdate': '2021-11-04 09:15', 'todate': '2021-11-04 15:30'}, Response: {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}
      EICHERMOT 2021-11-04 00:00:00
      [E 240531 12:00:19 smartConnect:218] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB', 'Authorization': 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJ1c2VybmFtZSI6IlM1OTMzNTgwNiIsInJvbGVzIjowLCJ1c2VydHlwZSI6IlVTRVIiLCJ0b2tlbiI6ImV5SmhiR2NpT2lKSVV6VXhNaUlzSW5SNWNDSTZJa3BYVkNKOS5leUp6ZFdJaU9pSlROVGt6TXpVNE1EWWlMQ0psZUhBaU9qRTNNVGN5TWpjeU16Z3NJbWxoZENJNk1UY3hOekV6TmpJMk1Td2lhblJwSWpvaU5USTBNVFkzTWpRdE9HTTFaQzAwWVdJMkxXRmtNVFl0WTJZNE5ETmhNbU5oTnpGaUlpd2liMjF1WlcxaGJtRm5aWEpwWkNJNk1Td2ljMjkxY21ObGFXUWlPaUl6SWl3aWRYTmxjbDkwZVhCbElqb2lZMnhwWlc1MElpd2lkRzlyWlc1ZmRIbHdaU0k2SW5SeVlXUmxYMkZqWTJWemMxOTBiMnRsYmlJc0ltZHRYMmxrSWpveExDSnpiM1Z5WTJVaU9pSXpJaXdpWkdWMmFXTmxYMmxrSWpvaU5EWTVOVFptWVdZdE1UWTNOUzB6T1dZNUxXSm1PVFV0TVRGaU56Tm1Zall6TWpSbUlpd2lZV04wSWpwN2ZYMC5FT2FreklSMVhCMTlXWFhnYTdxeVJzb0dLS3RJMW9iWEtLemNsc19BS1AtZEhGVWZscVNMcm1Wc05JWFlYcWkyQ2lFendlZ1ViMDhBMDBpWklxV2U3QSIsIkFQSS1LRVkiOiJ0ZTJXcjlmSSIsImlhdCI6MTcxNzEzNjMyMSwiZXhwIjoxNzE3MjI3MjM4fQ.sugV1uP9RiE9wKXVYfiDTYZ9QjjDNyJCkcWn2gWMJVGkfkSTiE2z6g9WDCTDaQuDrm7FPC-_rgZYJl27AaE9iQ'}, Request: {'exchange': 'NSE', 'symboltoken': '14977', 'interval': 'FIVE_MINUTE', 'fromdate': '2021-12-22 09:15', 'todate': '2021-12-22 15:30'}, Response: HTTPSConnectionPool(host='apiconnect.angelbroking.com', port=443): Read timed out. (read timeout=7)
      POWERGRID 2021-12-22 00:00:00
      [E 240531 12:00:45 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Error: Something Went Wrong, Please Try After Sometime. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'exchange': 'NSE', 'symboltoken': '16675', 'interval': 'FIVE_MINUTE', 'fromdate': '2022-01-06 09:15', 'todate': '2022-01-06 15:30'}, Response: {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}
      BAJAJFINSV 2022-01-06 00:00:00
      [E 240531 12:00:46 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Error: Something Went Wrong, Please Try After Sometime. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'exchange': 'NSE', 'symboltoken': '7229', 'interval': 'FIVE_MINUTE', 'fromdate': '2022-01-06 09:15', 'todate': '2022-01-06 15:30'}, Response: {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}
      HCLTECH 2022-01-06 00:00:00
      [E 240531 12:00:48 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Error: Something Went Wrong, Please Try After Sometime. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'exchange': 'NSE', 'symboltoken': '11536', 'interval': 'FIVE_MINUTE', 'fromdate': '2022-01-10 09:15', 'todate': '2022-01-10 15:30'}, Response: {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}
      TCS 2022-01-10 00:00:00
      [E 240531 12:00:50 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Error: Something Went Wrong, Please Try After Sometime. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'exchange': 'NSE', 'symboltoken': '25', 'interval': 'FIVE_MINUTE', 'fromdate': '2022-01-12 09:15', 'todate': '2022-01-12 15:30'}, Response: {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}
      ADANIENT 2022-01-12 00:00:00
      [E 240531 12:00:51 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Error: Something Went Wrong, Please Try After Sometime. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'exchange': 'NSE', 'symboltoken': '1363', 'interval': 'FIVE_MINUTE', 'fromdate': '2022-01-12 09:15', 'todate': '2022-01-12 15:30'}, Response: {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}
      HINDALCO 2022-01-12 00:00:00
      [E 240531 12:00:53 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Error: Something Went Wrong, Please Try After Sometime. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'exchange': 'NSE', 'symboltoken': '3351', 'interval': 'FIVE_MINUTE', 'fromdate': '2022-01-12 09:15', 'todate': '2022-01-12 15:30'}, Response: {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}
      SUNPHARMA 2022-01-12 00:00:00
      [E 240531 12:00:56 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Error: Something Went Wrong, Please Try After Sometime. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'exchange': 'NSE', 'symboltoken': '3787', 'interval': 'FIVE_MINUTE', 'fromdate': '2022-01-13 09:15', 'todate': '2022-01-13 15:30'}, Response: {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}
      WIPRO 2022-01-13 00:00:00
      [E 240531 12:00:58 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Error: Something Went Wrong, Please Try After Sometime. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'exchange': 'NSE', 'symboltoken': '11536', 'interval': 'FIVE_MINUTE', 'fromdate': '2022-01-13 09:15', 'todate': '2022-01-13 15:30'}, Response: {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}
      TCS 2022-01-13 00:00:00
      [E 240531 12:01:00 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Error: Something Went Wrong, Please Try After Sometime. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'exchange': 'NSE', 'symboltoken': '10999', 'interval': 'FIVE_MINUTE', 'fromdate': '2022-01-14 09:15', 'todate': '2022-01-14 15:30'}, Response: {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}
      MARUTI 2022-01-14 00:00:00
      [E 240531 12:15:48 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Error: Something Went Wrong, Please Try After Sometime. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'exchange': 'NSE', 'symboltoken': '11532', 'interval': 'FIVE_MINUTE', 'fromdate': '2022-07-25 09:15', 'todate': '2022-07-25 15:30'}, Response: {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}
      ULTRACEMCO 2022-07-25 00:00:00
      [E 240531 12:15:50 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Error: Something Went Wrong, Please Try After Sometime. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'exchange': 'NSE', 'symboltoken': '11723', 'interval': 'FIVE_MINUTE', 'fromdate': '2022-07-25 09:15', 'todate': '2022-07-25 15:30'}, Response: {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}
      JSWSTEEL 2022-07-25 00:00:00
      [E 240531 12:15:52 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Error: Something Went Wrong, Please Try After Sometime. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'exchange': 'NSE', 'symboltoken': '16675', 'interval': 'FIVE_MINUTE', 'fromdate': '2022-07-26 09:15', 'todate': '2022-07-26 15:30'}, Response: {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}
      BAJAJFINSV 2022-07-26 00:00:00
      [E 240531 12:15:53 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData. Error: Something Went Wrong, Please Try After Sometime. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': 'a9:31:1f:9d:a7:f3', 'Accept': 'application/json', 'X-PrivateKey': 'te2Wr9fI', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'exchange': 'NSE', 'symboltoken': '11287', 'interval': 'FIVE_MINUTE', 'fromdate': '2022-07-27 09:15', 'todate': '2022-07-27 15:30'}, Response: {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}
      UPL 2022-07-27 00:00:00

      posted in General Discussion
      S
      swathi priya