Main Content

Create Bloomberg EMSX Order and Route Using Bloomberg EMSX C++ Interface

This example shows how to connect to Bloomberg® EMSX and create and route a market order using the Bloomberg EMSX C++ interface.

For details about connecting to Bloomberg EMSX and creating orders, see the EMSX API Programmer’s Guide.

Connect to Bloomberg EMSX

Connect to the Bloomberg EMSX test service using the Bloomberg EMSX C++ interface.

c = bloombergEMSX('//blp/emapisvc_beta');
c = 
 
  bloombergEMSX with properties:

    Session: [1×1 datafeed.internal.BLPSession]
    Service: '//blp/emapisvc_beta'
    Ipaddress: "111.222.333.44"
    Port: 8194.00
    User: []

MATLAB® returns c as the connection to the Bloomberg EMSX test service with the following:

  • Bloomberg EMSX session object

  • Bloomberg EMSX service object

  • IP address of the machine running the Bloomberg EMSX test service

  • Port number of the machine running the Bloomberg EMSX test service

Create Market Order Request

Create an order request structure order for a buy market order of 400 shares of IBM®. Specify the broker as EFIX, use any hand instruction, and set the time in force to DAY.

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

Create and Route Market Order

Create and route the market order using the Bloomberg EMSX connection c and order request structure order.

events = createOrderAndRoute(c,order)
events = 
    
    EMSX_SEQUENCE: 335877
    EMSX_ROUTE_ID: 1
          MESSAGE: 'Order created and routed' 

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

  • Bloomberg EMSX order number

  • Bloomberg EMSX route identifier

  • Bloomberg EMSX message

Close Bloomberg EMSX Connection

close(c)

See Also

Objects

Functions

Related Topics

External Websites