I start the TWS and my "API" handler in separate threads but from the same parent. If the API handler detects a disconnect, or if it fails to receive updates on particular exchanges (i.e. futures, equities or fx) or if there are other internal failures (db or trading strategy) then I set an error status and the parent thread shutsdown and restarts the processes (TWS, API...).
This way I don't worry about whether the API detected a problem that wasn't handled properly by TWS and since TWS maintains separate connections for futures and equities it can be partially up but won't disconnect the client.
I've always found that the logic for clean startup connections is easier to handle then more complicated re-connect strategies.
Barnet Wagman <bw@...> wrote:
I neglected to mention that I always call ibSocket.eDisconnect() before
trying to reconnnect. So the sequence I've been using after getting a
ibSocket.eDisconnect() is actually
Thread.sleep(1000L) ...
ibSocket.eDisconnect()
ibSocket = new EClientSocket(...);
ibSocket.eConnect(...);
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "TWSAPI" on the web.
To unsubscribe from this group, send an email to:
TWSAPI-unsubscribe@...
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.