Alpaca-backtrader-api gives threading error on running sample code

Thanks for providing support for backtrader in Alpaca! I am trying to use the alpaca-backtrader-api but running into issues-

I am trying to run the example (in live) as mentioned in the blog post - https://medium.com/automation-generation/introducing-alpaca-backtrader-integration-898d8cabffdc

But I am getting this error:

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/harshupreti/Desktop/Trades/builds/alpaca-backtrader-api/alpaca_backtrader_api/alpacastore.py", line 310, in _t_streaming_events
    base_url=self.p.base_url)
  File "/Users/harshupreti/Desktop/Trades/builds/alpaca-backtrader-api/alpaca_backtrader_api/alpacastore.py", line 91, in __init__
    self.conn = tradeapi.StreamConn(api_key, api_secret, base_url)
  File "/Users/harshupreti/Desktop/Trades/Alpaca/nightwatch/venv/lib/python3.7/site-packages/alpaca_trade_api/stream2.py", line 27, in __init__
    self.loop = asyncio.get_event_loop()
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/events.py", line 644, in get_event_loop
    % threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'Thread-2'.

Exception in thread Thread-6:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/harshupreti/Desktop/Trades/builds/alpaca-backtrader-api/alpaca_backtrader_api/alpacastore.py", line 417, in _t_streaming_prices
    base_url=self.p.base_url)
  File "/Users/harshupreti/Desktop/Trades/builds/alpaca-backtrader-api/alpaca_backtrader_api/alpacastore.py", line 91, in __init__
    self.conn = tradeapi.StreamConn(api_key, api_secret, base_url)
  File "/Users/harshupreti/Desktop/Trades/Alpaca/nightwatch/venv/lib/python3.7/site-packages/alpaca_trade_api/stream2.py", line 27, in __init__
    self.loop = asyncio.get_event_loop()
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/events.py", line 644, in get_event_loop
    % threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'Thread-6'.

I have set the key, secret, url correctly.
I have installed alpaca-backtrader-api version 0.3 (which is the latest) and alpaca-trade-api 0.42 and running python 3.7 all in a venv.

I also tried installing alpaca-backtrader-api from source and still this error remains.

Does anyone knows how can I get this to work?

The error seems to point to this line in stream2.py:

IF you want to go comment out line 27 and replace it with(or add the lines):

self.loop = asyncio.new_event_loop()
asyncio.set_event_loop(self.loop)

It will run.

Here is a great description of the problem:

Thanks for providing the excellent solution!, I have made this change to the stream3.py file and it worked.
I am wondering if this is a bug in alpaca_trade_api which needs to be fixed. Without this change everyone who uses Backtrader with Alpaca will have to download the source, change and build locally.