How do I use User Tags with Adfin X Real Time in Eikon for Excel VBA?

How do I use User Tags with Adfin X Real Time in Eikon for Excel VBA?

Best Answer

  • DevTrev
    Answer ✓

    User tags are used with the AdxRtList Class of the AdxRtLib library. A user tag is applied when the object and its parameters are set up, and is specific to an isntrument and field. This is very useful, for example, when data is returned for positioning an instrument/field value into a specific place, either in an array or on to a spreadsheet table.

    With the PlVbaAPIs module added to the project, commenting out all sections except the AdfinX Real Time section (to avoid compilation errors), Tools, Reference for the AdfinX Real Time Library (rtx.dll)

    Dim WithEvents myRTList As AdfinXRtLib.AdxRtList
    In the main code;
    Set myRTList = CreateAdxRtList()
    With myRTList
    .Source = "IDN"
    .RegisterItems Array("EUR=", "GBP="), Array("BID", "ASK")

    .UserTag("EUR=", "*") = 1 ' "*" indicates this is the user tag for the RIC itself.
    .UserTag("GBP=", "*") = 2
    .UserTag("EUR=", "BID") = 3 ' ' specific for the BID field for EUR=
    .UserTag("EUR=", "ASK") = 4
    .UserTag("GBP=", "BID") = 5 ' ' specific for the BID field for EUR=
    .UserTag("GBP=", "ASK") = 6

    .StartUpdates RT_MODE_ONUPDATE
    End With

    And for the ONUPDATE event callback;
    m = myRTList.UserTag(ItemName, "*")
    n = myRtList.UserTag(ItemName, "BID") 'etc.