So I am writing a trading bot in python. It is more for fun and I just started. Every method works alone, so I excluded them here, to not give you 300lines of Code. I also exclude the hole analyze method, since even if I clear the rest of the method, the same Error appears. When I use analyze just once, it doesn't do anything but also gets no error and when I use it in a loop I get an error: Exception has occurred: KeyError 'result' (mark get_crypto_data) This doesn't make sense to me, since if I print get_crypto_data it works just fine. def get_crypto_data(pair,since): return api.query_public("OHLC", data = {"pair" : pair, "since" : since})["result"][pair] #array of prices (60sek) def analyze(pair,since): data = get_crypto_data(pair[0]+pair[1], since) if __name__ == "__main__": api = krakenex.API() api.load_key("KrakenKey.txt") pair = ('XETH' , 'ZEUR') # Currency pair since = str(int(time.time() - 3600)) while True: analyze(pair,since) The data structure receiving from the API looks like this(example)(without indents): { "error": [ ], "result": { "XXBTZUSD": [ [ 1616662740, "52591.9", "52599.9", "52591.8", "52599.9", "52599.1", "0.11091626", 5 ], [ 1616662800, "52600.0", "52674.9", "52599.9", "52665.2", "52643.3", "2.49035996", 30 ], [ 1616662860, "52677.7", "52686.4", "52602.1", "52609.5", "52634.5", "1.25810675", 20 ], [ 1616662920, "52603.9", "52627.5", "52601.2", "52616.4", "52614.0", "3.42391799", 23 ], [ 1616662980, "52601.2", "52601.2", "52599.9", "52599.9", "52599.9", "0.43748934", 7 ] ], "last": 1616662920 } } Continue reading...