Main Content

routes

Obtain Bloomberg EMSX route subscription

Description

[events,subs] = routes(c,fields) subscribes to Bloomberg® EMSX fields fields using the Bloomberg EMSX connection c. routes returns existing event data events from the event queue and the Bloomberg EMSX subscription list subs.

example

[events,subs] = routes(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,subs] = routes(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.

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

Set up the route subscription for Bloomberg EMSX fields EMSX_BROKER and EMSX_WORKING using the Bloomberg EMSX connection c.

fields = {'EMSX_BROKER','EMSX_WORKING'};

[events,subs] = routes(c,fields)
events = 

                       MSG_TYPE: {5x1 cell}
                   MSG_SUB_TYPE: {5x1 cell}
                   EVENT_STATUS: [5x1 int32]
                   ...

subs =

com.bloomberglp.blpapi.SubscriptionList@463b9287

events contains fields for the events currently in the event queue. subs contains the Bloomberg EMSX subscription list object.

Unsubscribe from route events using the Bloomberg EMSX subscription list object subs.

c.Session.unsubscribe(subs)

Close the Bloomberg EMSX connection.

close(c)

Create the Bloomberg EMSX connection c.

 c = emsx('//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.

Set up the route subscription for Bloomberg EMSX fields EMSX_BROKER and EMSX_WORKING using the Bloomberg EMSX connection c. Use the custom event handler by setting the name-value pair argument 'useDefaultEventHandler' to false.

fields = {'EMSX_BROKER','EMSX_WORKING'};

[events,subs] = routes(c,fields,'useDefaultEventHandler',false)
events =

     []

subs =

com.bloomberglp.blpapi.SubscriptionList@463b9287

events is an empty double. The custom event handler processes the event queue. subs contains the Bloomberg EMSX subscription list object.

Unsubscribe from route events using the Bloomberg EMSX subscription list object subs. Stop the timer to stop data updates using stop.

c.Session.unsubscribe(subs)
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.

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

Set up the route subscription for Bloomberg EMSX fields EMSX_BROKER and EMSX_WORKING using the Bloomberg EMSX connection c. Specify the name-value pair argument timeOut and set it to 200 milliseconds.

fields = {'EMSX_BROKER','EMSX_WORKING'};

[events,subs] = routes(c,fields,'timeOut',200)
events = 

                       MSG_TYPE: {5x1 cell}
                   MSG_SUB_TYPE: {5x1 cell}
                   EVENT_STATUS: [5x1 int32]
                   ...

subs =

com.bloomberglp.blpapi.SubscriptionList@463b9287

events contains fields for the events currently in the event queue. subs contains the Bloomberg EMSX subscription list object.

Unsubscribe from route events using the Bloomberg EMSX subscription list object subs.

c.Session.unsubscribe(subs)

Close the Bloomberg EMSX connection.

close(c)

Create the Bloomberg EMSX connection c.

 c = emsx('//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. Set up the route subscription for Bloomberg EMSX fields EMSX_BROKER and EMSX_WORKING using the Bloomberg EMSX connection c and options structure options.

options.useDefaultEventHandler = true;
options.timeOut = 200;
fields = {'EMSX_BROKER','EMSX_WORKING'};

[events,subs] = routes(c,fields,options)
events = 

                       MSG_TYPE: {5x1 cell}
                   MSG_SUB_TYPE: {5x1 cell}
                   EVENT_STATUS: [5x1 int32]
                   ...

subs =

com.bloomberglp.blpapi.SubscriptionList@463b9287

events contains fields for the events currently in the event queue. subs contains the Bloomberg EMSX subscription list object.

Unsubscribe from route events using the Bloomberg EMSX subscription list object subs.

c.Session.unsubscribe(subs)

Close the Bloomberg EMSX connection.

close(c)

Input Arguments

collapse all

Bloomberg EMSX service connection, specified as a connection object created using emsx.

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.

Bloomberg EMSX subscription list, returned as a Bloomberg EMSX subscription list object.

Tips

Suppose you create a custom event handler function called eventhandler with input argument c. Run eventhandler using this code.

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

t is the MATLAB® timer object. For details, see timer.

Version History

Introduced in R2013a