Multi-Account Support
XeroLite supports trading with multiple Interactive Brokers (IB) accounts linked to the same TWS (Trader Workstation) login. This feature allows you to specify which account should receive each order when you have multiple accounts configured.
Overview
When you have multiple IB accounts linked to the same TWS login, XeroLite can route orders to specific accounts using the acc_no (account number) field in alert requests.
When to Use Multi-Account Support
Use the acc_no field when:
- ✅ You have multiple IB accounts linked to the same TWS login
- ✅ You want to specify which account should receive a particular order
- ✅ You're managing different strategies across different accounts
- ✅ You need to separate trading activities by account
When NOT to Use
You do NOT need to use acc_no when:
- ❌ You have only one IB account linked to your TWS login
- ❌ All your orders should go to the default account
- ❌ The account number is automatically detected correctly
Finding Your Account Number
Method 1: From TWS
- Open TWS (Trader Workstation)
- Log in to your account
- Look at the top menu bar or account information panel
- Find your account number (typically displayed as "Account: XXXXXXXX" or similar)
- Copy the account number exactly as displayed
Method 2: From XeroLite Transactions Tab
- Log in to XeroLite
- Go to the Transactions tab
- Look at the "Account" column in any transaction
- The account number is displayed for each order
- Note the exact format (may include letters, numbers, or special characters)
Method 3: From Broker Health
- Log in to XeroLite
- Look at the Broker Health section in the left sidebar
- Account information may be displayed for connected brokers
- Note the account number format
Using the acc_no Field
In Alert Requests
Add the acc_no field to your alert request JSON:
{
"name": "MyStrategy",
"symbol": "AAPL",
"currency": "USD",
"asset_class": "STOCK",
"action": "BUY",
"qty": 100,
"order_type": "LIMIT",
"price": 150.50,
"acc_no": "DU123456"
}
Field Details
| Field | Type | Required | Description |
|---|---|---|---|
| acc_no | String | No | IB account number. Required only if multiple accounts are linked to the same TWS login. If a single account is used, this field is optional and will be ignored if provided. |
Format Requirements
- Exact Match: The account number must exactly match the account number in TWS
- Case Sensitive: Account numbers may be case-sensitive (use exact case)
- Special Characters: Include any special characters (hyphens, underscores) exactly as shown in TWS
- No Spaces: Do not include spaces unless they are part of the account number in TWS
Examples
Example 1: Single Account (No acc_no Needed)
If you have only one account, you can omit acc_no:
{
"name": "Strategy1",
"symbol": "TSLA",
"currency": "USD",
"asset_class": "STOCK",
"action": "BUY",
"qty": 50,
"order_type": "MARKET"
}
XeroLite will automatically use your default account.
Example 2: Multiple Accounts (With acc_no)
If you have multiple accounts, specify the account:
{
"name": "Strategy1",
"symbol": "TSLA",
"currency": "USD",
"asset_class": "STOCK",
"action": "BUY",
"qty": 50,
"order_type": "LIMIT",
"price": 250.00,
"acc_no": "DU123456"
}
This order will be placed in account "DU123456".
Example 3: Different Strategies, Different Accounts
Route different strategies to different accounts:
Strategy A → Account 1:
{
"name": "DayTrading",
"symbol": "SPY",
"currency": "USD",
"asset_class": "STOCK",
"action": "BUY",
"qty": 100,
"order_type": "MARKET",
"acc_no": "DU123456"
}
Strategy B → Account 2:
{
"name": "SwingTrading",
"symbol": "QQQ",
"currency": "USD",
"asset_class": "STOCK",
"action": "BUY",
"qty": 50,
"order_type": "LIMIT",
"price": 380.00,
"acc_no": "DU789012"
}
Using Account Numbers in TradingView Alerts
Manual Alerts
When creating manual TradingView alerts, include acc_no in the webhook message:
{{ticker}}|{{close}}|{{strategy.order.action}}|{{strategy.order.contracts}}|LIMIT|{{close}}|MyStrategy|DU123456
Or in JSON format:
{
"name": "{{strategy.order.comment}}",
"symbol": "{{ticker}}",
"currency": "USD",
"asset_class": "STOCK",
"action": "{{strategy.order.action}}",
"qty": "{{strategy.order.contracts}}",
"order_type": "LIMIT",
"price": "{{close}}",
"acc_no": "DU123456"
}
Pine Script Alerts
In your Pine Script strategy, include acc_no in the alert message:
// Example Pine Script alert with account number
if condition
alert('{"name":"MyStrategy","symbol":"' + syminfo.ticker + '","currency":"USD","asset_class":"STOCK","action":"BUY","qty":100,"order_type":"LIMIT","price":' + close + ',"acc_no":"DU123456"}', alert.freq_once_per_bar)
Best Practices
1. Consistent Account Usage
- Use the same account for related strategies when possible
- Document which strategies use which accounts
- Keep account numbers in a secure location for reference
2. Account Number Validation
- Verify account numbers before placing orders
- Test with small orders first when using a new account number
- Check Transactions tab to confirm orders are routed to the correct account
3. Error Prevention
- Double-check account numbers in alert requests
- Use consistent formatting (exact match with TWS)
- Test alerts before deploying to production
4. Security
- Keep account numbers private (they're sensitive information)
- Don't hardcode account numbers in public scripts
- Use environment variables or secure storage for account numbers
Troubleshooting
Order Not Placed in Correct Account
Problem: Order goes to wrong account or fails
Solutions:
- Verify the
acc_nofield exactly matches the account number in TWS - Check that the account number includes all required characters
- Ensure the account is properly linked to your TWS login
- Verify account number format (no extra spaces, correct case)
Account Number Not Recognized
Problem: Error message about invalid account number
Solutions:
- Double-check the account number in TWS
- Ensure the account is active and accessible
- Verify the account is linked to the TWS instance XeroLite is connected to
- Check for typos or formatting differences
Multiple Accounts Not Working
Problem: acc_no field is ignored or doesn't work
Solutions:
- Verify you actually have multiple accounts linked (check TWS)
- Ensure XeroLite is connected to the correct TWS instance
- Check that the account number format matches exactly
- Review the Transactions tab to see which account received the order
Finding Account Number
Problem: Can't find your account number
Solutions:
- Check TWS account information panel
- Look at the Transactions tab in XeroLite (Account column)
- Review Broker Health section for account information
- Contact IB support if account number is unclear
Version Compatibility
- v1.1.0+: Full multi-account support with
acc_nofield - v1.1.1: Bug fix for account number handling during order placement
- v1.0.0 Beta: Initial support for account numbers
- v0.3.x: Account number support not available
Related Documentation
- Alert Request Format v1.2.x - Complete field reference including
acc_no - Alert Request Format v1.1.x - Field reference for v1.1.x
- Alert Request Format v1.0.x - Field reference for v1.0.x
- Transactions - View which account received each order
- Connect XeroLite to IB - Setting up TWS connection
Summary
Multi-account support allows you to:
- ✅ Route orders to specific IB accounts
- ✅ Manage multiple strategies across different accounts
- ✅ Separate trading activities by account
- ✅ Use the
acc_nofield in alert requests
Remember: Only use acc_no when you have multiple accounts. For single-account setups, XeroLite automatically uses your default account.