Main Content

manualFill

Fill Bloomberg EMSX orders manually

Since R2021a

Description

events = manualFill(c,order) manually fills a Bloomberg® EMSX order using the Bloomberg EMSX connection with the Bloomberg EMSX C++ interface and order request. manualFill returns the order sequence number and status message using the default event handler.

example

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

example

manualFill(___,'useDefaultEventHandler',false) manually fills a Bloomberg EMSX order using any of the previous input argument combinations and a custom event handler function. Write a custom event handler to process the events associated with manually filling an order. This syntax does not have an output argument because the custom event handler processes the contents of the event queue.

example

___ = manualFill(c,order,options) uses the options structure to customize the output, which is useful for configuring and saving your options for repeated use. The available options structure fields are timeOut and useDefaultEventHandler. Use the events output argument when the useDefaultEventHandler field is set to true, and omit this output argument when the useDefaultEventHandler field is set to false.

example

Examples

collapse all

Using a Bloomberg EMSX connection, manually fill a Bloomberg EMSX order.

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

Create the order request structure order to define the order parameters. In this case, the code creates a buy market order for 100 shares of IBM®. The code uses the broker BB with the time in force set to DAY and any hand instruction. Convert the number of shares to a 32-bit signed integer using int32.

order.EMSX_TICKER = 'IBM';
order.EMSX_AMOUNT = int32(100);
order.EMSX_ORDER_TYPE = 'MKT';
order.EMSX_BROKER = 'BB';
order.EMSX_TIF = 'DAY';
order.EMSX_HAND_INSTRUCTION = 'ANY';
order.EMSX_SIDE = 'BUY';

Create the order using the Bloomberg EMSX connection c and order.

events = createOrder(c,order)
events = 

  struct with fields:
    
    EMSX_SEQUENCE: 354646
    MESSAGE: 'Order created'

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

  • EMSX_SEQUENCE — Bloomberg EMSX order number

  • MESSAGE — Bloomberg EMSX message

Manually fill the Bloomberg order. Specify the manualorder structure with the order number in the events structure.

manualorder.EMSX_SEQUENCE = int32(events.EMSX_SEQUENCE);
events = manualFill(c,manualorder)
events =

  struct with fields:

    EMSX_SEQUENCE: 354646
    MESSAGE: 'Order Filled'

The default event handler processes the events associated with manually filling the order. events is a structure that contains these fields:

  • EMSX_SEQUENCE — Bloomberg EMSX order number

  • MESSAGE — Bloomberg EMSX message

Close the Bloomberg EMSX connection.

close(c)

Using a Bloomberg EMSX connection, manually fill a Bloomberg EMSX order. Specify a timeout value.

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

Create the order request structure order to define the order parameters. In this case, the code creates a buy market order for 100 shares of IBM. The code uses the broker BB with the time in force set to DAY and any hand instruction. Convert the number of shares to a 32-bit signed integer using int32.

order.EMSX_TICKER = 'IBM';
order.EMSX_AMOUNT = int32(100);
order.EMSX_ORDER_TYPE = 'MKT';
order.EMSX_BROKER = 'BB';
order.EMSX_TIF = 'DAY';
order.EMSX_HAND_INSTRUCTION = 'ANY';
order.EMSX_SIDE = 'BUY';

Create the order using the Bloomberg EMSX connection c and order.

events = createOrder(c,order)
events = 

  struct with fields:
    
    EMSX_SEQUENCE: 354646
    MESSAGE: 'Order created'

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

  • EMSX_SEQUENCE — Bloomberg EMSX order number

  • MESSAGE — Bloomberg EMSX message

Manually fill the Bloomberg order. Specify the manualorder structure with the order number in the events structure. Specify the timeout value of 200 milliseconds by using the 'timeOut' flag.

manualorder.EMSX_SEQUENCE = int32(events.EMSX_SEQUENCE);
events = manualFill(c,manualorder,'timeOut',200)
events =

  struct with fields:

    EMSX_SEQUENCE: 354646
    MESSAGE: 'Order Filled'

events is a structure that contains these fields:

  • EMSX_SEQUENCE — Bloomberg EMSX order number

  • MESSAGE — Bloomberg EMSX message

