Upgrading to Workspace
We will be discontinuing the Eikon Desktop soon in favour of our next generation data and analytics workflow solution, LSEG Workspace. This page is designed to help you assess any changes you may need to make to programmatic (API) workflows. We also provide resources here to help you make those changes as well.
Upgrading to Workspace
Other related resources
Custom Application COM API Upgrade:
AdxRtContribute
Contents
Contribution - AdxRtContribute.dll
What does AdxRtContribute.dll do?
Prerequisites
VBA Prerequisites
Documentation on using the COM API in the Microsoft Office suite is available here: COM APIs for Microsoft Office. Users were also able to use the COM APIs outside of Microsoft Office suite for example in a standalone app: COM APIs for use in custom applications. A list of the prerequisites in question can be found in the index of this article.
Python Prerequisites
If you are new to Python, don't hesitate to install it on your machine and try it out yourself as outlined in this 3rd party tutorial. Otherwise, you can simply use Codebook as outlined in this Tutorial Video.
Python works with libraries that one can import to use functionalities that are not natively supported by the base coding package. Some popular distributuions of python include many of the popular packages that one could use for various tasks - Anaconda is the most popular such distribution.
Contribution - AdxRtContribute.dll
What does AdxRtContribute.dll do?
VBA
AdxRtContribute is for data contribution either locally (SCOPE:LOCAL) within the instance of Excel (or application if EikonDesktopDataAPI has been used) or on to a server (SCOPE:SERVER) and potentially on to IDN (where the Source Alias of "TRC" should be specified).
AdxRtContribute replicates the RtContribute() function in Eikon for Excel or Eikon - Microsoft Office.
NOTE - Eikon for Excel or Eikon - Microsoft Office should be logged in otherwise the sample VBA code will generate an error "ERROR #360c - AdxRtx : No connection to the platform".
1. Open a new single sheet Excel workbook.
Save As with an appropriate name (e.g. AdxRtSourceList.xls or AdxRtSourceList.xlsm in Office 2007 or higher).
2. Go to the VBE (Visual Basic Editor), ensure the Project Explorer is visible and select the project for the workbook.
<ALT><F11> or Tools, Macro, Visual Basic Editor in Excel 2003 or Developer, Visual Basic in Excel 2007 and above, View, Project Explorer If the Developer header is not visible in Excel 2007 and above, go to the Excel Office Button, select Excel Options (lower right), Popular, and check the 'Show Developer tab in the Ribbon' box.
3. In the VBE, click on File, Import File and import PLVbaApis.bas.
The .bas location is C:\Program Files (x86)\Thomson Reuters\Eikon\Z\Bin (Z may be X or Y, depending on the last Eikon update). The .bas is loaded as a new VB project module, PLVbaApis.
4. In the PLVbaAPis module, comment out the sections which aren't required.
E.G.: when dealing with AdxRtSourceList, part of the real time library AdfinXRtLib, the AdfinX Real Time section can remain uncommented.
5. In the VBE, go Tools, References and ensure that AdfinX Real Time Library is checked.
If it is not in the list the library is called rtx.dll and its location for Eikon 4 is ">C:\Program Files (x86)\Thomson Reuters\Eikon\Z\Bin (Z may be X or Y, depending on the last Eikon update).
6. Create an instance of an AdxRtContribute object using the PLVbaApis function CreateAdxRtContribute.
Set myAdxRtContrib = CreateAdxRtContribute
7. To replicate RtContribute(), when the object has been created set the source, item name and mode (if required) and then contribute the field(s) and value(s) desired.
Public myAdxRtContrib As AdfinXRtLib.AdxRtContribute
Dim fields (1 To 3) As Variant
Dim values (1 To 3) As Variant
Sub myContribution()
Set myAdxRtContrib = CreateAdxRtContribute
If myAdxRtContrib Is Nothing Then MsgBox "Failed to create RtContribute"
With myAdxRtContrib
.Source = "DAVID2"
.ItemName = "TEST_RIC2"
.Mode = "SCOPE:LOCAL UPDATE:CHANGED"
fields (1)="BID"
fields (2)="ASK"
fields (3)="ASKROW80_1"
values(1)=210
values(2)=220
values(3)="ABCDEF"
.Contribute fields, values
'.Contribute "ASK", 220 ' Alternative method of actual names and values'
'.Contribute Array("BID", "ASK"), Array(210, 220) ' Another alternative method'
End With
End Sub
8. RtGet() or RData() can be used in Eikon for Excel to check that the contribution has been successful. If the AdxRtList COM API for real time data retrieval is being used this can be set with the appropriate source and instrument parameters.
9. If no more contributions are required the AdxRtContribute object can be closed (set to Nothing).
Python
You can use the Refinitiv Data Library (RD Lib.) for Python's Content Layer's Pricing stream set of functions to send contributions. Using the Content Layer allows for a better ease of use than the Delivery Layer that nesesitates a better understanindg of APIs' inner workings; with the Content Layer, you have the option to set initialization parameters of the RD Lib. in the _refinitiv-data.config.json_ configuration file. You can find an example version of this configuration file here. This file must be located beside your notebook, in your user folder or in a folder defined by the _RD_LIB_CONFIG_PATH_ environment variable; the _RD_LIB_CONFIG_PATH_ environment variable is the option used by this series of examples; you can find more information about the configuration proccess here. The following code sets this environment variable.
import os
os.environ["RD_LIB_CONFIG_PATH"] = "../../../Configuration"
Next, we will need to import some libraries and modules/functions:
import refinitiv.data as rd
from refinitiv.data.content import pricing
from refinitiv.data.delivery.omm_stream import ContribType
FYI, we advise using the RD Lib. for Python version 1.4.0 or higher:
rd.__version__
Next, let's open our session. The open_session() function creates and open sessions based on the information contained in the refinitiv-data.config.json configuration file. Please edit this file to set the session type and other parameters required for the session you want to open. Note also the format expected in the config file here:
In this config file, you will see that we specified details for the highlighed `platform` & `rtds`; you ought to have already been provided with your contribution RTDS URL and DACS details. We can poit to these details in-code, in Python, in our code:
rd.open_session("platform.rtds")
<refinitiv.data.session.Definition object at 0x111a0ac1100 {name='rtds'}>
Now let's see what we can do. Start with defining the service we aould like to use; here we'll be using `ATS_GLOBAL_1` that is here for example purposes only:
service = "ATS_GLOBAL_1" # Accept contribs on only a curated list of RICs
Now let's try some off-stream contributions:
def display_contrib_response(response):
if response.is_success:
print(f">> Contribution successfully sent.")
else:
if response.nak_code:
print(f'>> Contrib rejected because "{response.nak_message}".')
if response.error:
print(f'>> Contrib failed because "{response.error}\n\t{response.debug}"')
response = rd.content.pricing.contribute(
name = "TESTRIC01",
fields = {
"BID": 5.555,
"ASK": 4.444
},
service=service,
contrib_type=ContribType.REFRESH
)
display_contrib_response(response)
>> Contribution successfully sent.
Now let's try some on-stream contributions by subscrigin to test RICs created for test purposes:
stream = rd.content.pricing.Definition(
universe=["TESTRIC01", "TESTRIC02", "TESTRIC03"],
service=service
).get_stream()
stream.open()
<OpenState.Opened: 'Opened'>
Let's have a look at our contribution:
stream.get_snapshot()
Instrument | RDNDISPLAY | DSPLY_NAME | TIMACT | TRADE_DATE | TRDTIM_1 | BID | ASK | BIDSIZE | ASKSIZE | RECORDTYPE | ROW80_1 | ROW80_2 | ROW80_3 | STOCK_RIC | SPARE_TS1 | QUOTE_DATE | |
0 | TESTRIC01 | 123 | BANK 1 | 57:20.5 | 05/12/2023 | 15:39:00 | 5.555 | 4.444 | 10 | 20 | 209 | 22-Mar-23 | contrib ask and bid | 3 | 25-Jul-21 | 16:30:00 | 01/05/2003 |
1 | TESTRIC02 | 153 | INVESTMENT BANK HKG | 55:51.7 | 05/12/2023 | 15:39:00 | 2.1 | 2.11 | 30 | 2 | 209 | 22-Mar-23 | 25-Jul-22 | 25-Jul-23 | 25-Jul-21 | 11:12:13 | 27/07/2022 |
2 | TESTRIC03 | 123 | BANK 2 | 12:19.4 | 05/12/2023 | 10:12:00 | 6 | 3 | 50 | 60 | 209 | 25-Jul-21 | 25-Jul-22 | 25-Jul-23 | 25-Jul-21 | 11:12:13 | 18/10/2021 |
Let's not foret to close our stream and session:
stream.close()
rd.close_session()
Conclusion
In conclusion, we can see that the Office COM API had many great uses, but limitations too. This was without mentioning its reliability on DLLs that can be heavy to run on a personal machine. But the Refinitiv Python Libraries (RD, RDP and EDAPI) can not only replicate these COM functionalities but enhance them in many instances, the simplest example being the Historical News functionality shown above.
Several COM API functionalities relying on a technology called Adfin was not replicated in Python in this article, but we will investigate them in another article - so stay tuned!
Further Resources
COM APIs: Overview | Quickstart Guide | Documentation | Downloads | Tutorials | Q&A Forum
RD Library: Overview | Quickstart Guide | Documentation | Tutorials | Q&A Forum