PermissionException: Insufficient permission for that call.-SMA

ShreeAlgoTrader
Hi Team,

For the following program getting error report as"PermissionException: Insufficient permission for that call" Kindly advise

from kiteconnect import KiteTicker,KiteConnect
import pandas as pd
from datetime import datetime, timedelta
import talib
api_key = "api_key"
api_secret = "api_secret"
request_token = "request_token"
access_token = "access_token"
kite = KiteConnect (api_key=api_key)

kite.set_access_token(access_token)

from_date = datetime.strftime(datetime.now() - timedelta(100), '%Y-%m-%d')
to_date = datetime.today().strftime('%Y-%m-%d')
interval = "5minute"
current_signal = ''

tokens = {738561: 'RELIANCE', 341249: 'HDFCBANK'}


while True:
if (datetime.now().second == 0) and ((datetime.now().minute) % 5 == 0):
for token in tokens:
records = kite.historical_data(token,from_date=from_date,to_date=to_date,interval=interval)
df = pd.DataFrame(records)
df.drop(df.tail(1).index, inplace=True)

print(df)

open = df['open'].values
high = df['high'].values
low = df['low'].values
close = df['close'].values
volume = df['volume'].values

sma5 = talib.SMA(close,5)
sma20 = talib.SMA(close,20)
print(sma5[-1])
print(sma20[-1])

if (sma5[-2] < sma20[-2]) and (sma5[-1] > sma20[-1]):
buy_order_id = kite.place_order(tradingsymbol=tokens[token],
exchange=kite.EXCHANGE_NSE,
transaction_type=kite.TRANSACTION_TYPE_BUY,
quantity=1,
order_type=kite.ORDER_TYPE_MARKET,
product=kite.PRODUCT_MIS)


if (sma5[-2] > sma20[-2]) and (sma5[-1] < sma20[-1]):
sell_order_id = kite.place_order(tradingsymbol=tokens[token],
exchange=kite.EXCHANGE_NSE,
transaction_type=kite.TRANSACTION_TYPE_SELL,
quantity=1,
order_type=kite.ORDER_TYPE_MARKET,
product=kite.PRODUCT_MIS)


Error report :

---------------------------------------------------------------------------
PermissionException Traceback (most recent call last)
in
25 if (datetime.now().second == 0) and ((datetime.now().minute) % 5 == 0):
26 for token in tokens:
---> 27 records = kite.historical_data(token,from_date=from_date,to_date=to_date,interval=interval)
28 df = pd.DataFrame(records)
29 df.drop(df.tail(1).index, inplace=True)

~\anaconda3\lib\site-packages\kiteconnect\connect.py in historical_data(self, instrument_token, from_date, to_date, interval, continuous, oi)
628 "interval": interval,
629 "continuous": 1 if continuous else 0,
--> 630 "oi": 1 if oi else 0
631 })
632

~\anaconda3\lib\site-packages\kiteconnect\connect.py in _get(self, route, params)
815 def _get(self, route, params=None):
816 """Alias for sending a GET request."""
--> 817 return self._request(route, "GET", params)
818
819 def _post(self, route, params=None):

~\anaconda3\lib\site-packages\kiteconnect\connect.py in _request(self, route, method, parameters)
884 # native Kite errors
885 exp = getattr(ex, data["error_type"], ex.GeneralException)
--> 886 raise exp(data["message"], code=r.status_code)
887
888 return data["data"]

PermissionException: Insufficient permission for that call.

  • rakeshr
    records = kite.historical_data(token,from_date=from_date,to_date=to_date,interval=interval)
    You don't seem to have a Historical data APIs subscription. It's an add-on you need to subscribe to it from the connect developer page. Refer FAQs here.
  • ShreeAlgoTrader
    Thank you Rakeshr " You have made my day" .The issue is resolved after activating Historical data API.Once again Thank you for helping .
This discussion has been closed.