modifyOrder

Modify Bloomberg EMSX order

Syntax

  • events = modifyOrder(c,modorder) example
  • events = modifyOrder(c,modorder,'timeOut',timeout) example
  • modifyOrder(___,'useDefaultEventHandler',false) example
  • ___ = modifyOrder(c,modorder,options) example

Description

example

events = modifyOrder(c,modorder) modifies a Bloomberg® EMSX order using the Bloomberg EMSX connection c and modify order request structure modorder. modifyOrder returns a status message using the default event handler.

example

events = modifyOrder(c,modorder,'timeOut',timeout) specifies a timeout value timeout for the execution of the default event handler.

example

modifyOrder(___,'useDefaultEventHandler',false) modifies a Bloomberg EMSX order using any of the input arguments in the previous syntaxes and a custom event handler. Write a custom event handler to process the events associated with modifying orders. This syntax does not have an output argument because the custom event handler processes the contents of the event queue. If you want to use the default event handler instead, set the flag 'useDefaultEventHandler' to true and use the events output argument. By default, the flag 'useDefaultEventHandler' is set to true.

example

___ = modifyOrder(c,modorder,options) uses the options structure to customize the output, which is useful to preconfigure and save your options for repeated use. The available options structure fields are timeOut and useDefaultEventHandler. Use the events output argument when the flag useDefaultEventHandler is set to true and omit this output argument when useDefaultEventHandler is set to false.

Examples

expand all

Modify an Order Using the Default Event Handler

To modify a Bloomberg EMSX order, create the connection c using emsx, set up the order subscription using orders, and create an order using createOrder. For an example showing these activities, see Create and Manage a Bloomberg EMSX Order.

Define the structure modorder that contains the order sequence number EMSX_SEQUENCE, the security EMSX_TICKER, and the number of shares EMSX_AMOUNT. This code modifies the order number 728905 for 200 shares of IBM®. Convert the numbers to 32-bit signed integers using int32.

modorder.EMSX_SEQUENCE = int32(728905);
modorder.EMSX_TICKER = 'IBM';
modorder.EMSX_AMOUNT = int32(200);

Modify the order using the Bloomberg EMSX connection c and modorder.

events = modifyOrder(c,modorder)
events = 

    EMSX_SEQUENCE: 728905
          MESSAGE: 'Order Modified'

The default event handler processes the events associated with modifying the order. modifyOrder returns events as a structure that contains these fields:

  • Bloomberg EMSX order number

  • Bloomberg EMSX message

Unsubscribe from order events using the Bloomberg EMSX subscription list object subs. This code assumes that orders creates subs.

b.Session.unsubscribe(subs)

Close the Bloomberg EMSX connection.

close(c)

Modify an Order Using a Timeout

To modify a Bloomberg EMSX order, create the connection c using emsx, set up the order subscription using orders, and create an order using createOrder. For an example showing these activities, see Create and Manage a Bloomberg EMSX Order.

Define the structure modorder that contains the order sequence number EMSX_SEQUENCE, the security EMSX_TICKER, and the number of shares EMSX_AMOUNT. This code modifies the order number 728905 for 200 shares of IBM. Convert the numbers to 32-bit signed integers using int32.

modorder.EMSX_SEQUENCE = int32(728905);
modorder.EMSX_TICKER = 'IBM';
modorder.EMSX_AMOUNT = int32(200);

Modify the order using the Bloomberg EMSX connection c and modorder. Set the timeout value to 200 milliseconds. timeOut specifies how long the event handler listens to the queue for an event for each iteration of the code.

events = modifyOrder(c,modorder,'timeOut',200)
events = 

    EMSX_SEQUENCE: 728905
          MESSAGE: 'Order Modified'

The default event handler processes the events associated with modifying the order. modifyOrder returns events as a structure that contains these fields:

  • Bloomberg EMSX order number

  • Bloomberg EMSX message

Unsubscribe from order events using the Bloomberg EMSX subscription list object subs. This code assumes that orders creates subs.

b.Session.unsubscribe(subs)

Close the Bloomberg EMSX connection.

close(c)

Modify an Order Using a Custom Event Handler

