KeyError 'orderNumber'
bahelit opened this issue · comments
- Cointrader version: latest from git
- Python version: 2.7 (default Ubuntu 16)
- Operating System: Ubuntu 16
Description
Rand for the 1st time last night, set to auto trade. It appears that when it went to place the 1st order it crashed. Possibly null value for orderNumber caused this crash.
What I Did
cointrader --config ~/Documents/cointrader.conf start BTC_LTC --strategy klondike --resolution 5m --automatic --btc 0.0011655 --coins 0.0814746159
I just checked to place an order which seems to work. Would you mind to post the traceback? Regarding to your error message "KeyError orderNumber" I suspect a certain line in the code.
Further the checks introduced in 72722e7 might give more detailed hints in case the API reports an error.
Please recheck with the latest version.
Here's the Traceback:
Traceback (most recent call last):
Traceback (most recent call last):
File "/usr/local/bin/cointrader", line 11, in
load_entry_point('cointrader==0.5.0', 'console_scripts', 'cointrader')()
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/cointrader-0.5.0-py2.7.egg/cointrader/cli.py", line 138, in start
bot.start(backtest, automatic)
File "/usr/local/lib/python2.7/dist-packages/cointrader-0.5.0-py2.7.egg/cointrader/bot.py", line 414, in start
self._handle_signal(signal)
File "/usr/local/lib/python2.7/dist-packages/cointrader-0.5.0-py2.7.egg/cointrader/bot.py", line 339, in _handle_signal
self._buy()
File "/usr/local/lib/python2.7/dist-packages/cointrader-0.5.0-py2.7.egg/cointrader/bot.py", line 219, in _buy
order_id = result["orderNumber"]
KeyError: 'orderNumber'
Did you do this with the latest version?
I expect the order failed for some reason. I recently have similar issues in context of #35. The latest version includes some more Info on the reason into the traceback.
Have updated and am starting the program, will check it in a few hours to see if the error occurs.
Am using the same parameters. Output so far:
2017-08-28 23:04:37,226 INFO [cointrader.bot][MainThread] Loading bot BTC_LTC 6
2017-08-28 23:04:37,229 INFO [cointrader.bot][MainThread] Loaded state from trade log: 7.8e-07 BTC 0.0 COINS
Press 'A' with in the next 0 secods to reattach the bot.
Error has a message now:
Traceback (most recent call last):
File "/usr/local/bin/cointrader", line 11, in
load_entry_point('cointrader==0.5.0', 'console_scripts', 'cointrader')()
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/cointrader-0.5.0-py2.7.egg/cointrader/cli.py", line 142, in start
bot.start(backtest, automatic)
File "/usr/local/lib/python2.7/dist-packages/cointrader-0.5.0-py2.7.egg/cointrader/bot.py", line 427, in start
self._handle_signal(signal)
File "/usr/local/lib/python2.7/dist-packages/cointrader-0.5.0-py2.7.egg/cointrader/bot.py", line 352, in _handle_signal
self._buy()
File "/usr/local/lib/python2.7/dist-packages/cointrader-0.5.0-py2.7.egg/cointrader/bot.py", line 218, in _buy
result = self._market.buy(self.btc)
File "/usr/local/lib/python2.7/dist-packages/cointrader-0.5.0-py2.7.egg/cointrader/exchange.py", line 126, in buy
return self._exchange._api.buy(self._name, amount, price, option)
File "/usr/local/lib/python2.7/dist-packages/cointrader-0.5.0-py2.7.egg/cointrader/exchanges/poloniex.py", line 275, in buy
self._check_response(result)
File "/usr/local/lib/python2.7/dist-packages/cointrader-0.5.0-py2.7.egg/cointrader/exchanges/poloniex.py", line 128, in _check_response
raise ApiError(json["error"])
cointrader.exchanges.poloniex.ApiError: Total must be at least 0.0001.
Ah ok. That is good.
My current plan to solve this issue
- Handle ApiErrors and abort buy/sell but show warning to prevent the traceback.
- Try to better prevent this situations. E.g by ensuring that the bot has always the minimum account of coins/btc. If this #35 is one main reason why this can happen.
I will first start with 1
Handle ApiErrors and abort buy/sell but show warning to prevent the traceback.
abb3d13 should fix this.
Try to better prevent this situations. E.g by ensuring that the bot has always the minimum account of coins/btc. If this #35 is one main reason why this can happen.
I will handle this in #36. So I will close this issue here as the origin KeyError is fixed.