problem with getting data with python

every time i run this code:

import eikon as ek

ek.set_app_key("my_app_key")

df = ek.get_timeseries(["COMI.CA"],
start_date="2016-01-01",
end_date="2016-01-10")
print(df.head())

i recive this error

]: runfile('D:/my drive/Python Projects/eikon/test001.py', wdir='D:/my drive/Python Projects/eikon')
Error on checking port 9000 : HTTPConnectionPool(host='localhost', port=9000): Max retries exceeded with url: /api/v1/data (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002664A5BEB70>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))
Error on checking port 9000 : HTTPConnectionPool(host='localhost', port=9000): Max retries exceeded with url: /api/v1/data (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002664A5BE748>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))
Error on checking port 36036 : HTTPConnectionPool(host='localhost', port=36036): Max retries exceeded with url: /api/v1/data (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002664A5BE6D8>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))
Error on handshake port None : Failed to parse: localhost:None
Port number was not identified.
Check if Eikon Desktop or Eikon API Proxy is running.
Traceback (most recent call last):
File "<ipython-input-6-816572c984fb>", line 1, in <module>
runfile('D:/my drive/Python Projects/eikon/test001.py', wdir='D:/my drive/Python Projects/eikon')
File "C:\Users\MArmia\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "C:\Users\MArmia\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "D:/my drive/Python Projects/eikon/test001.py", line 3, in <module>
ek.set_app_key("af6ed7495e654418af715318c4d90a9afd864f31")
File "C:\Users\MArmia\Anaconda3\lib\site-packages\eikon\Profile.py", line 48, in set_app_key
get_profile().set_app_key(app_key)
File "C:\Users\MArmia\Anaconda3\lib\site-packages\eikon\Profile.py", line 207, in set_app_key
self.check_profile()
File "C:\Users\MArmia\Anaconda3\lib\site-packages\eikon\Profile.py", line 322, in check_profile
raise EikonError(-1, 'Port number was not identified. Check if Eikon Desktop or Eikon API Proxy is running.')
NameError: name 'EikonError' is not defined

