Skip to content

Orders

Basic order methods return OrderResult. Bracket, spread, and iron condor methods return Dict.

python
OrderResult(
    success=True,
    order_id=738082887,
    message=None,
    raw={'result': [...], 'status': 'success'}
)

Market Orders

python
result = client.buy_market("SPY", 10)
result = client.sell_market("SPY", 10)

Optional parameters: conid, tif, exchange, country, currency, primary_exchange, sec_type.

Limit Orders

python
result = client.buy_limit("SPY", 10, price=690.50)
result = client.sell_limit("SPY", 10, price=695.00)

Optional parameters: conid, tif, exchange, country, currency, primary_exchange.

Stop Orders

python
result = client.buy_stop("SPY", 10, stop_price=695.00)
result = client.sell_stop("SPY", 10, stop_price=685.00)

Stop-Limit Orders

python
result = client.buy_stop_limit("SPY", 10, stop_price=695.00, limit_price=695.50)
result = client.sell_stop_limit("SPY", 10, stop_price=685.00, limit_price=684.50)

Contract-Based Order Placement

python
contract = client.qualify_contract("QQQ")
result = client.place_contract_order(contract, "BUY", 10, order_type="MKT")

This is the migration-friendly equivalent of ib.placeOrder(contract, order).

Generic Order

python
result = client.place_order(
    symbol="SPY",
    quantity=10,
    side="BUY",
    order_type="MKT",
    price=None,
    aux_price=None,
    conid=None,
    force=True,
    tif="DAY",
    exchange="SMART",
)

Parameters:

ParameterTypeDefaultDescription
symbolstrrequiredTicker symbol
quantityfloatrequiredOrder quantity
sidestrrequiredBUY / SELL
order_typestr"MKT"MKT / LMT / STP / STP LMT
pricefloatNoneLimit price
aux_pricefloatNoneStop price
conidintNoneContract ID (auto-resolved if None)
forceboolTrueAuto-confirm IBKR warnings
tifstr"DAY"Time in force: DAY, GTC, IOC, OPG
exchangestr"SMART"Routing exchange
countrystrNoneCountry code (for non-US)
currencystrNoneCurrency (for non-US)
primary_exchangestrNoneListing exchange pin
sec_typestrNoneSTK / IND / OPT / FUT / CRYPTO

Cancel Order

python
success = client.cancel_order(738082887)  # Returns bool

Cancel All Orders

python
cancelled_count = client.cancel_all_orders()  # Returns int

Attempts bulk cancel first, falls back to individual cancellation if bulk fails.

Modify Order

python
result = client.modify_order(order_id, price=695.00, quantity=20)

Parameters: price, aux_price, quantity — only pass fields to change.

Wait for Fill

python
status = client.wait_for_fill(order_id, timeout=60, poll_interval=0.5)

Returns: Dict with status, filled_quantity, avg_fill_price.

Wait for Submitted

Waits until an order is acknowledged by the exchange. Critical for multi-leg strategies.

python
acknowledged = client.wait_for_submitted(order_id, timeout=30, poll_interval=0.3)

Returns: boolTrue if submitted/presubmitted/filled, False if rejected/cancelled/timeout.

Example - Iron Condor leg sequencing:

python
result = client.place_order(symbol="SPX", quantity=1, side="SELL", ...)

if result.success and result.order_id:
    if client.wait_for_submitted(result.order_id, timeout=15):
        client.place_order(symbol="SPX", quantity=1, side="BUY", ...)
    else:
        logger.error("First leg not acknowledged")

Order Status

python
status = client.get_order_status(order_id)

Returns: Dict with order_id, status, symbol, side, quantity, filled_quantity, remaining_quantity, avg_fill_price, limit_price, order_type, tif.

Bracket Orders

Place an entry order with attached stop-loss and take-profit orders. All three orders are linked via IBKR's OCA (One-Cancels-All) group.

python
result = client.place_bracket_order(
    symbol="SPY",
    quantity=10,
    side="BUY",
    entry_price=690.00,
    stop_loss=685.00,
    take_profit=700.00,
    entry_type="LMT",
    force=False,
)

