Can't get API to work in local script (works in codebook)

Trying to fetch some historical data from Eikon API. I am running the following code:

# Importing libraries
import eikon as ek
import datetime
import pandas as pd
ek.set_app_key('MY APP KEY')
# Defining start time for the data series
start = datetime.datetime.now() - datetime.timedelta(days=1)  # 1 day ago
end = datetime.datetime.now()
# Defining lists with RIC's under interest
rics = ['US10YT=RR']
# Fetching intraday time series data with 1-minute intervals 
data = ek.get_timeseries(rics, start_date=start, end_date=end, interval='minute', fields="CLOSE")
print(data)

This works in the codebook editor in the application, where I get the wanted output. However, when I try to run this script on my local device I get the following error:

2023-12-13 15:56:01,612 P[33280] [MainThread 26372] HTTP request failed: EikonError-Client Error: <!-- IE friendly error message walkround.

if error message from server is less than

512 bytes IE v5+ will use its own error

message instead of the one returned by

server. -->

... Together with a lot of HTML code. It seems like it somehow connects, since I don't get an error, but I don't get the data either. Is there a solution for this?

Best Answer

Answers

  • Hi @jubu,


    Do you have Workspace/Eikon running on the background?


    Bes regards,

    Haykaz

  • Hi @aramyan.h, yes I have.

  • Hi @jubu ,


    This might be a proxy/firewall related issue which you would need to ask your IT team to whitelist. There are two similar questions in the portal, please check this and this. And have a look also at this article on troubleshooting.


    Hope this will help you to resolve the issue.


    Best regards,

    Haykaz

  • Hi @jubu ,

    Before investigating, can the following code be used to check whether the session has been successfully initialised?

    # Importing libraries
    import eikon as ek
    import datetime
    import pandas as pd
    ek.set_app_key('MY APP KEY')
    print(ek.get_desktop_session().get_open_state())
    # Defining start time for the data series
    start = datetime.datetime.now() - datetime.timedelta(days=1) # 1 day ago
    end = datetime.datetime.now()
    # Defining lists with RIC's under interest
    rics = ['US10YT=RR']
    # Fetching intraday time series data with 1-minute intervals
    data = ek.get_timeseries(rics, start_date=start, end_date=end, interval='minute', fields="CLOSE")
    print(data)

    It should display:

    State.Open


  • Hi pf, your code works and it does indeed print "State.Open".