CyberPunkMetalHead / gateio-crypto-trading-bot-binance-announcements-new-coins

This is a crypto trading bot that scans the Binance Annoucements page for new coins, and places trades on Gateio
MIT License
1.21k stars 302 forks source link

When chosen pairing doesn't exist, print error accordingly #172

Open coy123 opened 2 years ago

coy123 commented 2 years ago

https://github.com/CyberPunkMetalHead/gateio-crypto-trading-bot-binance-announcements-new-coins/blob/180763fa167ede0a7534d485a3c4c7b3030b43ec/src/gateio_new_coins_announcements_bot/trade_client.py#L22-L23

I had USDC as my preferred pairing in the last WOO anouncement. Gate.io, however, only makes USDT_WOO and ETH_WOO pairings available. This assert line caused the following error:

{"log":"Traceback (most recent call last):\n","stream":"stderr","time":"2022-02-08T02:20:56.351154707Z"}
{"log":"  File \"/usr/local/lib/python3.9/threading.py\", line 973, in _bootstrap_inner\n","stream":"stderr","time":"2022-02-08T02:20:56.351189051Z"}
{"log":"    self.run()\n","stream":"stderr","time":"2022-02-08T02:20:56.352852517Z"}
{"log":"  File \"/usr/local/lib/python3.9/threading.py\", line 910, in run\n","stream":"stderr","time":"2022-02-08T02:20:56.352999854Z"}
{"log":"    self._target(*self._args, **self._kwargs)\n","stream":"stderr","time":"2022-02-08T02:20:56.353485095Z"}
{"log":"  File \"/src/gateio_new_coins_announcements_bot/main.py\", line 79, in buy\n","stream":"stderr","time":"2022-02-08T02:20:56.353712756Z"}
{"log":"    obj = get_last_price(announcement_coin, globals.pairing, False)\n","stream":"stderr","time":"2022-02-08T02:20:56.353996537Z"}
{"log":"  File \"/src/gateio_new_coins_announcements_bot/trade_client.py\", line 23, in get_last_price\n","stream":"stderr","time":"2022-02-08T02:20:56.354121108Z"}
{"log":"    assert len(trades) == 1\n","stream":"stderr","time":"2022-02-08T02:20:56.354310747Z"}
{"log":"AssertionError\n","stream":"stderr","time":"2022-02-08T02:20:56.354449017Z"}

I would suggest having an if check and a good log message instead of an assert here, so that people don't have to look into code like I did. :)