Hello. I am trying to write a trading algorithm for kraken's crypto exchange. I keep getting an error where it says "result"; here is an example:
I am trying to get the daily close price from kraken but I keep getting an error. Here is the code:
I am trying to get the daily close price from kraken but I keep getting an error. Here is the code:
import krakenex import pandas as pd # create a Kraken API client api = krakenex.API() # set the currency pair and interval pair = 'XBT/USD' interval = 1440 # 1440 minutes = 1 day # make the API request for OHLC data ohlc_data = api.query_public('OHLC', {'pair': pair, 'interval': interval}) # convert the OHLC data into a pandas dataframe df = pd.DataFrame(ohlc_data['result'][pair], columns=['time', 'open', 'high', 'low', 'close', 'vwap', 'volume', 'count']) df['time'] = pd.to_datetime(df['time'], unit='s') df.set_index('time', inplace=True) # get the daily close price daily_close = df['close'].resample('D').last() # print the most recent daily close price print(daily_close.iloc[-1])In the terminal, I am getting this error:
The error I am getting is: line 15, in <module> df = pd.DataFrame(ohlc_data['result'][pair], columns=['time', 'open', 'high', 'low', 'close', 'vwap', 'volume', 'count']) KeyError: 'result'.I've had this error from several bits of code I have wrote. All with the word result. I am new to programming and I'm using chatgpt to help me. Could anyone give me some feedback please?