Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • TREP APIs /
avatar image
Question by josa · Feb 06, 2017 at 01:45 PM · javatrep

Parsing View Response Data

Hello, am having issues parsing trep api response data and would appreciate any help.

Currently, am using view and requesting data for ric "IBM.N". The requested fields are "ASK", and "BID". I would like to extract the BID and ASK data and put them into a map.

I would be grateful for a code snapshot of how to extracted these two fields into a map from the response data.

Regards

People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

2 Replies

  • Sort: 
avatar image
REFINITIV
Best Answer
Answer by Pimchaya.Wongrukun · Feb 07, 2017 at 12:10 AM

Hello @josa

RFA Java package provide the GenericOMMParser which is used to read and initialize dictionaries and parse any OMM message. Hence, you may modify GenericOMMParser to get your preference fields from the response and update the values in the map. The example source code is here:

 //create new method in GenericOMMParser.java to parse data and update map for BID and ASK field
    public static final void parseOMMData(OMMData data, HashMap<String,Double> fieldsMap)
    {
    	if(CURRENT_DICTIONARY==null) //make sure that RDMdictionary is loaded already
    		CURRENT_DICTIONARY = getDictionary(1);
        for (Iterator iter = ((OMMIterable)data).iterator(); iter.hasNext();)
        {
            OMMEntry entry = (OMMEntry)iter.next();
            if(entry.getType()==OMMTypes.FIELD_ENTRY) {
            	
            	OMMFieldEntry fe = (OMMFieldEntry)entry;
            	FidDef fiddef = CURRENT_DICTIONARY.getFidDef(fe.getFieldId());
            	OMMData aValue = null;
            	if(fe.getFieldId() ==22 || fe.getFieldId()==25) {
            		aValue=  fe.getData(fiddef.getOMMType());
            		if(!aValue.isBlank()) {
            			String key;
            			if(fe.getFieldId() ==22)
            				key = "BID";
            			else
            				key = "ASK";
            			fieldsMap.put(key, Double.parseDouble(aValue.toString()));
            		}
            			
            	}
            	
            }
        }
        
    }


//in your application at the method to process data(item events)
public void processEvent(Event event)
    {
        
        OMMItemEvent ie = (OMMItemEvent)event;
        OMMMsg respMsg = ie.getMsg();
      	...
        GenericOMMParser.parseOMMData(respMsg.getPayload(),fieldsMap);
        System.out.println("In the map BID is " + fieldsMap.get("BID"));
        System.out.println("In the map ASK is " + fieldsMap.get("ASK"));
        ...
}
Comment

People who like this

0 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
Lars-at-Addicticks · Feb 07, 2017 at 01:59 AM 0
Share

Also: You may want to consider how you store values of type OMM Real (i.e. BID and ASK fields). Storing them in a Double is one choice (possible loss of precision!) and storing them in a BigDecimal (no loss of precision) is another choice. It all depends on your needs. Sometimes using Double (or double) as in the example above is 'good enough'. Anyway, you'll need to cast the aValue variable in the example to OMMNumeric. This will give you direct translation into double, BigDecimal and so on. No need to first convert to String and then to Double as in the example.

avatar image
Answer by josa · Feb 07, 2017 at 10:17 AM

Thanks very much @Pimchaya.Wongrukun. Will try your code example and let you know if I need any more info.

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
11 People are following this question.

Related Questions

Publishing using NIP ETA library (F10: Not In Cache error when consuming)

What is RDMFieldDictionary_large?

What's input pattern for get TREP data specify by RICs via Speed Guide tool?

Java TREP UPA API - Choosing an Optimal Buffer SIze

Two NIPs publishing on the same service (ADH cache)

  • Feedback
  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Careers
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Calais
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRIT
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • World-Check Data File
  • Explore
  • Tags
  • Questions
  • Badges