Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
3 0 0 1

Dynamically create a list of RICs for the WithRics property

Hello,


I'm writing in C# and trying to determine if it's possible to pull a snapshot (not a subscription) of data for multiple RICs at a time, however I want to determine the list of RICs at runtime. In my testing I've been able to get the below to work without issue.

            realtime.SetupDataRequest()
               .WithRics("AAPL.O", "MSFT.O", "TRN.N","TSLA.O","F")
               .WithFields("OPEN_PRC","ACVOL_1","PCTCHG_YTD")
               .OnDataReceived(DataReceivedCallback)
               .CreateAndSend();

However, what I'd like to do is something like this:

            string rics = "\"AAPL.O\", \"MSFT.O\", \"TRN.N\", \"TSLA.O\", \"F\"";
            realtime.SetupDataRequest()
               .WithRics(rics)
               .WithFields("OPEN_PRC","ACVOL_1","PCTCHG_YTD")
               .OnDataReceived(DataReceivedCallback)
               .CreateAndSend();

Which would allow me to dynamically build the list of RICs at run time. Is something like that possible and if so can someone point me to in the right direction? Thank you very much.

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-api.net
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
80.1k 257 52 75

@xmeadow

You can create a List<string> and then add RICs into that list.

List<string> rics = new List<string>();
rics.Add("AAPL.O");
rics.Add("MSFT.O");
rics.Add("TRN.N");
rics.Add("TSLA.O");
rics.Add("F");
realtime.SetupDataRequest()
    .WithRics(rics)
    .WithFields("OPEN_PRC", "ACVOL_1", "PCTCHG_YTD")
   .OnDataReceived(DataReceivedCallback)
   .CreateAndSend();

Otherwise, you can create a list from a comma-separated string by using the Split method.

string rics = "AAPL.O,MSFT.O,TRN.N,TSLA.O,F";
realtime.SetupDataRequest()
    .WithRics(rics.Split(','))
    .WithFields("OPEN_PRC", "ACVOL_1", "PCTCHG_YTD")
   .OnDataReceived(DataReceivedCallback)
   .CreateAndSend();
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
3 0 0 1

This works great, thank you. I also found that you can pass a string array

string rics[] = new string[5]

But using a dynamic list is even better. Thank you.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.