When trying to publish value 0.00001 it is publishing as 0
Hello team,
I am using EMA ommConsumer where, when trying to publish value 0.00001 it is publishing as 0.
the code snippet I am using is as below:
nestedFieldList.add(EmaFactory.createFieldEntry().realFromDouble(25123, getBid(), 1));
Can anyone please help me out to understand the same.
Answers
-
Hello @nsharma
Is the FID 25123 defined as REAL64?
I tried publishing this value and able to see the desired result. PS: Its always better to use the enums like
EXPONENT_NEG_13
instead of 1.fieldList.add(EmaFactory.createFieldEntry().realFromDouble(21, 0.00001, 1)); …
and the result in the consumer -
Service Name: DIRECT_FEED Item State: Open / Ok / None / 'Refresh Completed' DSPLY_NAME(3): abc CURRENCY(15): 840 HST_CLOSE(21): 0.0000100000000 . .
You can also turn on the OMM logging in the SDK to see the raw messages being sent and received.
1 -
Hello @Gurpreet
Thanks for the reply….
FID 25123 is defined as Double.
and yes, I have tried using the EXPONENT_NEG_13 previously it was rounding off the values due to which I tried 1 in that place and tried and it was working as expected but don't know how again it rounded off for 0.00001 to 0.
Thanks!!!!!
0 -
Real and Double are distinct data types.
If FID 25123 is defined as Double, you need to use EmaFactory.createFieldEntry().doubleValue(int fieldId, double value) method instead.
0 -
Thanks @Jirapongse have done the changes as you mentioned will test and let you know the outcome.
Hope it will not round-off the any values….
Thanks again for the quick help!!!!!!
0 -
@Jirapongse I want to publish the value 0.000001 but not hard coded if I am storing it as double then double is rounding off to 0.0 is there any other method like doubleValue(int feildId, double arg) where we can store the 0.000001 in that variable and publish it to TREP?
0 -
Is it publishing (Interactive Provider or Non-Interactive Provider) or posting (OMM Consumer)?
0 -
It is Posting (OMM Consumer)
0 -
How did you define this 25123 field in a data dictionary file (RDMFieldDictionary)?
According to this Publish Custom Data via Refinitiv Real-Time Distribution System by EMA article, you need to use the negative FIDs for your custom fields.
0 -
Hello @Jirapongse I have given as an example but the issue I am getting is in ASK, BID field with id 25, 22 respectively.
Can you please let me know how I can publish 0.000001 other than doubleValue and realFromDouble methods as by storing in double variable it is rounding-off which I don't need.
0 -
You need to try this one by specifying a hint value.
nestedFieldList.add(EmaFactory.createFieldEntry().realFromDouble(22, 0.000001, OmmReal.MagnitudeType.EXPONENT_NEG_6));
0 -
@Jirapongse This is hard coded but I don't want to do hardcode need to store in some variable and pass that variable.
0 -
I checked the code. If the hint is not specified, it will useOmmReal.MagnitudeType.EXPONENT_0.
public FieldEntry realFromDouble(int fieldId, double value)
{
return realFromDouble(fieldId, value, OmmReal.MagnitudeType.EXPONENT_0);
}Due to the structure of REAL, the 0.00001 will be converted to long which is zero.
boolean _isBlank;
int _hint;
long _value;0 -
@Jirapongse where to specify the _hint; to not converting to long
0 -
The structure of real requires long and hint.
0 -
How can I achieve this? @Jirapongse
0 -
@nsharma
Covert a double to a string and count the number of digits after a decimal point. Then, use the number of digits to calculate a hint. For example:import java.text.DecimalFormatSymbols;
import java.text.DecimalFormat;
public int countDecimalDigits(double number) {
DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US);
DecimalFormat df = new DecimalFormat("#.###############", symbols);
String s = df.format(number);
int decimalPointIndex = s.indexOf('.');
if (decimalPointIndex == -1) {
// No decimal point, so 0 digits after it
return 0;
} else {
// Subtract 1 from the length to account for the decimal point itself
return s.length() - decimalPointIndex - 1;
}
}
…
…
nestedFieldList.add(EmaFactory.createFieldEntry().realFromDouble(22, 0.000001, 14-countDecimalDigits(0.000001)));
nestedFieldList.add(EmaFactory.createFieldEntry().realFromDouble(25, 0.00001, 14-countDecimalDigits(0.00001)));0 -
@Jirapongse again you have hardcoded value I need to pass the value into the variable not the hardcoded value
0 -
double BidVal = 0.000001;
double AskVal = 0.00001;
nestedFieldList.add(EmaFactory.createFieldEntry().realFromDouble(22, BidVal, 14-countDecimalDigits(BidVal)));
nestedFieldList.add(EmaFactory.createFieldEntry().realFromDouble(25, AskVal, 14-countDecimalDigits(AskVal)));0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 37 Alpha
- 167 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 712 Datastream
- 1.5K DSS
- 638 Eikon COM
- 5.3K Eikon Data APIs
- 19 Electronic Trading
- 1 Generic FIX
- 7 Local Bank Node API
- 11 Trading API
- 3K Elektron
- 1.5K EMA
- 260 ETA
- 572 WebSocket API
- 42 FX Venues
- 16 FX Market Data
- 2 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 26 Messenger Bot
- 5 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 285 Open PermID
- 47 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 25 RDMS
- 2.3K Refinitiv Data Platform
- 19 CFS Bulk File/TM3
- 935 Refinitiv Data Platform Libraries
- 5 LSEG Due Diligence
- 1 LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 12 World-Check Customer Risk Screener
- World-Check On Demand
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 46 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 126 Open DACS
- 1.1K RFA
- 108 UPA
- 197 TREP Infrastructure
- 232 TRKD
- 925 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 106 Workspace SDK
- 11 Element Framework
- 5 Grid
- 19 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