C++ EMA Batch Request
Hi, Currently am looking at the C++ Batch request example from training docs.
370__MarketPrice__Batch
In the example I tried to pass currency RICs in Batch with the help of text file. I am requesting Snapshot request.
But
void AppClient::onRefreshMsg( const RefreshMsg& refreshMsg, const OmmConsumerEvent& )
is returning those currency RICs which have outputs. Is there any method I can call in OnRefreshMsg which can give me all the currency RICS which I passed as an Input. I know
onStatusMsg
is returning all currency RICS but I am not sure how OnRefreshMsg is being call from OnStatusMsg. Also I noticed onupdateMsg is not called in any case am I right?
Best Answer
-
Even if you submit a batch request (one request for several
RICs) EMA calls you back in the onRefreshMsg() methods several times for each individual
RIC. For example if you request “TRI.N” and “IBM.N” (as done in the 370__MarketPrice__Batch
example), EMA calls the onRefreshMsg() method twice, once for “TRI.N” and once
for “IBM.N”. If you’re interested in the values of these two RICs (or all the
currency RICs of your use case) you must wait for EMA to call the onRefreshMsg()
method for all these instruments.Beware that if there’s a problem with an instrument (e.g. if
it doesn’t exist or if you do not have the proper permissions), for this instrument you will not be
called in onRefreshMsg() but in onStatusMsg () only.The onUpdateMsg() method is not called if you request the
currency RICs in snapshot.0
Answers
-
Hi Olivier, Thanks for your inputs. You know that is my problem onRefreshMsg is called for those instruments which have values. How onRefreshMsg is being called from OnstatusMsg();
0 -
I’m not sure to understand your question.
What makes you think that onRefreshMsg is being called
by onStatusMsg?0 -
I suspect that you want to retrieve the instruments values when
EMA first calls you in onStatusMsg().This is not possible I’m afraid. Let me explain why:If you run the 370__MarketPrice__Batch example, you’ll
see that onStatusMsg() is called before any RefreshMsg is received. The item state
onStatusMsg() sends you (“Closed / Ok /
None / 'Batch request acknowledged.”) tells you that your batch request has
been successfully received and acknowledged. It also tells you that the item stream associated to your batch request is closed. That is perfectly normal. Actually, the
data of the instruments you requested (“TRI.N” and “IBM.N”) will come later in
two separated item streams. This is what actually happens when onRefreshMsg()
is called for “TRI.N” and then for “IBM.N” (or vice versa). When EMA calls onStatusMsg() the first time, it doesn’t have the “TRI.N” and “IBM.N” data yet. At this
point there’s nothing you can do to retrieve this data. The only option is to
wait for EMA to call you back in onRefreshMsg() for the two instruments.0 -
Hi @Olivier
Let me tell what I am trying to achieve:
currently I am passing RICS from text file as an input like
Hide Copy CodeAUD=
AUDSW=
AUD2W=
AUD3W=
AED=
AEDSW=
AED2W=
AED3W=
and I need to write csv like this
1.AUD=, 'BID' value of AUD,'GEN_VAL1' of AUDSW=,'GEN_VAL1' of AUD1W=,'GEN_VAL1' of AUD2W=,'GEN_VAL1' of AUD3W=
2.AED=, 'BID' value of AED,'GEN_VAL1' of AEDSW=,'GEN_VAL1' of AED1W=,'GEN_VAL1' of AED2W=,'GEN_VAL1' of AED3W=
This I was able to achieve by running loops if onRefreshMsg was returning every currency RICS. Now I need to store input and output in a separate data structure and need to run compare between them and create the csv as per requirements. Any alternative approach you can suggest?0 -
If the order of the instruments (CSV rows) doesn’t matter,
you can write a new line in your CSV each time you receive a RefreshMsg for a
new instrument. As you subscribed in snapshot, you can do that each time EMA
calls you in onRefreshMsg().If the order of the CSV rows is important, the only solution
I see is to store the instruments values in an in-memory data structure, to sort
it once you received all instruments and to iterate it to write your CSV.0 -
Hi @Olivier
Can you please explain how Batch snapshot request is getting terminated in main().
UInt64 handle = consumer.registerClient(ReqMsg()
.serviceName("ELEKTRON_DD").interestAfterRefresh(false)
.payload(ElementList().addArray(":ItemList",
ricArray).complete()), client);
sleep(1200000);
Right now I am able to store the RICS and its output from Decode Function in a Map but I am struggling to use this Map in main() function.
0 -
Hi @brajesh.shuklafil ,
I’m not sure to understand what you mean by “is getting terminated in main()”.
When you submit your batch snapshot request by calling registerClient(), an item stream is opened for this request. It is only used for sending the request, not for retrieving the values of the instruments you requested. These values will come in separated item streams via the onRefreshMsg() callback (This what I explained in my other answer above). Once your batch request is sent, it is automatically closed. You can just forget it. You do not even have to call unregister() with the handle you received from the registerClient() call.
0 -
Hi Olivier, I am opening this thread again because my program is not working as per requirement it some times returns all the currency response and some times not. Not sure if it is in the code or in APIs that are not returning currency response. In my code I am requesting a currency batch in a text file and storing response in a C++ map and with those responses I am creating a csv file. Please let me if I can send my code files for suggestions.
0 -
Hi @brajesh.shuklafil
Please find my answer in the answer below
0 -
Hi @brajseh.shuklafil
The non-deterministic behavior that you describe in the
comment above makes me think of a multi-threading related issue. Because you
call sleep just after you registered your client callback, I presume that your
application relies on the API_DISPATCH operation model (that is the default EMA
operation model). With this model your application receives events from an EMA
background thread while (in your case) the main thread of the application is
sleeping. This model looks simple in the examples, but it requires your
application to be thread safe and to implement a synchronization mechanism between
your main application thread and the EMA background thread. This is not always
trivial and if it’s not done properly it may result in non-deterministic behaviors
as the one you described.To avoid this kind of issues and if you are not totally comfortable
with multi-threading techniques, I recommend that you use the USER_DISPATCH EMA
operation model instead. This model requires your application to implement a
dispatching loop (that may seem more complicated), but at the end of the day
your application will be single-threaded and this will make your programmer’s life
much simpler.I recommend you to have a look at the 130__MarketPrice__UserDisp
example that demonstrates how to use the USER_DISPATCH operation model. For a
better understanding of this operation model I recommend you to compare the
main function of 130__MarketPrice__UserDisp to the one of the 100__MarketPrice__Streaming
example that uses the API_DISPATCH operation model.I hope this will help in you investigations
0
Categories
- All Categories
- 6 AHS
- 39 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
- 60 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