-
Notifications
You must be signed in to change notification settings - Fork 229
Closed
Description
Hey,
I'm new to the krakenex API, i'm trying to do the following
import krakenex
import time
class krakencom():
def __init__(self):
self.k = krakenex.API(key='abc',secret="def")
def getEthEur(self):
self.etheur = self.k.query_public('Ticker', {'pair': 'ETHEUR'})["result"]['XETHZEUR']
return self.etheur
def lowestPrice(self, cur):
lowestPrice = cur['l']
return lowestPrice
def highestPrice(self, cur):
highestPrice = cur['h']
return highestPrice
def volume24h(self, cur):
volume24h = cur['v'][1]
return volume24h
def lastTrade(self, cur):
lastTrade = cur['c']
return lastTrade
krak = krakencom()
while True:
eth = krak.getEthEur()
print(krak.lastTrade(eth))
time.sleep(0.5)the out put is
[‘RESULT', 'RESULT]
and after a while ERROR !!!?!
The error happens randomly from the second query
Traceback (most recent call last):
File "/Users/MYUSER/MYDIR/MYPROJECT/krakapi.py", line 32, in <module>
eth = krak.getEthEur()
File "/Users/MYUSER/MYDIR/MYPROJECT/krakapi.py", line 10, in getEthEur
self.etheur = self.k.query_public('Ticker', {'pair': 'ETHEUR'})["result"]['XETHZEUR']
File "/usr/local/lib/python3.6/site-packages/krakenex/api.py", line 148, in query_public
return self._query(urlpath, req, conn)
File "/usr/local/lib/python3.6/site-packages/krakenex/api.py", line 131, in _query
return json.loads(ret)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)i'm on OSX 10.11.6 python 3.6.1
many thanks
lj
jacob-roth