createBasket
Syntax
Description
createBasket(___,'useDefaultEventHandler',false)
creates a basket of Bloomberg EMSX orders 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
creating a basket of orders. This syntax does not have an output argument because the custom
event handler processes the contents of the event queue.
___ = createBasket(
uses the c
,basket
,options
)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
.
Examples
Create Basket of Bloomberg EMSX Orders Using Default Event Handler
Using a Bloomberg EMSX connection, create a basket of Bloomberg EMSX orders.
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 order1
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
.
order1.EMSX_TICKER = 'IBM'; order1.EMSX_AMOUNT = int32(100); order1.EMSX_ORDER_TYPE = 'MKT'; order1.EMSX_BROKER = 'BB'; order1.EMSX_TIF = 'DAY'; order1.EMSX_HAND_INSTRUCTION = 'ANY'; order1.EMSX_SIDE = 'BUY';
Create the order using the Bloomberg EMSX connection c
and order1
.
events = createOrder(c,order1)
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 numberMESSAGE
— Bloomberg EMSX message
Create another order request structure order2
to define the order
parameters. In this case, the code creates a buy market order for 200 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
.
order2.EMSX_TICKER = 'IBM'; order2.EMSX_AMOUNT = int32(200); order2.EMSX_ORDER_TYPE = 'MKT'; order2.EMSX_BROKER = 'BB'; order2.EMSX_TIF = 'DAY'; order2.EMSX_HAND_INSTRUCTION = 'ANY'; order2.EMSX_SIDE = 'BUY';
Create the second order using the Bloomberg EMSX connection c
and order2
.
events = createOrder(c,order2)
events = struct with fields: EMSX_SEQUENCE: 354777 MESSAGE: 'Order created'
Create a basket of the two existing orders. Specify the basket name. Then, specify
the order numbers in the orders
structure.
basket = 'OrderBasket';
orders.EMSX_SEQUENCE = [int32(354646);int32(354777)];
events = createBasket(c,basket,orders)
events = struct with fields: EMSX_SEQUENCE: [2×1 double] MESSAGE: 'Orders added to Basket'
The default event handler processes the events associated with creating a basket of
orders. events
is a structure that contains these fields:
EMSX_SEQUENCE
— Bloomberg EMSX order numbersMESSAGE
— Bloomberg EMSX message
Close the Bloomberg EMSX connection.
close(c)
Create Basket of Bloomberg EMSX Orders Using Timeout Value
Using a Bloomberg EMSX connection, create a basket of Bloomberg EMSX orders. 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 order1
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
.
order1.EMSX_TICKER = 'IBM'; order1.EMSX_AMOUNT = int32(100); order1.EMSX_ORDER_TYPE = 'MKT'; order1.EMSX_BROKER = 'BB'; order1.EMSX_TIF = 'DAY'; order1.EMSX_HAND_INSTRUCTION = 'ANY'; order1.EMSX_SIDE = 'BUY';
Create the order using the Bloomberg EMSX connection c
and order1
.
events = createOrder(c,order1)
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 numberMESSAGE
— Bloomberg EMSX message
Create another order request structure order2
to define the order
parameters. In this case, the code creates a buy market order for 200 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
.
order2.EMSX_TICKER = 'IBM'; order2.EMSX_AMOUNT = int32(200); order2.EMSX_ORDER_TYPE = 'MKT'; order2.EMSX_BROKER = 'BB'; order2.EMSX_TIF = 'DAY'; order2.EMSX_HAND_INSTRUCTION = 'ANY'; order2.EMSX_SIDE = 'BUY';
Create the second order using the Bloomberg EMSX connection c
and order2
.
events = createOrder(c,order2)
events = struct with fields: EMSX_SEQUENCE: 354777 MESSAGE: 'Order created'
Create a basket of the two existing orders. Specify the basket name. Then, specify
the order numbers as the structure orders
. Specify the timeout value
of 200 milliseconds by using the 'timeOut'
flag.
basket = 'OrderBasket'; orders.EMSX_SEQUENCE = [int32(354646);int32(354777)]; events = createBasket(c,basket,orders,'timeOut',200)
events = struct with fields: EMSX_SEQUENCE: [2×1 double] MESSAGE: 'Orders added to Basket'
events
is a structure that contains these fields:
EMSX_SEQUENCE
— Bloomberg EMSX order numbersMESSAGE
— Bloomberg EMSX message
Close the Bloomberg EMSX connection.
close(c)
Create Basket of Bloomberg EMSX Orders Using Custom Event Handler
Using a Bloomberg EMSX connection, create a basket of Bloomberg EMSX orders. 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 order1
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
.
order1.EMSX_TICKER = 'IBM'; order1.EMSX_AMOUNT = int32(100); order1.EMSX_ORDER_TYPE = 'MKT'; order1.EMSX_BROKER = 'BB'; order1.EMSX_TIF = 'DAY'; order1.EMSX_HAND_INSTRUCTION = 'ANY'; order1.EMSX_SIDE = 'BUY';
Create the order using the Bloomberg EMSX connection c
and order1
.
events = createOrder(c,order1)
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 numberMESSAGE
— Bloomberg EMSX message
Create another order request structure order2
to define the order
parameters. In this case, the code creates a buy market order for 200 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
.
order2.EMSX_TICKER = 'IBM'; order2.EMSX_AMOUNT = int32(200); order2.EMSX_ORDER_TYPE = 'MKT'; order2.EMSX_BROKER = 'BB'; order2.EMSX_TIF = 'DAY'; order2.EMSX_HAND_INSTRUCTION = 'ANY'; order2.EMSX_SIDE = 'BUY';
Create the second order using the Bloomberg EMSX connection c
and order2
.
events = createOrder(c,order2)
events = struct with fields: EMSX_SEQUENCE: 354777 MESSAGE: 'Order created'
Create a basket of the two existing orders. Specify the basket name. Then, specify
the order numbers as the structure orders
. 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.
basket = 'OrderBasket'; orders.EMSX_SEQUENCE = [int32(354646);int32(354777)]; createBasket(c,basket,orders,'useDefaultEventHandler',false) processEvent(c)
CreateBasket = { EMSX_SEQUENCE[] = { 354646, 354777 } MESSAGE = 'Orders added to Basket' }
Close the Bloomberg EMSX connection.
close(c)
Create Basket of Bloomberg EMSX Orders Using Options Structure
Using a Bloomberg EMSX connection, create a basket of Bloomberg EMSX orders. 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 order1
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
.
order1.EMSX_TICKER = 'IBM'; order1.EMSX_AMOUNT = int32(100); order1.EMSX_ORDER_TYPE = 'MKT'; order1.EMSX_BROKER = 'BB'; order1.EMSX_TIF = 'DAY'; order1.EMSX_HAND_INSTRUCTION = 'ANY'; order1.EMSX_SIDE = 'BUY';
Create the order using the Bloomberg EMSX connection c
and order1
.
events = createOrder(c,order1)
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 numberMESSAGE
— Bloomberg EMSX message
Create another order request structure order2
to define the order
parameters. In this case, the code creates a buy market order for 200 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
.
order2.EMSX_TICKER = 'IBM'; order2.EMSX_AMOUNT = int32(200); order2.EMSX_ORDER_TYPE = 'MKT'; order2.EMSX_BROKER = 'BB'; order2.EMSX_TIF = 'DAY'; order2.EMSX_HAND_INSTRUCTION = 'ANY'; order2.EMSX_SIDE = 'BUY';
Create the second order using the Bloomberg EMSX connection c
and order2
.
events = createOrder(c,order2)
events = struct with fields: EMSX_SEQUENCE: 354777 MESSAGE: 'Order created'
Create a basket of the two existing orders. Specify the basket name. Then, specify
the order numbers as the structure orders
. Specify an additional
option for a timeout value of 200 milliseconds by using the options
structure.
basket = 'OrderBasket';
orders.EMSX_SEQUENCE = [int32(354646);int32(354777)];
options.timeOut = 200;
events = createBasket(c,basket,orders,options)
events = struct with fields: EMSX_SEQUENCE: [2×1 double] MESSAGE: 'Orders added to Basket'
events
is a structure that contains these fields:
EMSX_SEQUENCE
— Bloomberg EMSX order numbersMESSAGE
— Bloomberg EMSX message
Close the Bloomberg EMSX connection.
close(c)
Input Arguments
c
— Bloomberg EMSX service connection
bloombergEMSX
object
Bloomberg EMSX service connection, specified as a bloombergEMSX
object.
basket
— Basket name
character vector | string scalar
Basket name, specified as a character vector or string scalar.
Example: "OrderBasket"
Data Types: char
| string
order
— Order request
structure
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
— Timeout value
500
milliseconds (default) | nonnegative integer
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
— Options for custom event handler or timeout value
structure
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
events
— Event queue contents
double | 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.
Version History
Introduced in R2021a
See Also
bloombergEMSX
| orders
| routes
| close
| createOrder
| routeOrder
| groupRouteOrder
| modifyOrder
| deleteOrder
| processEvent
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)