To modify a Bloomberg EMSX order, create the Bloomberg EMSX connection c using emsx, set up the order subscription using orders, and create an order using createOrder. For an example showing these activities, see Create and Manage a Bloomberg EMSX Order.

Define the structure modorder that contains the order sequence number EMSX_SEQUENCE, the security EMSX_TICKER, and the number of shares EMSX_AMOUNT. This code modifies the order number 728905 for 200 shares of IBM. Convert the numbers to 32-bit signed integers using int32.

modorder.EMSX_SEQUENCE = int32(728905);
modorder.EMSX_TICKER = 'IBM';
modorder.EMSX_AMOUNT = int32(200);

Suppose you create a custom event handler function called eventhandler with input argument c. Run eventhandler using timer. Start the timer to run eventhandler immediately using start. For details, see Writing and Running Custom Event Handler Functions.

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

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

Modify the order using the Bloomberg EMSX connection c and modorder. Set the flag 'useDefaultEventHandler' to false so that eventhandler processes the events associated with modifying an order.

modifyOrder(c,modorder,'useDefaultEventHandler',false)

Unsubscribe from order events using the Bloomberg EMSX subscription list object subs. This code assumes that orders creates subs. Stop the timer to stop data updates using stop.

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

Delete the timer if you are done processing data updates using delete.

delete(t)

Close the Bloomberg EMSX connection.

close(c)

Modify an Order Using an Options Structure

To modify a Bloomberg EMSX order, create the connection c using emsx, set up the order subscription using orders, and create an order using createOrder. For an example showing these activities, see Create and Manage a Bloomberg EMSX Order.

Define the structure modorder that contains the order sequence number EMSX_SEQUENCE, the security EMSX_TICKER, and the number of shares EMSX_AMOUNT. This code modifies the order number 728905 for 200 shares of IBM. Convert the numbers to 32-bit signed integers using int32.

modorder.EMSX_SEQUENCE = int32(728905);
modorder.EMSX_TICKER = 'IBM';
modorder.EMSX_AMOUNT = int32(200);

Create a structure options. To use the default event handler, set the field useDefaultEventHandler to true. Set the field timeOut to 200 milliseconds. timeOut specifies how long the event handler listens to the queue for an event for each iteration of the code. Modify the order using the Bloomberg EMSX connection c, modorder, and options structure options.

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

events = modifyOrder(c,modorder,options)
events = 

    EMSX_SEQUENCE: 728905
          MESSAGE: 'Order Modified'

The default event handler processes the events associated with modifying the order. modifyOrder returns events as a structure that contains these fields:

  • Bloomberg EMSX order number

  • Bloomberg EMSX message

Unsubscribe from order events using the Bloomberg EMSX subscription list object subs. This code assumes that orders creates subs.

b.Session.unsubscribe(subs)

Close the Bloomberg EMSX connection.

close(c)

Input Arguments

expand all

c — Bloomberg EMSX service connectionconnection object

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

modorder — Modify order requeststructure

Modify order request, specified as a structure that contains these fields.

Use getAllFieldMetaData to view all available fields for modorder. Convert the numbers to 32-bit signed integers using int32.

Field

Description

EMSX_SEQUENCE

Bloomberg EMSX order sequence number

EMSX_TICKER

Bloomberg EMSX ticker symbol

EMSX_AMOUNT

Bloomberg EMSX number of shares

Example: modorder.EMSX_SEQUENCE = int32(728905);
modorder.EMSX_TICKER = 'XYZ';
modorder.EMSX_AMOUNT = int32(100);

Data Types: struct

timeout — Timeout value500 milliseconds (default) | nonnegative integer

Timeout value, specified as a nonnegative integer to denote the time in milliseconds the default or custom event handler waits for an event in the current queue.

Data Types: double

options — Options for custom event handler or timeout valuestructure

Options for custom event handler or timeout value, specified as a structure. Use the options structure to reuse the settings for specifying a custom event handler or timeout value for the event handler.

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

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

Data Types: struct

Output Arguments

expand all

events — Event queue contentsdouble | structure

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.

More About

expand all

Tips

For details about Bloomberg EMSX, see the EMSX API Programmer's Guide using the WAPI <GO> option from the Bloomberg terminal.

Was this topic helpful?