Historical 1 minute interval data between 15:30 – 17:30 CET for the last 90 days

Hi Team,


Can you advise what script can we use in Python Eikon API to get the Historical 1 minute interval data between 15:30 – 17:30 CET for the last 90 days.


Sample RICs

ADSGn.DE

AIRG.DE

ALVG.DE

BASFn.DE

BMWG.DE

Best Answer

  • raksina.samasiri
    Answer ✓

    Hi @dianne.palmario and @kenley.macandog123,

    Here's the code

    import eikon as ek
    import pandas as pd
    import datetime

    ek.set_app_key('####YOUR_APP_KEY####')

    rics = ['ADSGn.DE','AIRG.DE','ALVG.DE','BASFn.DE','BMWG.DE']
    df_list = []
    today = datetime.datetime.today()
    start_date = today - datetime.timedelta(90)

    # looping to get the data of 30 days in each call
    while start_date < today:
    end_date = start_date + datetime.timedelta(days=30)
    df = ek.get_timeseries(rics, start_date=start_date, end_date=end_date,interval='minute')
    df_list.append(df)
    start_date = end_date + datetime.timedelta(days=1)

    result = pd.concat(df_list)
    #display(result)

    # filter the time interval
    df_duration = result.iloc[(result.index.time >= datetime.time(14, 30))&(result.index.time <= datetime.time(16, 30))]
    display(df_duration)

    1671531916209.png

    Hope this helps and please let me know in case you have any further questions.

Answers

  • Hi @kenley.macandog123 ,

    Is this what you're looking for?

    First, to get the Historical 1-minute interval data in the last 90 days. However, as there's a limit of an API call in Eikon, so please check this Eikon Data API Usage and Limits Guideline and adjust the start_date, and end_date to not exceed the Eikon Limits.

    import eikon as ek
    import datetime
    from datetime import time
    ek.set_app_key('####YOUR_APP_KEY####')

    df = ek.get_timeseries(['ADSGn.DE','AIRG.DE','ALVG.DE','BASFn.DE','BMWG.DE'],
    start_date=datetime.timedelta(-90),
    end_date=datetime.timedelta(0),
    interval='minute')
    display(df)

    1671468046010.png

    Then after you get the data of the last 90 days, you can filter only the time you're interested, to confirm the timezone of data returned, you may check with the Content team by raising the ticket via MyRefinitiv.

    Hope this helps and please let me know in case you have any further questions.

  • @raksina.samasiri


    Hello, I need to get data between 14:30 to 16:30 GMT Daily.

    This works:

    df1 = df.iloc[df.index.time >= datetime.time(14, 30)]


    But this one does not:

    df1 = df.iloc[df.index.time >= datetime.time(14, 30), df.index.time <= datetime.time(16, 30)]


    Please advise. Thank you.

  • Hi @kenley.macandog123 and @dianne.palmario ,

    as mentioned in this thread that

    get_timeseries method of Eikon Data APIs library always returns timestamps in GMT.

    You may find another way to do the time conversion, in this case, I'm using the time range you used

    df1 = df.iloc[(df.index.time >= datetime.time(14, 30))&(df.index.time <= datetime.time(16, 30))]
    display(df1)

    However, as the data returned is less than latest 90 days due to the Eikon API call limit, you need to call a get_timeseries function in loops with the parts of latest 90 days and then merge the data together.

    1671506924431.png

    Hope this helps and please let me know in case you have any further questions.


  • @raksina.samasiri


    Can you please provide a script that calls a get_timeseries function in loops with the parts of latest 90 days? Like how the script would look like so that we can see more than the latest 90 days limitation?

  • Hi Raksina,


    thx a lot for the script, a nice way to solve the problem.


    I appreciate it a lot.


    Regards,


    Silvio