Hey Soma,
Next time print just the hist_data variable before the next line,
In the error above I feel the candles keyword is not coming in the dictionary.
So you can have a condition like this,
if hist_data[“candles”]:
df = pd.DataFrame(hist_data[“candles”], columns=[‘date’,‘open’,‘high’,‘low’,‘close’,‘volume’])