EMA Giving scientific notation for certain fields
Moving from RFA to EMA I noticed one of the difference is when it decides to convert the number to scientific notation.
Any possibility to default all fields away from using scientific notation?
Another odd behavior is for volume fields like askSize EMA gives it as 0.0 while rfa gives it as a 0
I know you can use:
EmaFactory.createFieldEntry().real( 6, 11, OmmReal.MagnitudeType.EXPONENT_NEG_2) ;
but we require a lot of fids and would need to declare for each one.
Any help would be appreciated
Using java with ema version 3.6.5.0
Best Answer
-
I checked the code if the power of zero, it will use Double.toString(toDouble()); to convert a double to a string.
if (_value != 0)
{
/* Handles number of decimal places according to the hint value. */
if(RealHints.EXPONENT_14 <= _hint && _hint <= RealHints.EXPONENT_1)
{
return String.format(decimalStringFormat[_hint],toDouble());
}
else
{
return Double.toString(toDouble());
}
}If you would like to change this behavior in the API and you have an RDC contact (Premium Support), you can raise this issue to the API Support team via Contact Premium Support.
Otherwise, you can submit this issue via GitHub.
0
Answers
-
Hi @carl_miller
Are you ensuring the value is not blank prior to processing?
...
if (Data.DataCode.BLANK == fieldEntry.code())
System.out.println(" blank");
else
switch (fieldEntry.loadType())
{
case DataTypes.REAL :
System.out.println(fieldEntry.real().asDouble());
break;
...
}
...0 -
Yes I return blank if its blank
0 -
I have also seen this behavior with an actual value
0 -
I tested ACVOL_1 for index .DJI to recreate the scientific notation for that fid during market hours
0 -
I think this is how Java displays a double value.
I found an answer on StackOverflow. To print a double value without scientific notation, you can use real.asBigDecimal().toPlainString().
FieldEntry fieldEntry;
while (iter.hasNext())
{
fieldEntry = iter.next();
System.out.println("Fid: " + fieldEntry.fieldId() + " Name: " + fieldEntry.name() + " value: " + fieldEntry.load());
if(fieldEntry.fieldId()==32) {
OmmReal real = fieldEntry.real();
System.out.println("mantissa: "+real.mantissa());
System.out.println("magnitude type: "+real.magnitudeTypeAsString());
System.out.println("asDouble: "+real.asDouble());
System.out.println("asBigDecimal.toPlainString: "+real.asBigDecimal().toPlainString());
}
}The output is:
Fid: 32 Name: ACVOL_1 value: 3.53773301E8
mantissa: 353773301
magnitude type: Power of 0
asDouble: 3.53773301E8
asBigDecimal.toPlainString: 353773301I hope this can be of help.
0 -
One side effect of making every real processed through this way would be getting rid of the leading zeros for price fields. Any way to determine if its a price fields vs volume? I could hardcode a fid check, but I would like something a bit more dynamic if possible
0 -
In rfa we just gave the string to the consumer and it was never converted to double. I suppose ema behind the scenes must convert it?
0 -
Hi @carl_miller
Looking at the data dictionary and pulling up a few examples of price fields vs volume, I see this:
ACRONYM DDE ACRONYM FID RIPPLES TO FIELD TYPE LENGTH RWF TYPE RWF LEN
------- ----------- --- ---------- ---------- ------ -------- -------
ACVOL_1 "VOL ACCUM..." 32 NULL INTEGER 15 REAL64 9
TRDPRC_1 "LAST" 6 TRDPRC_2 PRICE 17 REAL64 9
BID "BID" 22 BID_1 PRICE 17 REAL64 9
BIDSIZE "BID SIZE" 30 NULL INTEGER 15 REAL64 9Using the "Field Type" or "Length" might be a suitable way to distinguish.
0 -
Any easy way to check field type inside refreshmsg. It has data type which is giving real. I can grab the data dictionary in a separate flow and use that, but wondering if any prebuilt checks might exist.
0 -
Hi @carl_miller
I was looking at the real() (OmmReal) interface, and it offers a number of other attributes/representations of the data. I'm not sure if you have looked deeper into this, but things I noticed:
fieldEntry.real().asBigDecimal()
Through preliminary tests, I did not notice scientific notation.
0 -
Hi @carl_miller
The only other thing that I noticed that could potentially distinguish price and volume fields is the values coming out of fieldEntry.real().magnitudeType(). I noticed, based on some tests, this value is OmmReal.MagnitudeType.EXPONENT_0 (14) for volume fields. However, this would require deeper investigation.
The other option is to interrogate the data dictionary, based on the field ID, to pull out the "FIELD TYPE" or "LENGTH" properties for the FID. I would have to determine if/how this is possible.
0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