I've been trying out scripts to get a feel of using the API, and in the process of changing the client ID I now have several connections through port 7497. How can I disconnect from them? Either one at a time or all at once? Here is what I've tried without success: from ibapi.client import EClient from ibapi.wrapper import EWrapper class IBapi(EWrapper, EClient): def __init__(self): EWrapper.__init__(self) EClient.__init__(self,self) app = IBapi() #app.connect('127.0.0.1', 7497, 103) app.disconnect() app.run() I would've thought I could put the client_id into app.disconnect() but it throws an error. I've enabled/disabled the "ActiveX and Sockets" setting in TWS but it seems like a crude method to use. Do you usually put app.disconnect() at the end of every function?
TWS/Gateway monitors activity on the API connections. If a connection is not active for a certain amount of time will it be discarded. But I don't know how long it takes for this to happen.
Is there a simple script to run to disconnect? It comes with a connection script, but replacing connect() with disconnect() doesn't seem to be the solution.
Yes there is. But I don't program with Python and don't know the correct name for this disconnect command.