Connecting Xerolite to Interactive Brokers

This guide will help you set up the connection between Xerolite and Interactive Brokers (IB) using either Trader Workstation (TWS) or IB Gateway. Both options are supported, but IB Gateway is recommended for automated trading as it’s more lightweight and stable.

Prerequisites

  • Interactive Brokers account (Paper Trading or Live)
  • Either TWS (Trader Workstation) or IB Gateway installed on your machine
  • Xerolite installed and running
  • Both IB Gateway/TWS and Xerolite running on the same machine

Download Required Software

  • TWS (Trader Workstation): Download TWS – Full trading platform with charts and tools
  • IB Gateway: Download IB Gateway – Lightweight API-only connection
  • Note: Both applications require an Interactive Brokers account. Open an account if you don’t have one.

TWS vs IB Gateway

  • TWS: Full trading platform with charts and tools. Use if you need visual interface.
  • IB Gateway: Lightweight API-only connection. Recommended for automated trading.

Step 1: Choose Your Connection Method

  • Option A – TWS: Launch TWS and log in with your IB credentials
  • Option B – IB Gateway: Launch IB Gateway and log in with your IB credentials
  • Ensure you’re using the correct account type (Paper Trading or Live)

Step 2: Configure API Settings

  1. In TWS/IB Gateway, go to Edit → Global Configuration from the top menu bar
  2. Navigate to API → Settings and configure:
    • ✓ Enable Enable ActiveX and Socket Clients
    • ✓ Set Socket port to 7497
    • ✓ Ensure Read-Only API is unchecked
TWS/IB Gateway API Settings Configuration
TWS/IB Gateway API Settings Configuration

Step 3: Configure API Precautions

  1. In the same Global Configuration window, go to API → Precautions
  2. Enable all “Bypass Order Precautions for API Orders” options to ensure smooth order execution
Which Bypass Options to Enable?
  • Basic Trading: Enable the main “Bypass Order Precautions for API Orders”
  • Full Automation: Enable all options for complete automated trading functionality
TWS/IB Gateway API Precautions Configuration
TWS/IB Gateway API Precautions Configuration

Step 4: Connect Xerolite to IB

Connection Status
  • Once TWS/IB Gateway is properly configured and running, Xerolite will automatically connect
  • The Broker Health indicator will display in green when connected successfully
  • No manual connection is needed after the initial setup

Troubleshooting

Common Issues and Solutions
  • Connection Failed: Verify TWS/IB Gateway is running and correct port is not blocked by firewall
  • API Settings Not Saving: Restart TWS/IB Gateway after changing API settings
  • Orders Not Executing: Check API Precautions settings
  • Data Not Updating: Ensure you’re logged into the correct IB account
  • Wrong Port: Verify you’re using port 7497 for both live and paper

Need Help?

If you encounter any issues or need assistance, please contact our support team at support@xeroflex.com