whittlem / pycryptobot

Python Crypto Bot (PyCryptoBot)
Apache License 2.0
1.96k stars 736 forks source link

BadRequest error when using the /stats command #763

Closed alangrima closed 1 year ago

alangrima commented 1 year ago

Following a market scan, using the /stats command generates a BadRequest error:

argument of type 'BadRequest' is not iterable 2023-01-26 12:43:23,604 - telegram.helper - ERROR - Exception while handling an update: Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/telegram/ext/dispatcher.py", line 555, in process_update handler.handle_update(update, self, check, context) File "/usr/local/lib/python3.9/dist-packages/telegram/ext/conversationhandler.py", line 626, in handle_update new_state = handler.handle_update(update, dispatcher, check_result, context) File "/usr/local/lib/python3.9/dist-packages/telegram/ext/handler.py", line 198, in handle_update return self.callback(update, context) File "/home/ubuntu/pycryptobot_7.31/pycryptobot/telegram_bot.py", line 388, in stats_pair_received self.helper.send_telegram_message(update, output, context=context) File "/home/ubuntu/pycryptobot_7.31/pycryptobot/models/telegram/helper.py", line 173, in send_telegram_message context.bot.send_message( File "/usr/local/lib/python3.9/dist-packages/telegram/bot.py", line 130, in decorator result = func(*args, **kwargs) File "/usr/local/lib/python3.9/dist-packages/telegram/bot.py", line 513, in send_message return self._message( # type: ignore[return-value] File "/usr/local/lib/python3.9/dist-packages/telegram/ext/extbot.py", line 199, in _message result = super()._message( File "/usr/local/lib/python3.9/dist-packages/telegram/bot.py", line 332, in _message result = self._post(endpoint, data, timeout=timeout, api_kwargs=api_kwargs) File "/usr/local/lib/python3.9/dist-packages/telegram/bot.py", line 295, in _post return self.request.post( File "/usr/local/lib/python3.9/dist-packages/telegram/utils/request.py", line 356, in post result = self._request_wrapper( File "/usr/local/lib/python3.9/dist-packages/telegram/utils/request.py", line 279, in _request_wrapper raise BadRequest(message)

whittlem commented 1 year ago

I may have fixed this already. Can you tell me the exact command and config you are using?

alangrima commented 1 year ago

Just updated but still getting the same error This happens when running the /stats command for a pair on binance selected by the scanner. It also seems that the data.json does not contain any details.

Here is the config:

{ "binance": { "api_url": "https://api.binance.com", "config": { "autorestart": 1, "base_currency": "ETH", "disablebuynearhigh": 1, "enableinsufficientfundslogging": 1, "enabletelegrambotcontrol": 1, "granularity": "15m", "live": 0, "nobuynearhighpcnt": 1, "nosellmaxpcnt": 3, "nosellminpcnt": -9, "quote_currency": "EUR", "sellatresistance": 1, "selllowerpcnt": -12, "telegram": 1, "trailingbuypcnt": 1, "trailingstoploss": -1, "trailingstoplosstrigger": 3, "verbose": 0, "websocket": 0, "enable_pandas_ta": 1, "autorestart": 1, "graphs": 0, "verbose": 1, "stats": 0, "enableinsufficientfundslogging": 1, "enabletelegrambotcontrol": 1, "disablelog": 0, "buymaxsize": 20, "buylastsellsize": 0, "buyminsize": 0, "sellsmartswitch": 0, "granularity": 300 }, "api_key_file": "binance.key" }, "coinbasepro": { "api_url": "https://api.exchange.coinbase.com", "config": { "autorestart": 1, "base_currency": "SHIB", "disablebuynearhigh": 1, "enableinsufficientfundslogging": 1, "enabletelegrambotcontrol": 1, "granularity": "15m", "live": 0, "nobuynearhighpcnt": 1, "nosellmaxpcnt": 3, "nosellminpcnt": -9, "quote_currency": "EUR", "sellatresistance": 1, "selllowerpcnt": -12, "telegram": 1, "trailingbuypcnt": 1, "trailingstoploss": -1, "trailingstoplosstrigger": 3, "verbose": 0, "websocket": 0 }, "api_key_file": "coinbasepro.key" }, "telegram" : { "token" : "token", "client_id" : "clientid", "user_id" : "userid" }, "scanner": { "atr72_pcnt": 1.0, "use_default_scanner": 1, "enableexitaftersell": 1, "enableleverage": 0, "maxbotcount": 5, "autoscandelay": 6, "enable_buy_next": 1 } }

whittlem commented 1 year ago

Ok, so you mean via the Telegram bot? You run /stats and you get an error?

whittlem commented 1 year ago

I have been able to re-create the issue but it's a bit of a strange case.

whittlem commented 1 year ago

It's fixed in v7.0.34