how to specify list of fields to receive in the request, Java SDK

I want to specify currency for RIC in which I need a price,

how I can do it ?

Also it would be great to specify exact list of fields.

I would appreciate it if you could give me a code snippet

Best Answer

  • Hello @monakhov

    Elektron SDK Java Packages provide example360__MarketPrice__View demonstrating how to use View in EMA Java, the application source code is in <Elektron-SDK_Java_Package> \Java\Ema\Examples\src\main\java\com\thomsonreuters\ema\examples\training\consumer\series300\example360__MarketPrice__View, please modify Consumer.java as the following:

    • Modify .host("localhost:14002").username("user") to be your server host and username
    • After array.add(EmaFactory.createOmmArrayEntry().intValue(25)); line add the currency field id(15) line:
    array.add(EmaFactory.createOmmArrayEntry().intValue(15));//field id of the currency
    • Modify .serviceName("DIRECT_FEED").name("IBM.N") to be your service and your RIC(ASML.AS).

    Then compile and run the example360__MarketPrice__View application.You should see the currency as the example shown below:

    image

Answers

  • Hello @monakhov

    You cannot specify the currency for RIC. The currency is set by
    the feed and cannot be changed by any APIs. After EMA Java sends a RIC request, it will receive
    data of the RIC including the currency generated by the feed and pass to the
    application.

    View feature allows you to specify a list of fields to receive
    in the request. For more details and example snipped source code, please refer
    to Elektron Messaging API (Java) - Batch and View features

    Hope this help.

  • ok, in the response I get only those fields:

    FieldEntry fid="1" name="PROD_PERM" dataType="UInt" value="5926"

    FieldEntry fid="2" name="RDNDISPLAY" dataType="UInt" value="116"
    FieldEntry fid="3" name="DSPLY_NAME" dataType="Rmtes" value="ALLIANZ SE"
    FieldEntry fid="4" name="RDN_EXCHID" dataType="Enum" value="202"
    FieldEntry fid="5" name="TIMACT" dataType="Time" value="07:47:36:000:000:000"
    FieldEntry fid="6" name="TRDPRC_1" dataType="Real" value="206.5"

    nothing more, how I can get currency ?

  • I try to repeat a code snippet from the manual but got an exception:

    long handle = ommConsumer.registerClient(EmaFactory.createReqMsg().serviceName("IDN_INTERVAL_5S").name("ASML.AS").payload(view), priceEventHandler);

    exception:

    2019-05-09 09:43:04,325 INFO [pool-2-thread-9] c.s.c.a.r.a.v.ReutersIntradayClient Subscribing: Subscription[ric=ASML.AS,price=0.0,priceUpdated=false,assetClass=EQUITY,listingId=ListingId[instrumentId=id2,exchange=AS,currency=EUR]]
    2019-05-09 09:43:04,325 ERROR [pool-2-thread-9] c.s.m.e.c.LoggingEventConsumerDecorator Exception while processing message
    java.lang.ClassCastException: class com.thomsonreuters.upa.codec.ArrayImpl cannot be cast to class com.thomsonreuters.upa.codec.ElementListImpl (com.thomsonreuters.upa.codec.ArrayImpl and com.thomsonreuters.upa.codec.ElementListImpl are in unnamed module of loader 'app')
    at com.thomsonreuters.upa.codec.Decoders.decodeElementEntry(Decoders.java:1099)
    at com.thomsonreuters.upa.codec.ElementEntryImpl.decode(ElementEntryImpl.java:122)
    at com.thomsonreuters.ema.access.ReqMsgImpl.checkBatchView(ReqMsgImpl.java:788)
    at com.thomsonreuters.ema.access.ReqMsgImpl.payload(ReqMsgImpl.java:609)
    at ReutersIntradayClient.subscribe(ReutersIntradayClient.java:78)

  • @monakhov

    I have found the same error. Please use the following code instead.

    ElementList view = EmaFactory.createElementList();
    view.add(EmaFactory.createElementEntry().uintValue(EmaRdm.ENAME_VIEW_TYPE, 1));
    view.add(EmaFactory.createElementEntry().array(EmaRdm.ENAME_VIEW_DATA, array));
  • Hi @monakhov, Like others have mentioned, you cannot specify the currency for the returned quote, but it is possible to subscribe to your desired currency pair and recalculate the price in your code (provided user has permission to get FX data).

    E.g: To convert Bid price for ASML.AS = 178.28 EUR into USD, another snapshot request can be made to EUR= to get the currency spot rate.

  • thank you very much it works!