Error while downloading historical data

Akshay15
from datetime import datetime, timedelta
from kiteconnect import KiteConnect
from kiteconnect import exceptions
import pdb
import pandas as pd

ak = "aadfafg"
asecret = "hz9ugaafga1qew1ojyivj8mt7v2rz3l80wjlaz"
#request_token = "uXkU3WadfafAfag91cS7f9l0FUVJQVu4J6YRS"
access_token = "Z3jyFpJw8dGddadfasdfg7pLy48VnVmRAS35Lr0Z"

kite = KiteConnect(api_key=ak)
#data = kite.generate_session(request_token,api_secret=asecret)
kite.set_access_token(access_token)

trd_portfolio = {"HDFCBANK":{'token':341249}}

token = 341249
to_date = datetime.now()
from_date = to_date - timedelta(days=30)
interval="15minute"

records = kite.historical_data(token,from_date,to_date,interval)
df = pd.DataFrame(records)
df.to_excel("zerodhastocks.xlsx")
pdb.set_trace()

guys i am running above code to get historical data but getting below error.

kiteconnect.exceptions.PermissionException: Insufficient permission for that call.
Tagged:
  • lifegreat
    Just figured out that historical data is a separate subscription

    del.png 14.5K
  • sujith
    @Akshay15,
    Please don't post app or user specific keys on the public threads. It can be easily misused.

    As mentioned above, you need a historical add-on subscription to use the same.

    PS: We have regenerated your api secret, please use the new one.
  • Akshay15
    is there anything wrong with code i have taken subscription now & still getting same error.
  • Akshay15
    Ok guys it's working now.
  • subhojit
    Hi Akshay,

    I am new to this. Can you please explain to me the steps you are following.
    like
    1> I install python
    2> Is there anything else I need to install?
    3> I run the above script that you have posted ( making changes to tokens and symbol and interval)
    4> also how to get the request token and access token?

    I know the above questions may seem very silly but any reply will be of great help to me

    Thanks and Regards
    Subhojit
  • rakeshr
    @subhojit
    2> Is there anything else I need to install?
    You need to install the required kite connect client, check all the available client and installation detail.
    4> also how to get the request token and access token?
    You can check the flow here.For python client, you can follow example here.
Sign In or Register to comment.