Returns: Dict with order IDs for parent and child orders.

Trailing Stop Orders

Main Method

python
result = client.place_trailing_stop(
    symbol="SPY",
    quantity=10,
    side="SELL",
    trail_amount=2.00,      # OR trail_percent=1.0 (not both)
)

Convenience Methods

python
result = client.sell_trail("SPY", 10, trail_amount=2.00)  # Protect long
result = client.buy_trail("SPY", 10, trail_percent=1.0)   # Protect short

WARNING

Provide either trail_amount OR trail_percent, not both.

Adaptive Orders

IBKR adaptive algo orders that adjust execution strategy based on market conditions.

python
result = client.place_adaptive_order(
    symbol="SPY",
    quantity=100,
    side="BUY",
    priority="Normal",     # Normal / Patient / Urgent
    order_type="MKT",
    price=None,            # Max price for MKT orders
    force=False,
)

Order Impact (What-If)

Get margin impact for a hypothetical order without placing it.

python
impact = client.get_order_impact("SPY", quantity=100, side="BUY", order_type="MKT")

Returns: Dict with margin requirements.

Combo Orders

Combo orders (spreads) trade multiple option legs as a single order.

ComboLeg

python
from aqc_trading_sdk import ComboLeg

ComboLeg(
    conid=123456,      # Contract ID (required)
    ratio=1,           # Leg ratio (required)
    action="SELL",     # "BUY" or "SELL" (required)
    exchange="CBOE"    # Required for options
)

Exchange Routing

UnderlyingExchange
SPX/SPXWCBOE
SPY, QQQ, TQQQSMART

Side Concept

For combo orders, side="BUY" means buying the spread structure (opening the position), regardless of credit/debit. Individual leg action fields determine which legs are sold/bought.

Bear Call Spread

python
from aqc_trading_sdk import ComboLeg

short_call = client.get_option_contract(
    symbol="SPX", expiry="20260130", strike=6100, right="C", trading_class="SPXW"
)
long_call = client.get_option_contract(
    symbol="SPX", expiry="20260130", strike=6110, right="C", trading_class="SPXW"
)

short_conid = [c for c in short_call if c.get("maturityDate") == "20260130"][0]["conid"]
long_conid = [c for c in long_call if c.get("maturityDate") == "20260130"][0]["conid"]

legs = [
    ComboLeg(conid=short_conid, ratio=1, action="SELL", exchange="CBOE"),
    ComboLeg(conid=long_conid, ratio=1, action="BUY", exchange="CBOE")
]

result = client.place_combo_order(legs=legs, quantity=1, side="BUY", order_type="MKT")

Vertical Spread (Shortcut)

python
result = client.place_vertical_spread(
    symbol="SPX",
    expiry="20260130",
    long_strike=6000,
    short_strike=6010,
    right="P",
    quantity=1,
    trading_class="SPXW",
    order_type="MKT",
    force=False,
)

Iron Condor (Shortcut)

python
result = client.place_iron_condor(
    symbol="SPX",
    expiry="20260130",
    put_long_strike=5900,
    put_short_strike=5950,
    call_short_strike=6050,
    call_long_strike=6100,
    quantity=1,
    trading_class="SPXW",
    order_type="MKT",
    force=False,
)

How Combo Orders Work (Server-Side)

IBKR requires a spread conidex string. The server builds it as:

{spread_conid}@{exchange};;;{leg_conid1}/{signed_ratio},{leg_conid2}/{signed_ratio}
  • signed_ratio is positive for BUY legs, negative for SELL legs
  • For index options, spread_conid=0
  • Example: 0@CBOE;;;843975599/-1,843975601/1

Options with conid

For options, always provide the conid:

python
contracts = client.get_option_contract(
    symbol="SPX", expiry="20260126", strike=6900, right="P", trading_class="SPXW"
)
opt_conid = contracts[0]["conid"]

result = client.buy_limit("SPX", 1, price=5.00, conid=opt_conid)