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)
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: Verify Broker Connection
- Log in to XeroLite:
- Open your web browser
- Navigate to your XeroLite Cloud Edition URL
- Log in with your XeroLite credentials
- 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
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)
- 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 Xerolite Order Execution – Test order execution in a safe environment