6. Connect Xerolite to IB TWS
Once TWS/IB Gateway is configured for API access, you can connect XeroLite to Interactive Brokers. This section guides you through establishing the connection.
Prerequisites
- TWS or IB Gateway configured for API access (see Configure IB TWS for API Access)
- XeroLite installed and running (see Install Xerolite)
- XeroLite license activated (see Activate Xerolite License)
6.1: Ensure TWS Is Running
- Launch TWS or IB Gateway:
- Open Trader Workstation or IB Gateway
- Log in with your Interactive Brokers credentials
- Ensure you're connected to IB servers (check connection status)
- Verify API Settings:
- Confirm API access is enabled (port 7497)
- Ensure TWS/IB Gateway is not in read-only mode
- Keep TWS Running:
- TWS/IB Gateway must remain running while XeroLite is active
- Do not close TWS/IB Gateway during trading operations
6.2: Open Broker Connection Settings
- Log in to XeroLite:
- Open your web browser
- Navigate to
http://localhostor your server's IP address - Log in with your XeroLite credentials
- Navigate to Connection Settings:
- Look for Broker Connection, Connections, or Settings in the menu
- This is typically found in the main navigation or settings section
- Select Broker Configuration:
- Click on the broker connection settings
- You should see options for configuring broker connections
6.3: Select Interactive Brokers
- Choose Broker:
- Select Interactive Brokers from the list of available brokers
- If you see multiple broker options, ensure Interactive Brokers is selected
- Verify Broker Selection:
- Confirm that Interactive Brokers is highlighted or selected
- The interface should show IB-specific configuration options
6.4: Set Connection Mode
- Connection Type:
- XeroLite typically auto-detects TWS/IB Gateway
- Ensure the connection mode is set to use the local TWS/IB Gateway instance
- Port Configuration:
- Verify the port matches your TWS API settings (default: 7497)
- For paper trading: typically port 7497
- For live trading: typically port 7496 or 7497
- Connection Parameters:
- Host should be set to
127.0.0.1orlocalhost - Client ID can usually be left at default (0) unless you have multiple connections
- Host should be set to
6.5: Connect to IB
- Initiate Connection:
- Click Connect, Save, or Apply button
- XeroLite will attempt to connect to TWS/IB Gateway
- Wait for Connection:
- The connection process may take a few seconds
- Watch for connection status indicators
- Verify Connection Status:
- Look for a green status indicator or "Connected" message
- The Broker Health indicator should display as connected
- Account information should appear if connection is successful
Connection Status Indicators
- Green/Connected: Successfully connected to IB
- Red/Disconnected: Connection failed or TWS is not running
- Yellow/Pending: Connection in progress
Automatic Connection
Once properly configured, XeroLite will automatically connect to TWS/IB Gateway when:
- Both XeroLite and TWS/IB Gateway are running
- API settings are correctly configured
- Connection parameters are saved
Troubleshooting
Connection Failed
- Verify TWS is Running: Ensure TWS/IB Gateway is launched and logged in
- Check Port: Confirm the port in XeroLite matches TWS API settings (7497)
- Firewall: Ensure port 7497 is not blocked by firewall
- Restart Both: Try restarting both TWS and XeroLite
API Settings Not Saving
- Restart TWS: Restart TWS/IB Gateway after changing API settings
- Check Permissions: Ensure you have write permissions for TWS configuration
- Verify Settings: Go back to API settings and confirm they persisted
Next Steps
After successfully connecting, proceed to:
- Verify IB Connection – Confirm the connection is working properly
- Test Order Execution – Test order execution in a safe environment
Need more help? Contact support at [email protected]
See also:
- Verify IB Connection for confirming the connection
- Test Order Execution for safe testing
- Troubleshooting Guide for connection issues