What if you could tell your AI assistant "buy 10 shares of AAPL" and it actually executed the trade on Interactive Brokers?
That's exactly what the Xerolite skill for OpenClaw does. Launched in March 2026, it bridges the gap between conversational AI and real brokerage execution — no Python scripts, no manual order entry, no API documentation to wade through.
I've been running an automated trading system on Interactive Brokers for over a year (a USDJPY momentum strategy that executes through IB Gateway). Setting that up required weeks of Python development, debugging TWS API quirks, and building a custom daemon. Xerolite compresses that entire setup into something you can configure in under an hour.
Here's exactly how to set it up.
What You Need Before Starting
Before touching Xerolite or OpenClaw, make sure you have:
- An Interactive Brokers account with live trading permissions (open one here if you don't have one — you'll get up to $1,000 in IBKR stock)
- A Linux server or always-on machine (VPS, Raspberry Pi, or home server — OpenClaw needs to run 24/7)
- IB Gateway or TWS installed on the same machine (or accessible via network)
- Market data subscriptions for the instruments you want to trade (see our IB market data guide for which ones you actually need)
Architecture: How the Pieces Fit Together
Here's how data flows when you say "buy 10 shares of TSLA":
You (natural language)
→ OpenClaw (understands intent, extracts parameters)
→ Xerolite Skill (formats order, calls REST API)
→ Xerolite Server (validates, routes to broker)
→ IB Gateway / TWS (executes on exchange)
→ Interactive Brokers (fills order)
Each layer handles one job:
- OpenClaw parses your natural language into structured trading commands
- Xerolite translates those commands into IB-compatible API calls
- IB Gateway maintains the authenticated session with Interactive Brokers
Step 1: Install and Configure IB Gateway
IB Gateway is the headless version of TWS (Trader Workstation). It uses less memory and doesn't need a GUI, making it ideal for server deployments.
Download IB Gateway
Go to Interactive Brokers' download page and grab the latest stable release for your OS.
For Linux:
# Download the installer
chmod +x ibgateway-stable-standalone-linux-x64.sh
./ibgateway-stable-standalone-linux-x64.sh
# Default install location: ~/Jts/ibgateway/
Configure API Access
Launch IB Gateway and log in with your IB credentials. Then:
1. Go to Configure → Settings → API → Settings
2. Check "Enable ActiveX and Socket Clients" 3. Set the Socket port to4001 (live) or 4002 (paper trading)
4. Check "Allow connections from localhost only" (critical for security)
5. Uncheck "Read-Only API" — Xerolite needs write access to place orders
Set Up 2FA (IB Key)
IB Gateway requires two-factor authentication on every login. This is the single biggest pain point for automated trading setups.
Options:
- IB Key on mobile: Approve login via the IBKR Mobile app (manual step each restart)
- IBKR Mobile auto-confirm: Enable "Auto-Confirm" in IBKR Mobile settings for seamless restarts
Run IB Gateway as a Service (Linux)
For production use, run IB Gateway as a systemd service so it survives reboots:
# /etc/systemd/system/ibgateway.service
[Unit]
Description=IB Gateway
After=network.target
[Service]
Type=simple
User=your_username
ExecStart=/home/your_username/Jts/ibgateway/ibgateway
Restart=on-failure
RestartSec=30
[Install]
WantedBy=multi-user.target
sudo systemctl enable ibgateway
sudo systemctl start ibgateway
Step 2: Install Xerolite
Xerolite runs as a middleware server between OpenClaw and IB Gateway.
Install via Docker (Recommended)
docker pull xeroflex/xerolite:latest
docker run -d \
--name xerolite \
--network host \
-e IB_GATEWAY_HOST=127.0.0.1 \
-e IB_GATEWAY_PORT=4001 \
-e XEROLITE_API_KEY=your_secure_api_key_here \
xeroflex/xerolite:latest
Install from Source
git clone https://github.com/xeroflex/xerolite.git
cd xerolite
pip install -r requirements.txt
# Configure
cp config.example.yaml config.yaml
# Edit config.yaml with your IB Gateway host/port
Verify the Connection
curl http://localhost:8080/health
# Should return: {"status": "connected", "broker": "interactive_brokers"}
curl http://localhost:8080/api/search?symbol=AAPL \
-H "Authorization: Bearer your_secure_api_key_here"
# Should return AAPL contract details
If you get a connection error, check that IB Gateway is running and the port matches.
Step 3: Install the Xerolite Skill in OpenClaw
OpenClaw uses "skills" — modular plugins that give your AI new capabilities. The Xerolite skill teaches it how to place trades.
Install the Skill
openclaw skill install xerolite
Configure the Skill
Edit your OpenClaw configuration to point at your Xerolite server:
{
"skills": {
"xerolite": {
"api_url": "http://localhost:8080",
"api_key": "your_secure_api_key_here",
"default_currency": "USD",
"default_exchange": "SMART",
"default_sec_type": "STK"
}
}
}
Test It
Open a chat with your OpenClaw instance and try:
You: Search for AAPL
OpenClaw: Found AAPL — Apple Inc., STOCK, USD, SMART exchange.
Contract ID: 265598
You: What about TSLA?
OpenClaw: Found TSLA — Tesla Inc., STOCK, USD, SMART exchange.
Contract ID: 76792991
If search works, your pipeline is connected end-to-end.
Like what you're reading? Try it yourself — this link supports ChartedTrader at no cost to you.
Open an Interactive Brokers Account →Step 4: Place Your First Trade
Start with a small test order on your paper trading account (port 4002) before going live.
You: Buy 1 share of SPY
OpenClaw: ✅ Order placed — 1 share of SPY (STOCK/USD) at market price via SMART exchange.
Order ID: 42
Conversational Context
Because OpenClaw maintains conversation history, you can build on previous queries:
You: Search for NVDA
OpenClaw: Found NVDA — NVIDIA Corporation, STOCK, USD, SMART exchange.
You: Buy 5 shares
OpenClaw: ✅ Order placed — 5 shares of NVDA at market price.
What You Can Trade
Through Interactive Brokers, Xerolite supports:
- US Stocks (AAPL, TSLA, NVDA, SPY, QQQ, etc.)
- International Stocks (LSE, TSE, HKEX — change the exchange parameter)
- ETFs (SPY, QQQ, IWM, VTI, etc.)
- Options (requires contract specification)
- Futures (requires contract specification)
- Forex (configure sec_type to CASH)
Security: Protecting Your Brokerage Account
You're giving an AI assistant access to place real trades on a real brokerage account. Take security seriously.
1. Use a Sub-Account
Interactive Brokers lets you create sub-accounts with limited permissions. Create one specifically for AI trading:
- Set position limits (e.g., max $10,000 per trade)
- Restrict to specific instruments
- Disable margin/options if you only want stock trades
2. Lock Down Network Access
# IB Gateway: localhost only
# In IB Gateway → Configure → API → Settings:
# ✅ "Allow connections from localhost only"
# Xerolite: bind to localhost or use firewall
# In config.yaml:
# host: 127.0.0.1
# If running remotely, use SSH tunnel:
ssh -L 8080:localhost:8080 your_server
3. Use Strong API Keys
Generate a random API key for Xerolite:
openssl rand -hex 32
# Use this as XEROLITE_API_KEY
Never reuse passwords or use guessable keys.
4. Start with Paper Trading
Use IB Gateway port 4002 (paper trading) until you're confident the system works correctly. Paper trading uses simulated fills — no real money at risk.
5. Set Position Limits
In your IB account settings, configure:
- Maximum order size per instrument
- Daily P&L limit — auto-liquidate if losses exceed threshold
- Restricted instruments — only allow what you actually trade
Xerolite vs. Building Your Own IB Bot
Having built a production IB trading system from scratch (Python, ibapi, custom daemon, systemd services), I can compare honestly:
| Aspect | Custom Python Bot | Xerolite + OpenClaw |
|---|---|---|
| Setup time | 2-4 weeks | 1-2 hours |
| Programming required | Advanced Python | None |
| Customization | Unlimited | Limited to supported commands |
| Signal logic | Custom strategies | Manual decisions via chat |
| Monitoring | Custom dashboards | OpenClaw chat interface |
| Reliability | Depends on your code | Depends on Xerolite + IB Gateway |
| Best for | Systematic strategies | Discretionary traders |
But if you're a discretionary trader who wants to place trades without clicking through TWS, or you want a quick way to act on ideas without building infrastructure, Xerolite is genuinely useful.
Combining Xerolite with TradingView Alerts
The real power emerges when you connect TradingView alerts to OpenClaw:
1. TradingView fires a webhook when your Pine Script indicator triggers
2. OpenClaw receives the webhook and interprets the signal 3. Xerolite executes the trade on Interactive BrokersThis creates a no-code pipeline from chart analysis to execution. You write the Pine Script indicator, set the alert, and the rest happens automatically.
We covered the TradingView side in our Pine Script momentum indicator tutorial — the same logic applies here, but execution goes through Xerolite instead of custom Python.
Troubleshooting Common Issues
"Connection refused" from Xerolite
IB Gateway isn't running or the port doesn't match. Check:
# Is IB Gateway running?
ps aux | grep ibgateway
# Is the port correct?
netstat -tlnp | grep 4001
"Order rejected" errors
Common causes:
- Insufficient funds: Check your account balance in IB
- Market closed: US stocks trade 9:30 AM - 4:00 PM ET
- Missing market data: You need a subscription for the instrument you're trading
- Account restrictions: Paper trading accounts can't trade some instruments
IB Gateway disconnects randomly
IB Gateway drops connections after ~24 hours of inactivity. Solutions:
- Configure auto-restart in systemd (already shown above)
- Use IBC (IB Controller) for automatic re-authentication
- Set up monitoring that alerts you when the connection drops
What's Next
The Xerolite integration is version 1 — basic order placement and contract search. Here's what would make it genuinely powerful:
- Portfolio queries: "What's my current P&L?" / "Show my positions"
- Order types: Limit orders, stop-losses, bracket orders
- Position sizing: "Risk 1% of portfolio on TSLA"
- Scheduled orders: "Buy AAPL at market open tomorrow"
---
*Ready to try it? You'll need an Interactive Brokers account to connect — new accounts get up to $1,000 in IBKR stock through the referral program.*
> 💡 Did you know? Interactive Brokers pays $200 cash for each friend you refer, and your friend gets up to $1,000 in IBKR stock. Learn how the IBKR referral program works →
Frequently Asked Questions
Is Xerolite free to use?
Xerolite is open-source and self-hosted. You run it on your own server alongside IB Gateway. There are no subscription fees — your only costs are Interactive Brokers' standard commissions and market data subscriptions.
Can I use Xerolite with a paper trading account?
Yes. Point Xerolite at IB Gateway port 4002 instead of 4001. Paper trading uses simulated fills with real market data, so you can test the full pipeline without risking real money.
Does this work with IBKR Lite or only IBKR Pro?
Both work, but IBKR Pro gives better execution quality and access to more order types. For API trading, Pro is strongly recommended — the commission savings on Lite accounts come with wider spreads and slower fills.
What happens if my internet goes down during a trade?
Once an order reaches Interactive Brokers' servers, it executes regardless of your connection. If your connection drops before the order is sent, nothing happens — no partial state. IB Gateway handles the connection reliability; your local setup just needs to stay online long enough to submit the order.
Can I trade options or futures through Xerolite?
The current version supports stocks and ETFs with the default configuration. Options and futures require specifying additional contract parameters (expiry, strike, right). Check Xerolite's documentation for the extended order format — it's supported but requires more specific commands.