The value I am trying to publish is getting round-off how can I resolve it?

nsharma
nsharma Newcomer
edited April 4 in EMA

below is the example of value I am passing and what it is getting published.

Value passed :-

nestedFieldList.add(EmaFactory.createFieldEntry().realFromDouble(22, 5.0, OmmReal.MagnitudeType.EXPONENT_POS_1));

nestedFieldList.add(EmaFactory.createFieldEntry().realFromDouble(25, 4.9, OmmReal.MagnitudeType.EXPONENT_POS_1));

Value received after publish :-

Fid: 22 Name = BID DataType: Real Value: 10.0
Fid: 25 Name = ASK DataType: Real Value: 0.0

Can anyone please let me know how I can resolve it?

Tagged:

Welcome!

It looks like you're new here. Sign in or register to get started.

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @nsharma

    Thank you for reaching out to us.

    Under the hood, the structure of real is:

        boolean     _isBlank;
    int _hint;
    long _value;

    When you set the value 5.0 with the MagnitudeType.EXPONENT_POS_1 (10^1) as a hint, the _value will be 0.5 which is not supported by long. I think it is converted to 1. Therefore, 1 * (10^1) is equal to 10.

    When you set the value 4.9 with the MagnitudeType.EXPONENT_POS_1 (10^1) as a hint, the _value will be 0.49 which is not supported by long. I think it is converted to 0. Therefore, 0 * (10^1) is equal to 0.

    You can try this one:

    EmaFactory.createFieldEntry().realFromDouble(22, 5.0, OmmReal.MagnitudeType.EXPONENT_0);
    
    EmaFactory.createFieldEntry().realFromDouble(25, 4.9, OmmReal.MagnitudeType.EXPONENT_NEG_1);
  • nsharma
    nsharma Newcomer

    Am getting below error when tried your suggestion

    Exception in thread "pool-4-thread-1" Exception Type='OmmInvalidUsageException', Text='Passed in value is null', Error Code='-22'

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    Those code should not throw that exception.

    Can you verify the call stack of that exception?

  • nsharma
    nsharma Newcomer

    Exception in thread "pool-4-thread-1" Exception Type='OmmInvalidUsageException', Text='Passed in value is null', Error Code='-22'
    at com.refinitiv.ema.access.EntryImpl.ommIUExcept(EntryImpl.java:592)
    at com.refinitiv.ema.access.FieldEntryImpl.ascii(FieldEntryImpl.java:577)
    at com.trep.publish.TrepPublishingClient.onRefreshMsg(TrepPublisher.java:98)
    at com.refinitiv.ema.access.LoginCallbackClientConsumer.notifyOnRefreshMsg(LoginCallbackClient.java:992)
    at com.refinitiv.ema.access.LoginItem.handleTimeoutEvent(LoginCallbackClient.java:1137)
    at com.refinitiv.ema.access.TimeoutEvent.execute(TimeoutEvent.java:107)
    at com.refinitiv.ema.access.OmmBaseImpl.rsslReactorDispatchLoop(OmmBaseImpl.java:1894)
    at com.refinitiv.ema.access.OmmBaseImpl.run(OmmBaseImpl.java:2031)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:840)

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    It relates to an ascii value.

    What is in this line com.trep.publish.TrepPublishingClient.onRefreshMsg(TrepPublisher.java:98)?

  • nsharma
    nsharma Newcomer

    nestedFieldList.add(EmaFactory.createFieldEntry().ascii(17, activ));

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @nsharma

    The activ may be null.

    FieldList fieldList = EmaFactory.createFieldList();
    String activ = null;
    fieldList.add(EmaFactory.createFieldEntry().ascii(17, activ));

    The exception is:

    Exception Type='OmmInvalidUsageException', Text='Passed in value is null', Error Code='-22'
    at com.refinitiv.ema.access.EntryImpl.ommIUExcept(EntryImpl.java:605)
    at com.refinitiv.ema.access.FieldEntryImpl.ascii(FieldEntryImpl.java:583)
    at com.refinitiv.ema.examples.training.consumer.series100.ex100_MP_Streaming.Consumer.main(Consumer.java:58)
  • nsharma
    nsharma Newcomer
    edited April 4

    Have removed the activ and tried with the EXPONENT_0 but it is also rounding off the values.

    Can you please suggest any generic solution for all Double fields I am using as below?

    nestedFieldList.add(EmaFactory.createFieldEntry().realFromDouble(22, getBid(), OmmReal.MagnitudeType.EXPONENT_0));

  • nsharma
    nsharma Newcomer

    I Resolved it by passing numeric value.

    Thanks for your time

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    If you want one decimal point, you can use the OmmReal.MagnitudeType.EXPONENT_NEG_1.

    If you want two decimal points, you can use the OmmReal.MagnitudeType.EXPONENT_NEG_2.

  • nsharma
    nsharma Newcomer

    For your information, am trying to use below values of bid & ask

    0.9521

    0.9521_1

    0.6473

    0.6473

    0.04003

    0.04003

    5.55

    5.4

    1.0499

    1.0499

    0.134029

    0.134029

    1.2008

    1.2008

    0.119091

    0.119091

    0.2484

    0.2484

    0.559

    0.559

    0.010806

    0.010806

    0.6138

    0.6138

    0.5319

    0.5319

    0.2386

    0.2386

    0.0923

    0.0923

    0.6913

    0.6913

    0.02733

    0.02733

    0.9261

    0.9261

  • nsharma
    nsharma Newcomer

    For your information, am trying to use below values of bid & ask

    0.9521

    0.9521_1

    0.6473

    0.6473

    0.04003

    0.04003

    5.55

    5.4

    1.0499

    1.0499

    0.134029

    0.134029

    1.2008

    1.2008

    0.119091

    0.119091

    0.2484

    0.2484

    0.559

    0.559

    0.010806

    0.010806

    0.6138

    0.6138

    0.5319

    0.5319

    0.2386

    0.2386

    0.0923

    0.0923

    0.6913

    0.6913

    0.02733

    0.02733

    0.9261

    0.9261

  • nsharma
    nsharma Newcomer

    For your information, am trying to use below values of bid & ask

    0.9521

    0.9521_1

    0.6473

    0.6473

    0.04003

    0.04003

    5.55

    5.4

    1.0499

    1.0499

    0.134029

    0.134029

    1.2008

    1.2008

    0.119091

    0.119091

    0.2484

    0.2484

    0.559

    0.559

    0.010806

    0.010806

    0.6138

    0.6138

    0.5319

    0.5319

    0.2386

    0.2386

    0.0923

    0.0923

    0.6913

    0.6913

    0.02733

    0.02733

    0.9261

    0.9261

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.