Skip to content

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

Open
@coy123

Description

trades = spot_api.list_trades(currency_pair=f"{base}_{quote}", limit=1)
assert len(trades) == 1

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. :)

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions