gateio-crypto-trading-bot-binance-announcements-new-coins icon indicating copy to clipboard operation
gateio-crypto-trading-bot-binance-announcements-new-coins copied to clipboard

Error after new Coin detection

Open kahnesaaron opened this issue 3 years ago • 2 comments

Ive installed the Bot some days ago, but today was the first time it was running while a new Coin was detected. But I instantly got this error after the detection. Is this an error on my end and i need to fix a lib or something?

2022-01-06 10:42:21,312 INFO: New announcement detected: CLH
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "src/main.py", line 79, in buy
    obj = get_last_price(announcement_coin, globals.pairing, False)
  File "/home/pi/Desktop/announcement trade/src/trade_client.py", line 20, in get_last_price
    assert len(trades) == 1
AssertionError

kahnesaaron avatar Jan 06 '22 09:01 kahnesaaron

same here

jase-Base avatar Jan 06 '22 16:01 jase-Base

The method list_trades() should return the current market trades. see. https://github.com/gateio/gateapi-python/blob/master/docs/SpotApi.md#list_trades

It seems though, that none were available for the given pair, which caused the exception. This is a problem on the bot's end and not on your end.

To prevent the exception, assert should be replaced with an if-statement and that returns an invalid price (e.g. 0 / -1) if no trades are available. (buy() needs to be changed as well then to verify the price) Or return back to list_tickers as it was before (see 22748eec81).

@CyberPunkMetalHead what do you think is the best approach?

Linus045 avatar Jan 06 '22 17:01 Linus045