Skip to navigation

Execution Details

View as MarkdownOpen in Claude

Introduction

EWrapper.Execution and EWrapper.CommissionReport can be requested on demand via the EClient.reqExecutions method which receives an ExecutionFilter object as parameter to obtain only those executions matching the given criteria. An empty ExecutionFilter object can be passed to obtain all previous executions.

Once all matching executions have been delivered, an EWrapper.execDetailsEnd event will be triggered.

Important: By default, only those executions occurring since midnight for that particular account will be delivered. If you want to request executions from the last 7 days, TWS’s Trade Log setting “Show trades for …” must be adjusted to your requirement. The IB Gateway is limited to only executions from the current trading day since midnight.


ExecID Behavior

If a correction to an execution is published it will be received as an additional EWrapper.execDetails callback with all parameters identical except for the execID in the Execution object. The execID will differ only in the digits after the final period.

By default, most ExecID values will return as 4-segment alphanumeric sequence to identify each unique order. In the case of Combo orders, you may encounter a 5-segment alphanumeric sequence which will be used to denote per-leg executions. As an example, if a 1:1 combo for 200 shares of both contracts is placed, the first leg may fill for 200 shares, then leg 2 may fill for 100 in one execution, and then another execution for leg 2 of 100. The fifth segment will distinguish between these unique inner-combo executions.


The Execution Object

The Execution object is used to maintain all data related to a user’s traded orders. This can be used in both querying execution details and navigating received data. The details provided will display all information pertaining to the execution, including how many shares were filled, the price of the execution, and what time it took place.

OrderId: integer. The API client’s order Id. May not be unique to an account.

ClientId: integer. The API client identifier which placed the order which originated this execution.

ExecId: String. The execution’s identifier. Each partial fill has a separate ExecId. A correction is indicated by an ExecId which differs from a previous ExecId in only the digits after the final period, e.g. an ExecId ending in “.02” would be a correction of a previous execution with an ExecId ending in “.01”.

Time: String. The execution’s server time.

AcctNumber: String. The account to which the order was allocated.

Exchange: String. The exchange where the execution took place.

Side: String. Specifies if the transaction was buy or sale BOT for bought, SLD for sold.

Shares: decimal. The number of shares filled.

Price: double. The order’s execution price excluding commissions.

PermId: integer. The TWS order identifier. The PermId can be 0 for trades originating outside IB.

Liquidation: integer. Identifies whether an execution occurred because of an IB-initiated liquidation.

CumQty: decimal. Cumulative quantity. Used in regular trades, combo trades and legs of the combo.

AvgPrice: double. Average price. Used in regular trades, combo trades and legs of the combo. Does not include commissions.

OrderRef: String. The OrderRef is a user-customizable string that can be set from the API or TWS and will be associated with an order for its lifetime.

EvRule: String. The Economic Value Rule name and the respective optional argument. The two values should be separated by a colon. For example, aussieBond:YearsToExpiration=3. When the optional argument is not present, the first value will be followed by a colon.

EvMultiplier: double. Tells you approximately how much the market value of a contract would change if the price were to change by 1. It cannot be used to get market value by multiplying the price by the approximate multiplier.

ModelCode: String. model code

LastLiquidity: Liquidity. The liquidity type of the execution.

pendingPriceRevision: bool. Describes if the execution is still pending price revision.

Given additional structures for executions are ever evolving, it is recommended to review the relevant Execution class in your programming language for a comprehensive review of what fields are available.

Execution Class Reference


Request Execution Details

EClient.reqExecutions(reqId, filter)

Requests current day’s (since midnight) executions and commission report matching the filter. Only the current day’s executions can be retrieved.

reqId
int

The request’s unique identifier.

filter
ExecutionFilter

The filter criteria used to determine which execution reports are returned.


self.reqExecutions(10001, ExecutionFilter())

Receive Execution Details

EWrapper.execDetails(reqId, contract, execution)

Provides the executions which happened in the last 24 hours.

reqId
int

The request’s identifier.

contract
Contract

The Contract of the Order.

execution
Execution

The Execution details.


def execDetails(self, reqId: int, contract: Contract, execution: Execution):
print("ExecDetails. ReqId:", reqId, "Symbol:", contract.symbol, "SecType:", contract.secType, "Currency:", contract.currency, execution)

EWrapper.execDetailsEnd

EWrapper.execDetailsEnd(reqId)

Indicates the end of the Execution reception.

reqId
int

The request’s identifier.

def execDetailsEnd(self, reqId: int):
print("ExecDetailsEnd. ReqId:", reqId)