Best Answer

  • Alex Putkov.1
    Alex Putkov.1 ✭✭✭✭✭
    Answer ✓

    @michael.armia
    It appears that you're not a Refinitiv customer. You're a customer of the company named Metastock using their product named Metastock Xenith, which includes a low tier variant of Eikon. Metastock Xenith users are not entitled to Eikon Data APIs. If you'd like to use Eikon Data APIs, you need to subscribe to a higher tier Eikon variant from Refinitiv. You cannot get access to Eikon Data APIs through Metastock.

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @michael.armia

    I get the same error if Eikon Desktop or Eikon API Proxy isn't running on the machine.

    image

    Please make sure that Eikon Desktop or Eikon API Proxy is running properly on the same machine. Eikon Data API needs to connect to Eikon Desktop or Eikon API Proxy running on the same machine in order to work properly.

  • Dear @Jirapongse than;s for your response i am already running Eikon Desktop but i still receive the same error

  • Alex Putkov.1
    Alex Putkov.1 ✭✭✭✭✭

    @michael.armia
    From the trace you included it looks like Eikon API Proxy, which is embedded in Eikon Desktop application, is not running on the machine where your Python script is executed. Could you confirm that you indeed are running Eikon Desktop (and not Eikon Web) on the same machine where your Python scripts are running and that Eikon Desktop is up and signed in at the time the script is executed? Can you see if the following file exists on your machine and what the content is in this file? You can open the file with a text editor like Notepad. It should contain the single number (typically 9000), which is the port number Eikon API Proxy is listening on. The file is created on the startup of Eikon.
    %APPDATA%\Thomson Reuters\Eikon API Proxy\.portInUse

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @michael.armia

    I have created a PowerShell script to verify the basic environment for Eikon Data API, such as Eikon Processes, listening ports, PortInUse file, and connection. Please run the script and share the output.txt file.

    checkeikondataapips1.txt

    Please rename it to checkeikondataapi.ps1 and run it in the PowerShell command line.

    image

  • @jirapongse.phuriphanvichai

    i received this error:

    PS C:\Users\MArmia\Desktop> .\checkeikondataapi.ps1
    .\checkeikondataapi.ps1 : File C:\Users\MArmia\Desktop\checkeikondataapi.ps1 cannot be loaded
    because running scripts is disabled on this system. For more information, see
    about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
    At line:1 char:1
    + .\checkeikondataapi.ps1
    + ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @michael.armia

    You need to run the PowerShell command as Administrator to change the policy and then use the following command.

     Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope LocalMachine

    Next, you can run the script.

    Finally, you may need to change it back to Undefined.

    Set-ExecutionPolicy -ExecutionPolicy Undefined -Scope LocalMachine
  • 1. List all Eikon processes
    ===========================

    Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
    ------- ------ ----- ----- ------ -- -- -----------
    1064 52 30408 60120 2.97 5808 3 Eikon
    773 43 45840 55208 3.91 1872 3 EikonBox
    915 44 20020 50840 1.17 3052 3 EikonBox
    731 57 43932 62672 1.52 3996 3 EikonBox
    503 33 31592 44808 0.89 13648 3 EikonBox
    385 33 32460 51900 0.53 13844 3 EikonBox
    408 68 17132 25272 0.48 17328 3 EikonBox
    751 78 64524 79868 2.41 17984 3 EikonBox
    460 39 50204 65080 0.95 21548 3 EikonBox
    1023 78 62976 79552 1.05 2352 3 EikonBoxNet
    1658 74 73036 87588 5.00 6664 3 EikonBoxNet
    805 54 62336 71132 1.97 12652 3 EikonBoxNet
    820 51 39848 58040 1.56 16860 3 EikonBoxNet
    Process: Eikon.exe



    ProcessId CommandLine
    --------- -----------
    5808 "C:\Program Files (x86)\Thomson Reuters\Eikon\Y\Bin\Eikon.exe" -background


    Process: EikonBox.exe

    ProcessId CommandLine
    --------- -----------
    17328 "C:\Program Files (x86)\Thomson Reuters\Eikon\Y\Bin\EikonBox.exe" -pa -a --pid=5808 --pa-inactive
    --pa-version=9.47.0.108 --pa-path="C:\Program Files (x86)\Thomson
    Reuters\Eikon\Y\Bin\Apps\THOMSONREUTERS.EIKON.PROXY\0.0.0.0"
    1872 "C:\Program Files (x86)\Thomson Reuters\Eikon\Y\Bin\EikonBox.exe" -al -a -cp
    "C:\Users\MArmia\AppData\Local\Thomson Reuters\Eikon User\Cache" -p AppLibAgent -g
    5E0DC8E2-B9C3-4B0A-BD24-A4FF0606678B -e 5808
    3052 "C:\Program Files (x86)\Thomson Reuters\Eikon\Y\Bin\EikonBox.exe" -v3 --pid=5808
    --guid=EikonViewer.Singleton.9.47.0.108 --pipeid=EikonViewer.Singleton.9.47.0.108 --starterpid=5808
    --device-scale-factor=1 --lang=en-US --disable-gpu-process-prelaunch --disable-gpu-watchdog
    --child-clean-exit --process-per-site --disable-spell-checking --proxy-bypass-list=http://localhost:8043
    13648 "C:\Program Files (x86)\Thomson Reuters\Eikon\Y\Bin\EikonBox.exe" -v3 -v3 --type=gpu-process
    --disable-gpu-watchdog --no-sandbox --log-file="C:\Program Files (x86)\Thomson
    Reuters\Eikon\Y\Bin\debug.log" --log-severity=disable --user-agent="Mozilla/5.0 (Windows NT 6.1)
    AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.3071.0.0 EikonViewer/59.3071.0.0 Safari/537.36" /prefetch:2
    --pid=5808 --guid=EikonViewer.Singleton.9.47.0.108 --pipeid=EikonViewer.Singleton.9.47.0.108
    --starterpid=5808 --disable-direct-composition --supports-dual-gpus=false
    --gpu-driver-bug-workarounds=7,10,11,19,20,21,24,43,63,76
    --disable-gl-extensions="GL_KHR_blend_equation_advanced GL_KHR_blend_equation_advanced_coherent"
    --gpu-vendor-id=0x8086 --gpu-device-id=0x5917 --gpu-driver-vendor="Intel Corporation"
    --gpu-driver-version=23.20.16.4973 --gpu-driver-date=2-28-2018 --log-file="C:\Program Files (x86)\Thomson
    Reuters\Eikon\Y\Bin\debug.log" --log-severity=disable --user-agent="Mozilla/5.0 (Windows NT 6.1)
    AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.3071.0.0 EikonViewer/59.3071.0.0 Safari/537.36"
    --lang=en-US --pid=5808 --guid=EikonViewer.Singleton.9.47.0.108 --pipeid=EikonViewer.Singleton.9.47.0.108
    --starterpid=5808 --child-clean-exit --service-request-channel-token=14CFD219499821B2C89295440D7E89DC
    --mojo-platform-channel-handle=1980
    3996 "C:\Program Files (x86)\Thomson Reuters\Eikon\Y\Bin\EikonBox.exe" -tsi -a -eikonpid=5808
    -EikonProcessId=5808 -HwndComInterop=0x1 -ll=2 -perfLevel=0 -context="C:\Users\MArmia\AppData\Local\Thomson
    Reuters\Eikon User\Cache\LibraryCache\Apps\THOMSONREUTERS.EIKON.TSI6\6.4.2013.44564\"
    17984 "C:\Program Files (x86)\Thomson Reuters\Eikon\Y\Bin\EikonBox.exe" -pixl -context="C:\Program Files
    (x86)\Thomson Reuters\Eikon\Y\Bin\Apps\THOMSONREUTERS.REALTIME.PIXLALLPROTOCOLS\0.0.0.0" -a 3996
    13844 "C:\Program Files (x86)\Thomson Reuters\Eikon\Y\Bin\EikonBox.exe" -v3 --type=renderer --js-flags=--expose-gc
    --no-sandbox --child-clean-exit --primordial-pipe-token=70D9C30D15078080F5A8064477476C39
    --log-file="C:\Program Files (x86)\Thomson Reuters\Eikon\Y\Bin\debug.log" --log-severity=disable
    --user-agent="Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.3071.0.0
    EikonViewer/59.3071.0.0 Safari/537.36" --disable-spell-checking /prefetch:1 --lang=en-US --pid=5808
    --guid=EikonViewer.Singleton.9.47.0.108 --pipeid=EikonViewer.Singleton.9.47.0.108 --starterpid=5808
    --enable-pinch --device-scale-factor=1 --num-raster-threads=4 --enable-main-frame-before-activation --content
    -image-texture-target=0,0,3553;0,1,3553;0,2,3553;0,3,3553;0,4,3553;0,5,3553;0,6,3553;0,7,3553;0,8,3553;0,9,35
    53;0,10,3553;0,11,3553;0,12,3553;0,13,3553;0,14,3553;0,15,3553;0,16,3553;1,0,3553;1,1,3553;1,2,3553;1,3,3553;
    1,4,3553;1,5,3553;1,6,3553;1,7,3553;1,8,3553;1,9,3553;1,10,3553;1,11,3553;1,12,3553;1,13,3553;1,14,3553;1,15,
    3553;1,16,3553;2,0,3553;2,1,3553;2,2,3553;2,3,3553;2,4,3553;2,5,3553;2,6,3553;2,7,3553;2,8,3553;2,9,3553;2,10
    ,3553;2,11,3553;2,12,3553;2,13,3553;2,14,3553;2,15,3553;2,16,3553;3,0,3553;3,1,3553;3,2,3553;3,3,3553;3,4,355
    3;3,5,3553;3,6,3553;3,7,3553;3,8,3553;3,9,3553;3,10,3553;3,11,3553;3,12,3553;3,13,3553;3,14,3553;3,15,3553;3,
    16,3553;4,0,3553;4,1,3553;4,2,3553;4,3,3553;4,4,3553;4,5,3553;4,6,3553;4,7,3553;4,8,3553;4,9,3553;4,10,3553;4
    ,11,3553;4,12,3553;4,13,3553;4,14,3553;4,15,3553;4,16,3553
    --service-request-channel-token=70D9C30D15078080F5A8064477476C39 --renderer-client-id=3
    --mojo-platform-channel-handle=2436
    21548 "C:\Program Files (x86)\Thomson Reuters\Eikon\Y\Bin\EikonBox.exe" -v3 --type=renderer --js-flags=--expose-gc
    --no-sandbox --child-clean-exit --primordial-pipe-token=604202AEFEAF6B12A047718B28A8EEA6
    --log-file="C:\Program Files (x86)\Thomson Reuters\Eikon\Y\Bin\debug.log" --log-severity=disable
    --user-agent="Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.3071.0.0
    EikonViewer/59.3071.0.0 Safari/537.36" --disable-spell-checking /prefetch:1 --lang=en-US --pid=5808
    --guid=EikonViewer.Singleton.9.47.0.108 --pipeid=EikonViewer.Singleton.9.47.0.108 --starterpid=5808
    --enable-pinch --device-scale-factor=1 --num-raster-threads=4 --enable-main-frame-before-activation --content
    -image-texture-target=0,0,3553;0,1,3553;0,2,3553;0,3,3553;0,4,3553;0,5,3553;0,6,3553;0,7,3553;0,8,3553;0,9,35
    53;0,10,3553;0,11,3553;0,12,3553;0,13,3553;0,14,3553;0,15,3553;0,16,3553;1,0,3553;1,1,3553;1,2,3553;1,3,3553;
    1,4,3553;1,5,3553;1,6,3553;1,7,3553;1,8,3553;1,9,3553;1,10,3553;1,11,3553;1,12,3553;1,13,3553;1,14,3553;1,15,
    3553;1,16,3553;2,0,3553;2,1,3553;2,2,3553;2,3,3553;2,4,3553;2,5,3553;2,6,3553;2,7,3553;2,8,3553;2,9,3553;2,10
    ,3553;2,11,3553;2,12,3553;2,13,3553;2,14,3553;2,15,3553;2,16,3553;3,0,3553;3,1,3553;3,2,3553;3,3,3553;3,4,355
    3;3,5,3553;3,6,3553;3,7,3553;3,8,3553;3,9,3553;3,10,3553;3,11,3553;3,12,3553;3,13,3553;3,14,3553;3,15,3553;3,
    16,3553;4,0,3553;4,1,3553;4,2,3553;4,3,3553;4,4,3553;4,5,3553;4,6,3553;4,7,3553;4,8,3553;4,9,3553;4,10,3553;4
    ,11,3553;4,12,3553;4,13,3553;4,14,3553;4,15,3553;4,16,3553
    --service-request-channel-token=604202AEFEAF6B12A047718B28A8EEA6 --renderer-client-id=4
    --mojo-platform-channel-handle=2584


    Process: EikonBoxNet.exe

    ProcessId CommandLine
    --------- -----------
    16860 "C:\Program Files (x86)\Thomson Reuters\Eikon\Y\Bin\EikonBoxNet.exe" -b -a -EikonPipe true -EikonPipeId 5808
    -EikonProcessId 5808 -HwndComInterop 0x1 -AffinityName
    singleInstance[THOMSONREUTERS.EIKON.STARTERNET]_08A9D1C8 -Context "C:\Program Files (x86)\Thomson
    Reuters\Eikon\Y\Bin\Apps\THOMSONREUTERS.EIKON.STARTERNET\0.0.0.0" -DelayInitKobraProvider true /prefetch:4
    6664 "C:\Program Files (x86)\Thomson Reuters\Eikon\Y\Bin\EikonBoxNet.exe" -b -a -EikonPipe true -EikonPipeId 5808
    -EikonProcessId 5808 -HwndComInterop 0x1 -AffinityName
    singleInstance[TR.FLOATINGTOOLBAR.MANAGEDCONTAINERSERVICE]_42931033 -Context
    "C:\Users\MArmia\AppData\Local\Thomson Reuters\Eikon
    User\Cache\LibraryCache\Apps\THOMSONREUTERS.EIKON.FLOATINGTOOLBAR\4.84.0.2"
    "-manifest=C:\Users\MArmia\AppData\Local\Thomson Reuters\Eikon
    User\Cache\LibraryCache\9.0.47109_R12-959837__EikonContainer.dll.manifest
    12652 "C:\Program Files (x86)\Thomson Reuters\Eikon\Y\Bin\EikonBoxNet.exe" -b -a -EikonPipe true -EikonPipeId 5808
    -EikonProcessId 6664 -HwndComInterop 0x1 -AffinityName
    singleInstance[THOMSONREUTERS.EIKON.OPSCONSOLE]_62724554 -Context "C:\Users\MArmia\AppData\Local\Thomson
    Reuters\Eikon User\Cache\LibraryCache\Apps\THOMSONREUTERS.EIKON.OPSCONSOLE\4.0.17.5"
    2352 "C:\Program Files (x86)\Thomson Reuters\Eikon\Y\Bin\EikonBoxNet.exe" -b -a -EikonPipe true -EikonPipeId 5808
    -EikonProcessId 5808 -HwndComInterop 0x1 -AffinityName
    singleInstance[ThomsonReuters.Eikon.UdaService]_49538252 -Context "C:\Users\MArmia\AppData\Local\Thomson
    Reuters\Eikon User\Cache\LibraryCache\Apps\THOMSONREUTERS.EIKON.UDASERVICE\2.10.13.3"
    "-manifest=C:\Users\MArmia\AppData\Local\Thomson Reuters\Eikon
    User\Cache\LibraryCache\9.0.47109_R12-959837__EikonContainer.dll.manifest



    2. List all listening ports of Eikon processes
    ==============================================

    LocalAddress LocalPort State OwningProcess
    ------------ --------- ----- -------------
    127.0.0.1 8088 Listen 3052
    127.0.0.1 8043 Listen 17328
    127.0.0.1 8042 Listen 17328
    127.0.0.1 8000 Listen 17984

    3. Check portInUse file
    =======================
    C:\Users\MArmia\AppData\Roaming\Thomson Reuters\Eikon API Proxy\.portInUse is found
    9000

    4. Verify the connection to TCP Port: 9000
    ======================================
    GET: http://127.0.0.1:9000/sxs/v1
    Exception: Unable to connect to the remote server
    GET: http://127.0.0.1:9000/ping
    Exception: Unable to connect to the remote server
    POST: http://127.0.0.1:9000/api/v1/data
    Exception: Unable to connect to the remote server

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    From the output, there is no Eikon process listening on TCP port 9000. Below is my output.

    image

    The Eikon process that owns this port is Eikonbox.exe (16544).

    image

    The context for this process is THOMSONREUTERS.EIKON.DESKTOPSXSSVC.

    I couldn't find this process on your output. This is why you are unable to use Eikon Data API.

    You may need to restart the machine, run Eikon, and then re-run the script. If there is still no Eikon process listening on TCP port 9000, your account may not have permission to use this service.

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    The output from my machine and new script that prints the creation date of PortInUse file are attached.

    output.txt

    checkeikondataapips1.txt

  • Alex Putkov.1
    Alex Putkov.1 ✭✭✭✭✭

    @michael.armia
    Are you by any chance using Metastock Xenith product? If not, which variant of Eikon do you subscribe to? Could you also check which version of Eikon you're running? You can check the latter by selecting Help - About Thomson Reuters Eikon from the main Eikon menu.

  • @Alex Putkov.1

    My Eikon version is :

    Desktop 4.0.48(4.0.48064)

  • This exception message says you're trying to connect to the same host ( 127.0.0.1 ), while you're stating that your server is running on a different host. This 127.0.0.1 represents a 'loopback' . It allows the computer to communicate with itself via network protocol .

    Dns.GetHostEntry(IPAddress.Loopback).HostName returns the host name of your machine. When you pass a host name to TcpClient , it will resolve it to one or more IP addresses using Dns.GetHostAddresses(hostName) . This includes the public and local IP addresses of your machine (e.g. 192.168.12.10), but not 127.0.0.1 (loopback address). So your client is trying to connect to any of the non-loopback addresses of your machine, while your server is listening only on the loopback address . So, no connection can be established. The solution to this problem is that connect to the same end point your server is listening on.