edeng23 / binance-trade-bot

Automated cryptocurrency trading bot
GNU General Public License v3.0
7.87k stars 2.19k forks source link

Notifications are not working #308

Closed SH-Stark closed 3 years ago

SH-Stark commented 3 years ago

Hello, when starting the bot I get some errors then the bot works normally.

The notifications system doesn't work tho, I don't receive a buy or sell notification. My apprise.yml is configured correctly, and with the BTB-manager I can interact with "Begin" or "/start".

Here is the log I get when running the bot:

➜  binance-trade-bot git:(master) ✗ sudo python3 -m binance_trade_bot

2021-04-28 09:19:24,614 - crypto_trading_logger - INFO - Starting
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 261, in _add_reader
    key = self._selector.get_key(fd)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/selectors.py", line 193, in get_key
    raise KeyError("{!r} is not registered".format(fileobj)) from None
KeyError: '8 is not registered'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/xxx/binance-trade-bot/binance_trade_bot/notifications.py", line 33, in process_queue
    self.apobj.notify(body=message)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/apprise/Apprise.py", line 500, in notify
    if not py3compat.asyncio.notify(coroutines, debug=self.debug):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/apprise/py3compat/asyncio.py", line 68, in notify
    asyncio.run(main(results, coroutines), debug=debug)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 39, in run
    loop = events.new_event_loop()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/events.py", line 761, in new_event_loop
    return get_event_loop_policy().new_event_loop()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/events.py", line 659, in new_event_loop
    return self._loop_factory()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/unix_events.py", line 54, in __init__
    super().__init__(selector)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 61, in __init__
    self._make_self_pipe()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 112, in _make_self_pipe
    self._add_reader(self._ssock.fileno(), self._read_from_self)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/selector_events.py", line 263, in _add_reader
    self._selector.register(fd, selectors.EVENT_READ,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/selectors.py", line 523, in register
    self._selector.control([kev], 0, 0)
TypeError: changelist must be an iterable of select.kevent objects
Exception ignored in: <function BaseEventLoop.__del__ at 0x7fee412c80d0>
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 683, in __del__
    self.close()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/unix_events.py", line 60, in close
    for sig in list(self._signal_handlers):
AttributeError: '_UnixSelectorEventLoop' object has no attribute '_signal_handlers'
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py:956: RuntimeWarning: coroutine 'notify.<locals>.main' was never awaited
  self._invoke_excepthook(self)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py:956: RuntimeWarning: coroutine 'AsyncNotifyBase.async_notify' was never awaited
  self._invoke_excepthook(self)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
2021-04-28 09:19:25,059 - crypto_trading_logger - INFO - Chosen strategy: default
2021-04-28 09:19:25,060 - crypto_trading_logger - INFO - Creating database schema if it doesn't already exist

Any idea? thanks

SH-Stark commented 3 years ago

My apprise.yml under the config file in case :)

rel-s commented 3 years ago

Not sure, but this doesn't seem to be a bug with the bot (as it's working for everyone) but rather with your own setup. Please consult our Discord channel for issues of this sort. Thanks!

sgoult commented 3 years ago

Just to answer, I was having this issue as well. The short answer is that python 3.9 appears to make some changes to asyncio which impact systems including Mac and some distros of linux. I recommend downgrading your python to 3.8 to get rid of the error. This problem will also impact the asyncio function calls made by unicorn-binance-websocket-api in https://github.com/edeng23/binance-trade-bot/pull/328