Close the Bloomberg EMSX connection.

close(c)

Using a Bloomberg EMSX connection, manually fill a Bloomberg EMSX order. Specify using a custom event handler function to process the events.

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

Create the order request structure order to define the order parameters. In this case, the code creates a buy market order for 100 shares of IBM. The code uses the broker BB with the time in force set to DAY and any hand instruction. Convert the number of shares to a 32-bit signed integer using int32.

order.EMSX_TICKER = 'IBM';
order.EMSX_AMOUNT = int32(100);
order.EMSX_ORDER_TYPE = 'MKT';
order.EMSX_BROKER = 'BB';
order.EMSX_TIF = 'DAY';
order.EMSX_HAND_INSTRUCTION = 'ANY';
order.EMSX_SIDE = 'BUY';

Create the order using the Bloomberg EMSX connection c and order.

events = createOrder(c,order)
events = 

  struct with fields:
    
    EMSX_SEQUENCE: 354646
    MESSAGE: 'Order created'

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

  • EMSX_SEQUENCE — Bloomberg EMSX order number

  • MESSAGE — Bloomberg EMSX message

Manually fill the Bloomberg order. Specify the manualorder structure with the order number in the events structure. Use a custom event handler function to process the events. You can use the sample event handler function processEvent or write your own custom event handler function. For this example, use processEvent to process the events.

manualorder.EMSX_SEQUENCE = int32(events.EMSX_SEQUENCE);
manualFill(c,manualorder,'useDefaultEventHandler',false)
processEvent(c)
ManualFill = {

    EMSX_SEQUENCE = 354646

    MESSAGE = 'Order Filled'

}

Close the Bloomberg EMSX connection.

close(c)

Using a Bloomberg EMSX connection, manually fill a Bloomberg EMSX order. Specify an additional option for a timeout value by using a structure.

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

Create the order request structure order to define the order parameters. In this case, the code creates a buy market order for 100 shares of IBM. The code uses the broker BB with the time in force set to DAY and any hand instruction. Convert the number of shares to a 32-bit signed integer using int32.

order.EMSX_TICKER = 'IBM';
order.EMSX_AMOUNT = int32(100);
order.EMSX_ORDER_TYPE = 'MKT';
order.EMSX_BROKER = 'BB';
order.EMSX_TIF = 'DAY';
order.EMSX_HAND_INSTRUCTION = 'ANY';
order.EMSX_SIDE = 'BUY';

Create the order using the Bloomberg EMSX connection c and order.

events = createOrder(c,order)
events = 

  struct with fields:
    
    EMSX_SEQUENCE: 354646
    MESSAGE: 'Order created'

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

  • EMSX_SEQUENCE — Bloomberg EMSX order number

  • MESSAGE — Bloomberg EMSX message

Manually fill the Bloomberg order. Specify the manualorder structure with the order number in the events structure. Then, specify an additional option for a timeout value of 200 milliseconds by using the options structure.

manualorder.EMSX_SEQUENCE = int32(events.EMSX_SEQUENCE);
options.timeOut = 200;
events = manualFill(c,manualorder,options)
events =

  struct with fields:

    EMSX_SEQUENCE: 354646
    MESSAGE: 'Order Filled'

events is a structure that contains these fields:

  • EMSX_SEQUENCE — Bloomberg EMSX order number

  • MESSAGE — Bloomberg EMSX message

Close the Bloomberg EMSX connection.

close(c)

Input Arguments

collapse all

Bloomberg EMSX service connection, specified as a bloombergEMSX object.

Order request, specified as a structure that contains the EMSX_SEQUENCE field. This field contains the order numbers. Convert the order numbers to a 32-bit signed integer by using int32.

Example: int32(123456)

Data Types: struct

Timeout value, specified as a nonnegative integer. This integer denotes the time, in milliseconds, that the event handler listens to the event queue for each iteration of the code. The event handler can be a default or custom event handler.

Data Types: double

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

For example, specify using a custom event handler and a timeout value of 200 milliseconds.

options.useDefaultEventHandler = false;
options.timeOut = 200;

Data Types: struct

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.

Version History

Introduced in R2021a