erdewit / ib_insync

Python sync/async framework for Interactive Brokers API
BSD 2-Clause "Simplified" License
2.8k stars 743 forks source link

ib_insync throws "RuntimeError: There is no current event loop in thread" #167

Closed fvalenti1 closed 5 years ago

fvalenti1 commented 5 years ago

I'm trying to create an IB object in a non main thread and it is throwing "RuntimeError: There is no current event loop in thread 'Thread-X'"

import threading
from ib_insync import IB
class Strategy (threading.Thread):

    def run(self):
        ib = IB()
        ib.connect('127.0.0.1', 7495, clientId=15)
        ...
erdewit commented 5 years ago

See #33.

fvalenti1 commented 5 years ago

Problem fixed!! Thanks a lot for your very quick answer