Main Content

orders

ObtainBloombergEMSX order subscription

Description

example

[events,subs] = orders(c,fields)subscribes to Bloomberg®EMSX fieldsfields使用Bloomberg EMSX connectionc.ordersreturns existing event dataeventsfrom the event queue and the Bloomberg EMSX subscription listsubs.

example

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

example

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

Examples

collapse all

Create the Bloomberg EMSX connectionc.

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

Subscribe to events for Bloomberg EMSX orders using the Bloomberg EMSX connectioncand Bloomberg EMSX field listfields.

fields = {'EMSX_BROKER','EMSX_AMOUNT','EMSX_FILLED'}; [events,subs] = orders(c,fields)
events = MSG_TYPE: {'E'} MSG_SUB_TYPE: {'O'} EVENT_STATUS: 4 ... subs = com.bloomberglp.blpapi.SubscriptionList@4bc3dc78

eventscontains fields for the events currently in the event queue.subscontains the Bloomberg EMSX subscription list object.

Unsubscribe from order events using the Bloomberg EMSX subscription list objectsubs.

c.Session.unsubscribe(subs)

Close the Bloomberg EMSX connection.

close(c)

Create the Bloomberg EMSX connectionc.

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

Write a custom event handler function namedeventhandler. Run the custom event handler usingtimer. Start the timer to runeventhandlerimmediately usingstart. For details, seeWriting and Running Custom Event Handler Functions.

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

tis the timer object.

Subscribe to events for Bloomberg EMSX orders using the Bloomberg EMSX connectioncand Bloomberg EMSX field listfields. Use the custom event handler by setting the name-value pair argument'useDefaultEventHandler'tofalse.

fields = {'EMSX_BROKER','EMSX_AMOUNT','EMSX_FILLED'}; [events,subs] = orders(c,fields,'useDefaultEventHandler',false)
events = [] subs = com.bloomberglp.blpapi.SubscriptionList@2c5b1c7e

eventscontains an empty double. The custom event handler processes the event queue.subscontains the Bloomberg EMSX subscription list object.

Unsubscribe from order events using the Bloomberg EMSX subscription list objectsubs. Stop the timer to stop data updates usingstop.

c.Session.unsubscribe(subs) stop(t)

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

delete(t)

Close the Bloomberg EMSX connection.

close(c)

Create the Bloomberg EMSX connectionc.

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

Subscribe to events for Bloomberg EMSX orders using the Bloomberg EMSX connectioncand Bloomberg EMSX field listfields. Specify the name-value pair argumenttimeOutand set it to 200 milliseconds.

fields = {'EMSX_BROKER','EMSX_AMOUNT','EMSX_FILLED'}; [events,subs] = orders(c,fields,'timeOut',200)
events = MSG_TYPE: {'E'} MSG_SUB_TYPE: {'O'} EVENT_STATUS: 4 ... subs = com.bloomberglp.blpapi.SubscriptionList@4bc3dc78

eventscontains fields for the events currently in the event queue.subscontains the Bloomberg EMSX subscription list object.

Unsubscribe from order events using the Bloomberg EMSX subscription list objectsubs.

c.Session.unsubscribe(subs)

Close the Bloomberg EMSX connection.

close(c)

Create the Bloomberg EMSX connectionc.

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

Create a structureoptions. To use the default event handler, set the fielduseDefaultEventHandlertotrue. Set the fieldtimeOutto 200 milliseconds. Subscribe to events for Bloomberg EMSX orders using the Bloomberg EMSX connectionc, Bloomberg EMSX field listfields, and options structureoptions.

options.timeOut = 200; options.useDefaultEventHandler = true; fields = {'EMSX_BROKER','EMSX_AMOUNT','EMSX_FILLED'}; [events,subs] = orders(c,fields,options)
events = MSG_TYPE: {'E'} MSG_SUB_TYPE: {'O'} EVENT_STATUS: 4 ... subs = com.bloomberglp.blpapi.SubscriptionList@4bc3dc78

eventscontains fields for the events currently in the event queue.subscontains the Bloomberg EMSX subscription list object.

Unsubscribe from order events using the Bloomberg EMSX subscription list objectsubs.

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 usingemsx.

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

Example:'EMSX_TICKER'
'EMSX_AMOUNT'
'EMSX_ORDER_TYPE'

Data Types:cell

选择自定义事件处理程序或超时值, 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.

Theoptionsstructure 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 asName1=Value1,...,NameN=ValueN, whereNameis the argument name andValueis 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 encloseNamein 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 valuestrueorfalse.

To specify the default event handler, set this flag totrue.

Otherwise, set this flag tofalseto 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,eventsis a structure containing the current contents of the event queue. Otherwise,eventsis an empty double.

When the name-value pair argument'useDefaultEventHandler'or the same field for the structureoptionsis set tofalse,eventsis an empty double.

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

Version History

Introduced in R2013a