Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • Elektron /
  • ETA /
avatar image
Question by Paul.Wuethrich2 · Apr 09, 2020 at 04:57 PM · javaETAjava apirealhint

ETA/UPA guidance on using Real w/RealHints

I'm looking for some guidance on using RealHints with Real type in the ETA/UPA Java API (v3.3.0 of the jars)

1) Use case is for publishing to external consumers

2) Storing bid/ask values as Java double types

3) We were initially mapping the double values to Real types using a default RealHints value of EXPONENT_4 resulting in some inadvertent rounding (e.g. 0.12349 -> would result in 0.1235 on the receiving client side):

// ASK

fieldEntry.clear();

dictionaryEntry = dictionary.entry(MarketPriceItem.ASK_FID);

if (dictionaryEntry != null) {

fieldEntry.fieldId(MarketPriceItem.ASK_FID);

fieldEntry.dataType(dictionaryEntry.rwfType());

tempReal.clear();

// Set blank for empty book and wipes

if(mpItem.ASK == -0.0) {

tempReal.blank();

}

else {

tempReal.value(mpItem.ASK, RealHints.EXPONENT_4);

}

ret = fieldEntry.encode(encodeIter, tempReal);

if (ret < CodecReturnCodes.SUCCESS) {

return ret;

}

}

4) We modified the above to use the max value of EXPONENT_14 thinking that this would give provide a margin of safety for variable precision of decimal values. We then began seeing inconsistent & apparently random behavior for instrument bid/ask values that would either be 0 or something along these lines:


a) EXPONENT_14:

DOMAIN: MARKET_PRICE

UPDATE TYPE: UNSPECIFIED

3/DSPLY_NAME: <instrument name>

22/BID: 92233.72036854776

25/ASK: 92233.72036854776

134/MID_PRICE: <blank data>

30/BIDSIZE: <blank data>

31/ASKSIZE: <blank data>

436/BEST_BID1: <blank data>

441/BEST_ASK1: <blank data>

3814/UNDERLYING: <blank data>

16/TRADE_DATE: 8 APR 2020

5/TIMACT: 17:40:23:000:000:000


b) EXPONENT_4 or EXPONENT_8 which is the expected output value


DOMAIN: MARKET_PRICE

State: Open/Ok/None - text: "Item Refresh Completed"

2/RDNDISPLAY: 0

4/RDN_EXCHID: (0)

3/DSPLY_NAME: <instrument name>

22/BID: 192220.0

25/ASK: 197220.0

134/MID_PRICE: <blank data>

30/BIDSIZE: <blank data>

31/ASKSIZE: <blank data>

436/BEST_BID1: <blank data>

441/BEST_ASK1: <blank data>

3814/UNDERLYING: <blank data>

16/TRADE_DATE: 8 APR 2020

5/TIMACT: 15:56:03:000:000:000


5) Switching to EXPONENT_8 has resolved this behavior as of now

6) Feels like our original interpretation of using RealHints was incorrect given the API documentation on the Real type and underlying RealHints table of values. So can someone provide some guidance on using RealHints? Also note, that we could conceivable switch to using Real.value(String) instead of Real.value(double, hint)

thx

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.

3 Replies

  • Sort: 
avatar image
REFINITIV
Best Answer
Answer by jirapongse.phuriphanvichai · Apr 14, 2020 at 07:22 AM

@Paul.Wuethrich2

The code used to convert double to Real is available in GitHub.

           _hint = hint;
            if (value > 0)
                _value = (long)(value * powHintsExp[hint] + 0.5);
            else
                _value = (long)(value * powHintsExp[hint] - 0.5);

When using Real.value(double value, int hint), you need to know the hint. For 0.12349, the hint should be RealHints.EXPONENT_5.

When you see this value (92233.72036854776), it should indicate the calculated value exceeds the max long used in Java (-9,223,372,036,854,775,807 and 9,223,372,036,854,775,808).

Therefore, another option is using Real.value(String value) to convert string to Real.

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.

avatar image
REFINITIV
Answer by Pimchaya.Wongrukun · Apr 14, 2020 at 07:37 AM

Hello @Paul.Wuethrich2

For more details of Real and RealHints, please refer to section 11.2.1 Real in ETA Java Developers Guide

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.

avatar image
Answer by Paul.Wuethrich2 · Apr 23, 2020 at 01:23 PM
Apologies - forgot to reply to this - I was looking for guidance on whether we could 'safely' pick one hint value given the following:


1) We arbitrarily used 4 and then realized we had some scenarios where values were being rounded up.

2) We increased the hint to the max of 14 assuming that it would cover more than adequate precision and this worked for +90% of values until we discovered that some values were way off even though there was no reason for an overflow condition

3) We've since changed the default to 8 and we're no longer seeing any issues


No reply necessary as we will likely just migrate to using string-based interface


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

Chain request via Java ETA API

Anyone use ESDK to get gold price?

Why SEQNUM is in order but QUOTIM_MS is not?

Reactor premature CHANNEL_READY on reconnect

ETA Java source code

  • 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