Skip to content

Core Concepts

Strategy Routing

All requests carry a strategy ID. The engine uses it to route to the correct account and tag every order, trade, and position for attribution.

  • Header: X-Strategy-Id: AQC-Pxxxxxx
  • Set at construction: TradingClient(strategy_id=...)
PrefixAccountMode
AQC-PPaper (simulated, IBKR paper gateway)paper
AQC-LLive (real capital, IBKR live gateway)live
AQC-FFund (separate real-capital IBKR account)fund

The engine infers the mode from the strategy ID prefix automatically. Strategy code does not need to specify a mode explicitly.

Fund and Live accounts

Both AQC-L and AQC-F strategies trade real capital. Fund strategies route to a separate IBKR account (port 5002) distinct from the live account (port 5001).

Contract IDs (conid)

Most market data and order endpoints accept a conid (IBKR contract identifier). Use these helpers:

python
conid = client.get_conid("AAPL")
spx_conid = client.get_index_conid("SPX")

Security Types

The sec_type parameter controls which IBKR instrument class to look up or trade.

ValueInstrument
STKStock / ETF (default when omitted)
INDIndex (SPX, NDX, VIX, etc.)
OPTOption
FUTFuture
CRYPTOCryptocurrency (BTC, ETH, etc.) — use exchange="PAXOS"
python
# Stocks default to STK — no sec_type needed
conid = client.get_conid("AAPL")

# Indices require sec_type="IND"
spx = client.get_conid("SPX", sec_type="IND")

# Futures
es = client.get_conid("ES", sec_type="FUT", exchange="CME")

# Crypto — explicit hints required
btc = client.get_conid("BTC", sec_type="CRYPTO", exchange="PAXOS")
eth = client.get_conid("ETH", sec_type="CRYPTO", exchange="PAXOS")

Non-US Exchanges

get_conid, qualify_contract, and all order placement methods accept exchange, primary_exchange, country, and currency parameters for routing to non-US markets.

python
# Canadian stock on TSX
conid = client.get_conid("RY", exchange="TSX", currency="CAD", country="CA")

# UK stock on LSE
conid = client.get_conid("VOD", exchange="LSE", currency="GBP", country="GB")

# German stock on XETRA
conid = client.get_conid("SAP", exchange="IBIS", currency="EUR", country="DE")

# Futures on CME
es = client.get_conid("ES", sec_type="FUT", exchange="CME")

Pass the same parameters to place_order or buy_market/sell_market to ensure routing to the correct exchange:

python
result = client.buy_market(
    "RY",
    quantity=100,
    exchange="TSX",
    currency="CAD",
    country="CA",
)

primary_exchange

primary_exchange pins the listing exchange when SMART routing is active (e.g., primary_exchange="NYSE" for a US stock). Use exchange to override the routing destination entirely for non-US markets.

Time Formats

  • Historical bars (get_history): period="1d", bar_size="1min"
  • Historical bars (get_historical_bars): duration="1 D", bar_size="30 mins"
  • Tick history: YYYYMMDD-HH:MM:SS
  • Calendar/trading days: YYYY-MM-DD

Order Confirmations

Some IBKR orders return a confirmation prompt. Use force=True on order requests to auto-confirm warnings.

Data Availability

Some data depends on IBKR subscriptions:

  • Options OI/volume
  • Level 2 depth
  • Certain greeks/market data fields

When unavailable, the SDK returns empty datasets with a note.

Engine Status

python
status = client.get_status()
connection = client.get_connection_status()

Use get_connection_status() when strategy code needs a simple readiness check for the current account mode.