Configuration reference
TWS / IB Gateway API settings
| Setting | Effect |
|---|---|
| Enable socket clients | Opens the TWS API listener. |
| Socket port | Must match connect; changing it can emit 1300 and disconnect clients. |
| Read-only API | Server-side guard against API order actions. Prefer it for data-only services. |
| Trusted IPs | Allows remote hosts without an interactive approval prompt. Keep the list private and narrow. |
| Master API Client ID | Causes that client to receive order/execution activity from other API clients; it also affects order-ID sequencing obligations. |
| Bind TWS orders to client 0 | Enables manual-order takeover/visibility behavior. Optional negative IDs distinguish manual orders. Binding can cancel/resubmit at the exchange on some API/TWS versions and may lose queue priority. |
| Download open orders on connection | UI behavior; application code should still use an explicit, tested startup policy. |
| Expose entire trading schedule | Larger contract-details responses; disabling can speed large option-chain-like queries. |
| Create API message log | Writes protocol message logs, normally rotated across seven weekday files. Market-data logging is separately configurable and very verbose. |
| API precautionary settings | Can reject price/size outside configured bounds. overridePercentageConstraints bypasses only relevant checks and increases risk. |
IB class defaults
| Setting | Default | Meaning |
|---|---|---|
RequestTimeout | 0 | Blocking request timeout; zero means indefinite. Not applied to async methods. |
RaiseRequestErrors | False | Empty result plus event versus RequestError for certain request failures. |
MaxSyncedSubAccounts | 50 | Automatic subaccount-update threshold during connection sync. |
TimezoneTWS | "" | Empty assumes local system timezone. Set it when TWS and process time zones differ. |
IB(defaults=IBDefaults(...)) also accepts protocol-level default factories/values documented in the IBDefaults reference.
Client throttling
Client.MaxRequests defaults to 45 messages per RequestsInterval of 1 second, below IBKR's documented 50 messages/second ceiling. Set MaxRequests=0 to disable library throttling only if an external rate limiter is correct. Throttling covers outgoing protocol messages, not endpoint-specific historical/scanner restrictions.
throttleStart and throttleEnd events expose when the client queue enters/leaves throttling. A backlog increases latency; instrument it.
StartupFetch
The flag values are POSITIONS, ORDERS_OPEN, ORDERS_COMPLETE, ACCOUNT_UPDATES, SUB_ACCOUNT_UPDATES, and EXECUTIONS, with StartupFetchALL and StartupFetchNONE. In 2.1.0, positions are still requested unconditionally by connectAsync; the flag's POSITIONS member is not consulted in that implementation. Treat this as version-specific behavior.
from ib_async import StartupFetch
fetch = StartupFetch.ORDERS_OPEN | StartupFetch.EXECUTIONS
await ib.connectAsync(..., readonly=False, fetchFields=fetch)
IBC and Watchdog
IBC locates TWS, settings, IBC, Java, and config paths and builds the platform-specific launch command. Supplying userid/password puts secrets in process arguments; a secured IBC config is safer. twsVersion is the installed major version, gateway selects IB Gateway versus TWS, and tradingMode is live or paper.
The full field tables and defaults are in ibcontroller.