Main Content

orders

Obtain Bloomberg EMSX order subscription

Since R2021a

Description

events = orders(c,fields) subscribes to Bloomberg® EMSX fields fields using the Bloomberg EMSX connection c with the Bloomberg EMSX C++ interface. orders returns existing event data events from the event queue.

example

events = orders(c,fields,Name,Value) uses additional options specified by one or more Name,Value pair arguments to specify a custom event handler or timeout value for the event handler.

example

events = orders(c,fields,options) uses the options structure to customize the output, which is useful to preconfigure and save your options for repeated use. The options structure fields and values correspond to names and values of name-value pair arguments, respectively.

example

Examples

collapse all

Create the Bloomberg EMSX connection c using the Bloomberg EMSX C++ interface.

c = bloombergEMSX('//blp/emapisvc_beta');

Subscribe to events for Bloomberg EMSX orders using the Bloomberg EMSX connection c and Bloomberg EMSX field list fields.

fields = {'EMSX_BROKER','EMSX_AMOUNT','EMSX_FILLED'};

events = orders(c,fields)
events = 

                       MSG_TYPE: {'E'}
                   MSG_SUB_TYPE: {'O'}
                   EVENT_STATUS: 4
                   ...

events contains fields for the events currently in the event queue.

Unsubscribe from order events using the Bloomberg EMSX subscriptions.

c.Session.stopSubscriptions

Close the Bloomberg EMSX connection.

close(c)

Create the Bloomberg EMSX connection c using the Bloomberg EMSX C++ interface.

c = bloombergEMSX('//blp/emapisvc_beta');

Write a custom event handler function named eventhandler. Run the custom event handler using timer. Start the timer to run eventhandler immediately using start. For details, see Writing and Running Custom Event Handler Functions.

t = timer('TimerFcn',{@c.eventhandler},'Period',1, ...
    'ExecutionMode','fixedRate');
start(t)

t is the timer object.

Subscribe to events for Bloomberg EMSX orders using the Bloomberg EMSX connection c and Bloomberg EMSX field list fields. Use the custom event handler by setting the name-value pair argument 'useDefaultEventHandler' to false.

fields = {'EMSX_BROKER','EMSX_AMOUNT','EMSX_FILLED'};

events = orders(c,fields,'useDefaultEventHandler',false)
events =

     []

 

events contains an empty double. The custom event handler processes the event queue.

Unsubscribe from order events using the Bloomberg EMSX subscriptions. Stop the timer to stop data updates using stop.

c.Session.stopSubscriptions
stop(t)

If you are done processing data updates, delete the timer using delete.

delete(t)

Close the Bloomberg EMSX connection.

close(c)

Create the Bloomberg EMSX connection c using the Bloomberg EMSX C++ interface.

c = bloombergEMSX('//blp/emapisvc_beta');

Subscribe to events for Bloomberg EMSX orders using the Bloomberg EMSX connection c and Bloomberg EMSX field list fields. Specify the name-value pair argument timeOut and set it to 200 milliseconds.

fields = {'EMSX_BROKER','EMSX_AMOUNT','EMSX_FILLED'};

events = orders(c,fields,'timeOut',200)
events = 

                       MSG_TYPE: {'E'}
                   MSG_SUB_TYPE: {'O'}
                   EVENT_STATUS: 4
                   ...

events contains fields for the events currently in the event queue.

Unsubscribe from order events using the Bloomberg EMSX subscriptions.

c.Session.stopSubsriptions

Close the Bloomberg EMSX connection.

close(c)

Create the Bloomberg EMSX connection c using the Bloomberg EMSX C++ interface.

c = bloombergEMSX('//blp/emapisvc_beta');

Create a structure options. To use the default event handler, set the field useDefaultEventHandler to true. Set the field timeOut to 200 milliseconds. Subscribe to events for Bloomberg EMSX orders using the Bloomberg EMSX connection c, Bloomberg EMSX field list fields, and options structure options.

options.timeOut = 200;
options.useDefaultEventHandler = true;

fields = {'EMSX_BROKER','EMSX_AMOUNT','EMSX_FILLED'};

events = orders(c,fields,options)
events = 

                       MSG_TYPE: {'E'}
                   MSG_SUB_TYPE: {'O'}
                   EVENT_STATUS: 4
                   ...

events contains fields for the events currently in the event queue.

Unsubscribe from order events using the Bloomberg EMSX subscriptions.

c.Session.stopSubscriptions

Close the Bloomberg EMSX connection.

close(c)

Input Arguments

collapse all

Bloomberg EMSX service connection, specified as a bloombergEMSX object.

Bloomberg EMSX field information, specified using a cell array. Use getAllFieldMetaData to view available field information for the Bloomberg EMSX service.

Example: 'EMSX_TICKER'
'EMSX_AMOUNT'
'EMSX_ORDER_TYPE'

Data Types: cell

Options for custom event handler or timeout value, specified as a structure. Use the options structure instead of name-value pair arguments to reuse the optional name-value pair arguments to specify a custom event handler or timeout value for the event handler.

The options structure field and values correspond to names and values of the name-value pair arguments, respectively.

Specify using a custom event handler and a timeout value of 500 milliseconds.

Example: options.useDefaultEventHandler = false;
options.timeOut = 500;

Data Types: struct

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'useDefaultEventHandler',false

Flag for event handler preference, indicating whether to use the default or custom event handler to process order events, specified as the comma-separated pair consisting of 'useDefaultEventHandler' and the logical values true or false.

To specify the default event handler, set this flag to true.

Otherwise, set this flag to false to specify a custom event handler.

Data Types: logical

Timeout value for event handler for the Bloomberg EMSX service, specified as the comma-separated pair consisting of 'timeOut' and a nonnegative integer in units of milliseconds.

Example: 'timeOut',200

Data Types: double

Output Arguments

collapse all

Event queue contents, returned as a double or structure.

If the event queue contains events, events is a structure containing the current contents of the event queue. Otherwise, events is an empty double.

When the name-value pair argument 'useDefaultEventHandler' or the same field for the structure options is set to false, events is an empty double.

Version History

Introduced in R2021a