question

Upvotes
Accepted
3 0 1 4

AdxRtList.RegisterItems - how can I use ISIN instead of RIC?

Is there a direct way of using an ISIN with AdxRtList.RegisterItems? If not, I assume I'd have to use RSearch to first get the RIC from the ISIN. Could you maybe offer some guidance?

I'm using VBA in MS Access 2016.

eikoneikon-com-apivbams-access
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.

Upvote
Accepted
39.4k 78 11 27

Hi @vik-t

There's a couple of errors in your code.

1. m_dex2mgrADC variable must be declared as Dex2Lib.IDex2Mgr2, not as Dex2Lib.IDex2Mgr

2. To create RData object you need to use Dex2Lib.Dex2Mgr class. So it should be

Set m_rdata = m_dex2mgr.CreateRData(m_cookie)

and not Set m_rdata = m_dex2mgrADC.CreateRData(m_cookie) as in your code.

Once I corrected these two errors I was able to retrieve the data using your code. Oh, and just as a sanity check, your run the example by calling ConnectToEikon procedure, right? Cause if you call Command0_Click then CloseDex procedure will run and destroy RData object before it has a chance to retrieve the data.

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.

Alex, this solved it, thanks a lot. :) The class names are quite confusing with the many 2's. Can I ask a couple of follow-up questions?

  1. The goal of my script is to populate a table with certain reference data, once. So running the procedure should start and end without further intervention. How do I correctly call the code in "CloseDex" so that the event can still be processed first?
  2. What is the general difference between TR and RI codes, and why or when would I prefer one over the other? What did Zhenya mean by "interfaces"? Maybe you can refer me to some documentation on the topic.

1. I don't see the need to call CloseDex procedure at all. It does some cleanup, which is a good practice in general, but in your case it won't make any difference. It will free up an unnoticeable teeny bit of memory, that's all. If your code was creating lots and lots of objects repetitively, then cleanup would be important. In your use case however it's quite unnecessary. This said if for whatever reason you do need to call this procedure, you can call it from the bottom of OnUpdate event handler.

2. RI field names are a legacy scheme that we're phasing out. Unless you run a very old version of Eikon where you cannot use TR field names, you never want to use RI fields in any new applications. The old field name scheme is only preserved for backwards compatibility, and will eventually be retired.

Upvote
4.6k 27 7 22

I would recommend using the reference data API for this, it is called DEX2.

If you have a list of ISINs, you can send it in a RData query (a part of the DEX2) requesting the RIC (either field RI.ID.RIC or TR.RIC depending on the interface).

You can find the usage sample here.

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.

I followed your advice but I'm running into some issues. Could you please elaborate on the interfaces? I'm trying to understand why using RI.ID.RIC works fine but TR.RIC or any other TR.xyz taken from the Data Item Browser hopelessly crashes MS Access with the error message "Run-time error '-2147220965 (8004021b)': Method 'Data' of object 'IRData' failed." As I mentioned, I'm using VBA in MS Access 2016 and I'm connecting to Eikon which is up and running.

Ok, so I followed the information in section 8 of Tutorial 6. Can you help me figure out what's wrong with this code? (See next comment because of comment size limitations..)

Public WithEvents rtConn As EikonDesktopDataAPI
Private m_dex2mgr As Dex2Lib.Dex2Mgr
Private m_dex2mgrADC As Dex2Lib.IDex2Mgr
Private m_cookie As Long
Private WithEvents m_rdata As Dex2Lib.RData


Set rtConn = New EikonDesktopDataAPI
Set m_dex2mgr = rtConn.CreateDex2Mgr
Set m_dex2mgrADC = m_dex2mgr
m_cookie = m_dex2mgrADC.Initialize(DE_MC_ADC_POWERLINK)
Set m_rdata = m_dex2mgrADC.CreateRData(m_cookie)
m_rdata.InstrumentIDList = "TRI.N"
m_rdata.FieldList = "TR.RIC"
m_rdata.Subscribe

Result of the code above is an "Application-defined or object-defined error" in the 'Data' field of m_rdata.

Upvote
39.4k 78 11 27

Hi @vik-t

I don't see any event handling in the code snippet you posted. Are you trying to get the Data property of RData object immediately after calling m_rdata.Subscribe? OnUpdate event of RData class notifies you that the data you requested has been retrieved and is available. You should access the data from the callback for OnUpdate event, as it's done in the tutorial you referenced. If you already access the data from within OnUpdate event handler, then what are the values of DataStatus and Error parameters returned to the event handler procedure?

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.

@Alex Yes, I just summarized the code to fit in the comment. In reality, it is built according to the tutorial, i.e. with an OnUpdate Event. However, since I changed the code from the regular Dex2Mgr to the ADC version, the OnUpdate event is no longer called.. Find the full source code that I use here: Pastebin Link

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.