How can I get historical data for SPX3MO=R using the Python API?

I'm trying to retrieve the historical data for SPX3MO=R using the Python API. CF_CLOSE, CF_LAST fields as available, but they only give me the current data. However, when I open the daily charts I see the historical data is available. Can you please advise?


Sample formula used: ek.get_data("SPX3MO=R", "HST_CLOSE", {'SDate':'2020-04-30'})


I would like to see historical data at the longer date. Looking forward for your help.

Best Answer

  • umer.nalla
    umer.nalla LSEG
    Answer ✓

    Hi @Paco Sebastian.Sunico

    The following provides me with historical data

    ric = 'SPX3MO=R'
    startdate = '2015-01-01T00:00:00'
    enddate = '2020-05-12T00:00:00'
    interval = 'daily'
     
    df = ek.get_timeseries(
            [ric],
            start_date=startdate,
            end_date=enddate,
            interval=interval )
    print(df)

    outputs:

    SPX3MO=R    
    VALUE Date
    2015-01-02 15.37
    2015-01-05 16.74
    2015-01-06 17.53
    2015-01-07 16.45
    2015-01-08 14.97
    ... ...
    2020-05-06 29.86
    2020-05-07 28.00
    2020-05-08 25.70
    2020-05-11 24.70
    2020-05-12 28.22

    You can find more details on the get_timeseries method here

    Note that not all the time intervals + fields listed in the documentation are available for all RICs.

    If you do want to discuss what data is available you can create a Content ticket via MyRefinitiv


Answers