Getting error while fetching historical data of futures contract

shahbinoys21
Hi,

I am not an expert in coding and hence I feel I am making some silly mistake somewhere. I am trying to pull Historical data of ACC June contract, my end goal is fetch to Futures data for all contracts for last 1 year in a loop.

The code which I have written is

token =24508418
to_date= datetime.now()
from_date = to_date - timedelta(days= 60)
interval = '5minute'
records = kite.historical_data(token,from_date,to_date,interval, continuous=1)
df= pd.DataFrame(records)
df['date']=df.date.dt.strftime('%Y-%m-%d %H:%M:%S')
df.to_excel("ACC.xlsx")
print(df)

This is the error I keep on getting

Traceback (most recent call last):
File "c:\Users\Binoy\Desktop\Result Trading System\Historical_data.py", line 73, in
records = kite.historical_data(token,from_date,to_date,interval, continuous=1)
File "C:\Python 3.8.3\lib\site-packages\kiteconnect\connect.py", line 624, in historical_data
data = self._get("market.historical", {
File "C:\Python 3.8.3\lib\site-packages\kiteconnect\connect.py", line 817, in _get
return self._request(route, "GET", params)
File "C:\Python 3.8.3\lib\site-packages\kiteconnect\connect.py", line 892, in _request
raise ex.DataException("Unknown Content-Type ({content_type}) with response: ({content})".format(
kiteconnect.exceptions.DataException: Unknown Content-Type (text/html) with response: (b"

504 Gateway Time-out

\nThe server didn't respond in time.\n\n")

Now, if I am not using continuous = 1 in the code I am able to fetch the data for last 2 months, i.e May & June. Every time I use continuous or Oi in the query, it gives the above error. I have tried using 1 and true for continuous and oi, both doesn't work.

Any help would be appreciated. Thanks.
  • sujith
    We only provide day candle data for expired future instruments.
  • shahbinoys21
    Ok, thanks, any plans to introduce 5,15, hourly candle data for expired futures contracts.
  • sujith
    We don't have any plans of offering intraday data for expired instruments. You can contact any exchange registered data vendors.
  • shahbinoys21
    ok, thanks :)
This discussion has been closed.