question

Upvotes
Accepted
15 5 4 9

What is the best way to decode the OMMMsgs received (e.g. to get prices) when subscribing to a RIC using RFA?

treprfarfa-apijava
icon clock
10 |1500

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

1 Answer

Upvote
Accepted
582 8 12 23

Hi @Ethan Wong

Are you asking about decoding Market Price (for trades, indicative quotes) response message payloads?

If so, here's the description of the Market Price response message payload.

Here's a tutorial on Retrieving Level 1 MARKET PRICE Data

Here's an example:

OMMItemEvent ie = (OMMItemEvent)event;
OMMMsg respMsg = ie.getMsg();

if (respMsg.getDataType() != OMMTypes.NO_DATA) {
	if (respMsg.getPayload().getType() == OMMTypes.FIELD_LIST) {	        	
		OMMFieldList fl = (OMMFieldList) respMsg.getPayload();
		
		 for (Iterator iter = ((OMMIterable)fl).iterator(); iter.hasNext();) {
			 OMMEntry entry = (OMMEntry)iter.next();
			 
			 if (entry.getType() == OMMTypes.FIELD_ENTRY) {
				 OMMFieldEntry fe = (OMMFieldEntry)entry;	             
				 System.out.print("FID="+fe.getFieldId() );	                	 
				 if (CURRENT_DICTIONARY != null)  {
					 FidDef fiddef = CURRENT_DICTIONARY.getFidDef(fe.getFieldId());
					 if (fiddef != null) {	    
						 System.out.print(" FieldName="+fiddef.getName() +" FieldValue=");
						 OMMData data = null;
						 if (fe.getDataType() == OMMTypes.UNKNOWN)
							 data = fe.getData(fiddef.getOMMType());
						 else
							 // defined data already has type
							 data = fe.getData();
						 
						 if (data.getType() == OMMTypes.ENUM) {
							 System.out.print(CURRENT_DICTIONARY.expandedValueFor(fiddef.getFieldId(),
																		  ((OMMEnum)data).getValue()));
							 System.out.println(" (" + data + ")");
						 }  else
							 System.out.println(data); 
					 } else {
						 System.out.println(" - Not defined in dictionary");
					 }
				 } // END - if (CURRENT_DICTIONARY != null)
			 }    // FIELD_ENTRY            
		 } // END-FOR	        	
	} // END - if FIELD_LIST
}

icon clock
10 |1500

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

Click below to post an Idea Post Idea