Skip to main content

TWS API order types

This catalog covers every construction on IBKR's official TWS API Basic Orders page, then the major compound and algorithmic families. Availability is a function of product, route, region, account permissions, TWS/server version, and sometimes live versus paper trading. The final authority is the current IBKR order matrix plus ContractDetails.orderTypes/validExchanges.

Core directional orders​

NameEncodingOperation and edge cases
MarketorderType="MKT"Executes at available prices; favors immediacy, provides no price protection, and can sweep far through a thin book.
LimitLMT; lmtPriceBuy at limit or lower / sell at limit or higher. It may never fill. Price must conform to the applicable market-rule increment.
Forex cash quantityusually LMT/MKT; cashQtySizes by settlement-currency cash rather than base units where supported. Do not also send a conflicting totalQuantity.
Market-to-limitMTLSends as market; an unfilled remainder becomes a limit at the execution price. A partial first fill determines the remainder's cap.
Market with protectionMKT PRTFutures-oriented protected market order; unfilled quantity becomes a limit at an exchange-defined protection price. Protection is not your chosen limit.
Limit with manual-order timeLMT; lmtPrice, manualOrderTimeRecords the operator/manual submission time for reporting workflows. The timestamp is metadata, not an activation time; use goodAfterTime for activation. Server-version and institutional requirements apply.
BlockLMT; blockOrder=TrueLarge-block handling, historically ISE options specific. Size/routing eligibility is enforced by the venue.
Sweep-to-fillLMT; sweepToFill=TrueSMART-routed limit order that simultaneously addresses successive price levels for speed; never exceeds the limit.
DiscretionaryLMT; lmtPrice, discretionaryAmtDisplays the limit while permitting a hidden discretionary range. Amount must obey tick precision; the hidden range changes execution economics.

Triggered orders​

NameEncodingOperation and edge cases
StopSTP; auxPrice=stopOn trigger becomes market. Trigger is not a guaranteed fill price; gaps can be severe. Buy stop normally lies above and sell stop below the market.
Stop limitSTP LMT; auxPrice=stop, lmtPrice=limitOn trigger becomes limit. Provides price protection but can remain unfilled after the market passes the limit.
Market if touchedMIT; auxPrice=triggerBuy is normally triggered as market falls to/below the trigger; sell as it rises to/above. Semantically opposite to a protective stop.
Limit if touchedLIT; auxPrice=trigger, lmtPrice=limitTouch activates a limit order. It can trigger and not fill.
Stop with protectionSTP PRT; auxPrice=stopTriggered futures order executes within an exchange protection band; remainder becomes a protected limit.
Trailing stopTRAIL; auxPrice=absolute trail or trailingPercent; optional trailStopPriceFavorable movement ratchets the stop; adverse movement does not. On trigger becomes market. Do not set competing trail amount forms.
Trailing stop limitTRAIL LIMIT; trail amount/percent, lmtPriceOffset, optional trailStopPriceRatchets a trigger and, after trigger, submits a limit offset. Price protection introduces non-fill risk. Some TWS presets auto-populate offsets, so explicitly unset conflicting fields.
Adjustable stop familyparent plus triggerPrice, adjustedOrderType, adjustedStopPrice, adjustedStopLimitPrice, adjustedTrailingAmountWhen the adjustment trigger is reached, modifies the parent into the specified stop/stop-limit/trailing type rather than transmitting a separate child. Do not confuse adjustment trigger with stop trigger.

Open, close, and auction​

