Skip to main content

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.

Table of Contents


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

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

FieldTypeRequiredDescription
acc_noStringNoIB 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:

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. 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

2. Error Prevention

  • Double-check account numbers in alert requests
  • Use consistent formatting (exact match with TWS)
  • Test alerts before deploying to production

Troubleshooting

Order Not Placed in Correct Account

Problem: Order goes to wrong account or fails

Solutions:

  • Verify the acc_no field exactly matches the account number in TWS
  • 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

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_no field in alert requests

Remember: Only use acc_no when you have multiple accounts. For single-account setups, XeroLite automatically uses your default account.


Limitations

One Alert Per Account

XeroLite is designed to handle one account per alert. Each alert can only route an order to a single account specified by the acc_no field.

Not supported:

  • ❌ Order replication across multiple accounts
  • ❌ Quantity allocation across multiple accounts
  • ❌ Routing one signal to multiple accounts (omnibus application)

Workaround: To trade the same signal across multiple accounts, create multiple identical alerts in TradingView, each with a different acc_no. When the signal triggers, each alert will fire separately and route to its respective account.


Version Compatibility

  • v1.1.0+: Full multi-account support with acc_no field
  • 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

Need more help? Contact support at [email protected]

See also: