Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

executions

Request Interactive Brokers execution data

Syntax

d = executions(ib,filter)
d = executions(ib,filter,eventhandler)

Description

example

d = executions(ib,filter) requests Interactive Brokers® execution data using the IB Trader WorkstationSM connection ib and the Interactive Brokers execution filter filter.

example

d = executions(ib,filter,eventhandler) requests Interactive Brokers execution data using an event handler function eventhandler. Use the sample event handler ibExampleEventHandler or write a custom event handler function.

Examples

collapse all

Create the IB Trader Workstation℠ connection ib on the local machine using port number 7496.

ib = ibtws('',7496);

Create the IB Trader Workstation℠ execution filter IExecutionFilter object filter. This object specifies these property values:

  • Buy side

  • Stock security type

  • Aggregate exchange

  • Google® symbol

filter = ib.Handle.createExecutionFilter;
filter.side = 'BUY';
filter.secType = 'STK';
filter.exchange = 'SMART';
filter.symbol = 'GOOG';

For details about the IExecutionFilter object, see the Interactive Brokers® API Reference Guide.

Request IB Trader Workstation℠ execution filter data using ib and filter.

d = executions(ib,filter)
d = 

  struct with fields:

    enddetails: [1×1 struct]

d is a structure containing the execution filter data in the structure enddetails.

Display the execution filter data.

d.enddetails
ans = 

  struct with fields:

       Type: 'execDetailsEnd'
     Source: [1×1 COM.TWS_TwsCtrl_1]
    EventID: 38
      reqId: 1

The structure enddetails contains these fields:

  • Type -- Data request type

  • Source -- Interactive Brokers® ActiveX® object

  • EventID -- Event identifier

  • reqId -- Execution filter data request identifier

Close the IB Trader Workstation℠ connection.

close(ib)

Create the IB Trader Workstation connection ib on the local machine using port number 7496.

 ib = ibtws('',7496); 

Create the IB Trader Workstation execution filter IExecutionFilter object filter. Here, this object specifies these property values:

  • Buy side

  • Stock security type

  • Aggregate exchange

  • Google® symbol

filter = ib.Handle.createExecutionFilter;
filter.side = 'BUY';
filter.secType = 'STK';
filter.exchange = 'SMART';
filter.symbol = 'GOOG';

For details about the IExecutionFilter object, see Interactive Brokers API Reference Guide.

Request IB Trader Workstation execution filter data using ib and filter. Use the sample event handler ibExampleEventHandler to display the IB Trader Workstation execution filter data in the Command Window. Use ibExampleEventHandler or write a custom event handler function.

d = executions(ib,filter,@ibExampleEventHandler)
d =

     []

    [1x1 COM.TWS_TwsCtrl_1]    [38]    [1]    [1x1 struct]    'execDetailsEnd'

d is an empty double.

ibExampleEventHandler displays the data in the Command Window. The columns are:

  • Interactive Brokers ActiveX® object

  • Event identifier

  • Execution filter data request identifier

  • Structure that repeats the contents of the columns

  • Data request type

For details, see Interactive Brokers API Reference Guide.

Close the IB Trader Workstation connection.

close(ib)

Input Arguments

collapse all

IB Trader Workstation connection, specified as an IB Trader Workstation connection object created using ibtws.

IB Trader Workstation execution filter, specified as a IExecutionFilter object. For details about this object, see Interactive Brokers API Reference Guide.

Data Types: struct

Event handler, specified as a function handle, character vector, or string scalar to identify an event handler function that processes the returned data. Use the sample event handler or write a custom event handler function. For details, see Writing and Running Custom Event Handler Functions with Interactive Brokers.

Example: @eventhandler

Data Types: function_handle | char | string

Output Arguments

collapse all

IB Trader Workstation execution filter data, returned as a structure. When using an event handler function, d is an empty double.

Tips

  • ibBuiltInErrMsg appears in the MATLAB® workspace. Check the status of connection and function execution by displaying the contents of this variable. ibBuiltInErrMsg contains messages related to:

    • Connection

    • Information resulting from executing functions

    • Errors

Introduced in R2015a

Was this topic helpful?