Guidance for users who run TWS every day.

Connection hygiene

  • Enable API in TWS: File -> Global Configuration -> API -> Settings.
  • Use the correct port: 4002 (IB Gateway paper), 7497 (TWS paper), 4001 (IB Gateway live), 7496 (TWS live).
  • Read-only mode is recommended for testing.

Market data entitlements

  • Missing quotes often mean no entitlement or snapshot access.
  • Backtests fall back to sample data when TWS data is unavailable.

Sessions and time filters

  • Time filters use market time in 24-hour format.
  • Verify system clock and TWS session settings if results look off.

Pacing and throttling

  • Historical requests can be throttled by TWS.
  • If you hit pacing limits, retry after a short pause.

Common errors

  • Could not connect to TWS: not running, wrong port, or API disabled.
  • Connection timeout: API enabled but blocked by firewall or settings.

Paper vs live

  • Double-check account and port before deploying live.
  • Keep client IDs consistent to avoid session conflicts.