question

Upvotes
Accepted
3 4 4 4

How to properly manage EMA orderbook delete action (from market_by_price)?

I receive the delete action from market_by_price in EMA. I checked the map action with

case MapEntry.MapAction.DELETE :

But when I tried to get the price to delete. The field 3427 (ORDER_PRC) is always empty.

Below is the implementation

P.S. The code tag doesn't format the code nicely so I paste as plain text.

private void decodeMap(String ric, com.thomsonreuters.ema.access.Map map) {
int tmpSide = 0;
double tmpPrice = 0;
double tmpSize = 0;
for (MapEntry mapEntry : map) {
if (DataTypes.FIELD_LIST == mapEntry.loadType()) {
FieldList fieldList = mapEntry.fieldList();
for (FieldEntry fieldEntry : fieldList) {
int fid = fieldEntry.fieldId();
if (fieldEntry.code() == Data.DataCode.BLANK) {
// noop
}
else {
switch (fid) {
case 3427: // ORDER PRICE
tmpPrice = fieldEntry.real().asDouble();
break;
case 3428: // ORDER SIDE
tmpSide = fieldEntry.enumValue();
break;
case 3430: // NUMBER OF ORDERS, type: 4, OMMTypes.UINT = int
tmpNumOrder = fieldEntry.uintValue();
break;
case 4356: // ACCUMULATED SIZE
tmpSize = fieldEntry.real().asDouble();
break;
default:
break;
}
}
}
}
if (mapEntry.action() == MapEntry.MapAction.DELETE && tmpPrice != 0d) { // orderbook delete operation
// delete the entry in orderbook
}
}
}

elektronrefinitiv-realtimeelektron-sdkema-apirrtelektron-message-apimarket-by-price
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
18.2k 21 13 21

Hi @steve.lau

You should use "Map Entry KEY" to store your data in a map data structure.

You can delete the entry from map using the same "Map Entry KEY".

You can refer to line 84 on

com.thomsonreuters.ema.examples.training.consumer.series200.example210__MarketByOrder__Streaming example.

System.out.println("Action: " + mapEntry.mapActionAsString() + " key value: " + EmaUtility.asHexString(mapEntry.key().buffer().buffer()));
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
3 4 4 4

Hi @chavalit.jintamalit

Thank you, so you mean the key should be a String to be retrieved by below?

EmaUtility.asHexString(mapEntry.key().buffer().buffer())

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

The EmaUtility.asHexString is optional.

You can convert byte arrays (the value of map key) to any string that you like.

It is the unique identifier to this map entry.

Upvote
25.3k 87 12 25

Hi @steve.lau

You may also find the following article useful - How to Sort & Process Level 2 Orderbook Data

Although the sample source code is C++, the explanations should still be relevant.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

very useful, thanks!

Upvotes
3 4 4 4

Cool, thanks a lot all Gents

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.