NameEncodingOperation and edge cases
Market on openMKT, tif="OPG"Participates in the opening process. Cutoffs and imbalance handling are venue-specific.
Limit on openLMT, tif="OPG", lmtPriceOpening participation with a limit; may not fill if the opening price violates it.
Market on closeMOCSeeks the official close without user price protection. Venue cutoff/cancel rules are strict.
Limit on closeLOC; lmtPriceClosing-auction order that fills only at a qualifying close price.
AuctionMTL, tif="AUC", lmtPriceEntered before the open for the calculated opening price; official behavior may resubmit an unfilled remainder as a limit.
Auction limitLMT; auctionStrategyBOX option price-improvement auction participation with a limit. Direct routing and penny improvement rules apply.
Auction pegged to stockPEG STK; delta, startingPrice, optional stock reference/rangeBOX option auction price changes with the underlying by signed delta. Stock range can cancel the order.
Auction relativeREL; auxPrice=offset, auction fieldsBOX option auction relative pricing. It is not the same as generic SMART pegged-to-primary behavior.
Imbalance-onlysupported auction type plus imbalanceOnly=TrueParticipates only in supported exchange imbalance mechanisms; availability/cutoffs are route-specific.

Pegged and relative orders​

NameEncodingOperation and edge cases
Pegged to marketPEG MKT; auxPrice=offset, optional capMaintains a price relative to the same-side market. Official examples and accepted token can vary by server/route; verify contract order types.
Pegged to primaryREL; auxPrice=offset, lmtPrice=capBuy follows NBB and sell follows NBO by offset, capped by limit. Can become aggressive as quotes move. Often unavailable in paper.
Passive relativePASSV REL; auxPrice=offsetPegged order designed to remain passive and avoid crossing; venue repricing rules determine behavior.
Pegged to midpointPEG MID; auxPrice=offset, lmtPrice=capTracks NBBO midpoint with direction-sensitive offset and cap. Requires a valid NBBO and supported route.
Pegged to stockPEG STK; delta/reference fieldsOption price is pegged to movements in its underlying stock. Delta sign and option right matter.
Pegged to benchmarkPEG BENCH; referenceContractId, isPeggedChangeAmountDecrease, peggedChangeAmount, referenceChangeAmount, referenceExchangeId, lmtPricePrice moves based on a reference contract's change from a reference value, not simply the traded contract's quote.
IBKR ATS pegged-to-bestPEG BEST; ATS fields such as minTradeQty, minCompeteSize, offsetsIBKRATS-only behavior. Routing, minimums, and whole/half-penny offsets are server-version dependent.
IBKR ATS pegged-to-midPEG MID with IBKRATS parametersATS midpoint behavior with venue-specific minimum and offset controls. Do not assume generic PEG MID parameters are interchangeable.
MidpriceMIDPRICE; optional lmtPrice capSMART-routed US-stock order that seeks NBBO midpoint or better. The optional cap is highest buy/lowest sell price; requires a valid NBBO and supported TWS/server version.

Venue-specific and volatility orders​

NameEncodingOperation and edge cases
Box TopBOX TOPBOX option marketable order; unfilled remainder becomes a limit at the initial execution price. BOX route only.
VolatilityVOL; volatility, volatilityType, continuousUpdate, referencePriceType, optional lmtPrice and delta-neutral fieldsOption order priced from implied volatility. Volatility type must be daily or annual as specified; underlying-price updates can reprice the order. Complex and entitlement-sensitive.
Scalebase order plus scaleInitLevelSize, scaleSubsLevelSize, scalePriceIncrement, and optional profit/reset fieldsBreaks quantity into successively priced components. Invalid/missing level sizes and increments are rejected; fills alter subsequent levels.
Hedgechild order with parentId, hedgeType, hedgeParamCreates supported delta/beta/FX/pair hedge behavior tied to a parent. Transmit sequence and account permissions are critical.

Combo orders​

First create a Bag contract with ComboLeg records. Order-level forms are:

NameEncodingMeaning
Combo marketMKTMarket price for the combo where supported; legging and routing risk depends on native versus SMART handling.
Combo net limitLMT; lmtPriceLimit on net debit/credit. Confirm the sign convention in a paper account for the exact buy/sell leg construction.
Price per legLMT; orderComboLegs=[OrderComboLeg(price=...), ...]Supplies leg prices. Number/order must match combo legs.
Relative limit comboREL + LMT (official examples also show capitalization variants)Relative behavior with an overall limit.
Relative market comboREL + MKTRelative combo without the same net limit protection.

