check_connection
Check if TWS or IB Gateway is reachable and an account is logged in. Identifies the cause of connection failures and provides hints to fix them.
Instructions
Check whether TWS or IB Gateway is reachable and an account is logged in.
Call this first whenever another tool fails. It separates the four situations that all present as "cannot connect" and need different fixes:
not_listening— nothing is on the port. TWS is not running, or IBKR_PORT points at the wrong one; the response lists which of the four default ports (7496 TWS live, 7497 TWS paper, 4001/4002 Gateway) are answering.api_not_enabled— the port answers but the API handshake never completes. "Enable ActiveX and Socket Clients" is off in TWS.client_id_in_use— another script holds this client id.not_logged_in— the API is up but no account is loaded.connected— everything is in place.
hint says what to do about the state in each case.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||