Exemple #1
0
 def connect(self, host, port, clientId, timeout=2):
     """
     Connect to TWS/IBG at given host and port and with a clientId
     that is not in use elsewhere.
     
     When timeout is not zero, asyncio.TimeoutError
     is raised if the connection is not established within the timeout period.
     """
     util.syncAwait(self.connectAsync(host, port, clientId, timeout))
Exemple #2
0
 def run(*awaitables: List[Awaitable]):
     """
     By default run the event loop forever.
     
     When awaitables (like Tasks, Futures or coroutines) are given then
     run the event loop until each has completed and return their results.
     """
     loop = asyncio.get_event_loop()
     if not awaitables:
         result = loop.run_forever()
     else:
         if len(awaitables) == 1:
             future = awaitables[0]
         else:
             future = asyncio.gather(*awaitables)
         result = util.syncAwait(future)
     return result
Exemple #3
0
 def terminate(self):
     """
     Terminate TWS/IBG.
     """
     util.syncAwait(self.terminateAsync())
Exemple #4
0
 def stop(self):
     """
     Cleanly shutdown TWS/IBG.
     """
     util.syncAwait(self.stopAsync())
Exemple #5
0
 def start(self):
     """
     Launch TWS/IBG.
     """
     util.syncAwait(self.startAsync())
Exemple #6
0
 def __init__(self, *args, **kwargs):
     Object.__init__(self, *args, **kwargs)
     self._proc = None
     self._logger = logging.getLogger('ib_insync.IBController')
     util.syncAwait(self.start())
     asyncio.ensure_future(self.monitor())