SMART combo routing parameters use TagValue entries in smartComboRoutingParams; valid tags are venue/product specific. OCA support is restricted for SMART combos, and what-if calculations may be unavailable.

Compound order structures (not orderType tokens)​

Bracket​

IB.bracketOrder(action, quantity, limitPrice, takeProfitPrice, stopLossPrice) returns parent, take-profit child, and stop-loss child. The parent and first child have transmit=False; the last child has transmit=True, causing the group to transmit. Place all three in order. A process crash between sends can leave an untransmitted partial structure; reconcile it.

One-cancels-all​

IB.oneCancelsAll(orders, ocaGroup, ocaType) assigns the group. Type 1 cancels remaining orders with block, type 2 proportionally reduces with block, and type 3 proportionally reduces without block. Partial fills and overfill risk differ. OCA is coordination, not a cross-venue atomic transaction.

Parent/child​

Set child parentId to the parent's API order ID. Stage with transmit=False until the last intended child is ready. Child quantities should match supported parent rules, and children may remain held until the parent fills.

Algorithmic orders​

Set algoStrategy and exact algoParams: list[TagValue]. Official sample tokens and parameters are:

StrategyalgoStrategyParameters shown by the official API sample
AdaptiveAdaptiveadaptivePriority (Urgent, Normal, or Patient)
Arrival PriceArrivalPxmaxPctVol, riskAversion, startTime, endTime, forceCompletion, allowPastEndTime
Close PriceClosePxmaxPctVol, riskAversion, startTime, forceCompletion
Dark IceDarkIcedisplaySize, startTime, endTime, allowPastEndTime
Accumulate/DistributeADcomponentSize, timeBetweenOrders, randomizeTime20, randomizeSize55, giveUp, catchUp, waitForFill, activeTimeStart, activeTimeEnd
Percentage of VolumePctVolpctVol, startTime, endTime, noTakeLiq
TWAPTwapstrategyType, startTime, endTime, allowPastEndTime
VWAPVwapmaxPctVol, startTime, endTime, allowPastEndTime, noTakeLiq, speedUp
Price Variant % VolumePctVolPxstartPctVol, endPctVol, startTime, endTime, noTakeLiq, speedUp
Size Variant % VolumePctVolSzstartPctVol, endPctVol, startTime, endTime, noTakeLiq
Time Variant % VolumePctVolTmstartPctVol, endPctVol, startTime, endTime, noTakeLiq
Balance Impact RiskBalanceImpactRiskmaxPctVol, riskAversion, forceCompletion
Minimize ImpactMinImpactmaxPctVol

Some official regional examples use maxPctVol4Px, minPctVol4Px, or deltaPctVol. Treat the tag set as a schema: values are strings, booleans are normally encoded as "1"/"0", percentages have strategy-specific ranges, and an unknown/misspelled tag is not safely ignored.

Do not invent tags. Use the current official IB algorithms reference. Common parameters include start/end time, participation percentage, urgency/risk aversion, allow-past-end-time, force completion, and component/display size. Time parameters must be in the future where required (for example, error 167 for a past VWAP start).

Conditions​

Conditions do not create new order types. Append PriceCondition, TimeCondition, MarginCondition, ExecutionCondition, VolumeCondition, or PercentChangeCondition to Order.conditions, link with .And()/.Or(), and control behavior with conditionsCancelOrder and conditionsIgnoreRth.

A price condition needs a canonical conId, exchange, trigger price, and comparison direction. A condition can be satisfied during a data gap or based on a trigger method you did not intend; test both RTH settings. Conditions are unavailable for some contracts/order types.

Official sources: basic orders, order conditions, IB algorithms, and IBKRATS orders.