Skip to main content

Order

ib_interface.api.order

Order types used by Interactive Brokers.

Order

Order for trading contracts.

https://interactivebrokers.github.io/tws-api/available_orders.html

Regulatory attributes (API v222+): customerAccount: Customer account identifier for regulatory reporting. professionalCustomer: If True, marks the order as originating from a professional customer (affects exchange fee schedules).

Overnight attributes (API v222+): includeOvernight: If True, the order participates in overnight trading sessions where supported by the exchange.

Attached order attributes (API v222+): slOrderId: Order ID of the attached stop-loss child order. slOrderType: Order type for the attached stop-loss (e.g. "STP"). ptOrderId: Order ID of the attached profit-taker child order. ptOrderType: Order type for the attached profit-taker (e.g. "LMT").

Post-only and auction attributes (API v222+): postOnly: If True, the order will only add liquidity (rejected if it would cross the spread and take liquidity). allowPreOpen: If True, the order can participate in the pre-open session before the regular trading session begins. ignoreOpenAuction: If True, the order will not participate in the opening auction. deactivate: If True, the order is submitted in a deactivated state and must be explicitly activated before execution. seekPriceImprovement: If True, requests price improvement through applicable exchange mechanisms. None means unspecified.

LimitOrder

MarketOrder

StopOrder

StopLimitOrder

OrderStatus

OrderState

OrderComboLeg

Trade

Trade keeps track of an order, its status and all its fills.

Events:

  • statusEvent (trade: :class:.Trade)
  • modifyEvent (trade: :class:.Trade)
  • fillEvent (trade: :class:.Trade, fill: :class:.Fill)
  • commissionReportEvent (trade: :class:.Trade, fill: :class:.Fill, commissionReport: :class:.CommissionReport)
  • filledEvent (trade: :class:.Trade)
  • cancelEvent (trade: :class:.Trade)
  • cancelledEvent (trade: :class:.Trade)

isActive

def isActive() -> bool

True if eligible for execution, false otherwise.

isDone

def isDone() -> bool

True if completely filled or cancelled, false otherwise.

filled

def filled() -> float

Number of shares filled.

remaining

def remaining() -> float

Number of shares remaining to be filled.

BracketOrder

OrderCondition

createClass

def createClass(condType)

And

def And()

Or

def Or()

PriceCondition

TimeCondition

MarginCondition

ExecutionCondition

VolumeCondition

PercentChangeCondition