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
}
}
}

Best Answer

  • 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()));

Answers