How to retreive any data using API which is using GRSUM function in excel?

How to retreive any data using API which is using GRSUM function in excel?

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @avinash.sonde

    Thank you for reaching out to us.

    Please refer to the following discussion.

    You can try it with the LSEG Data Library for Python with ld.get_data method.

  • @Jirapongse Thank you for checking.

    I tried something similar to what was mentioned there: 

    today = datetime.today().strftime('%Y-%m-%d')

    df_1 = ld.get_history(universe=["BHP.AX" ,"RIO.AX","FMG.AX","S32.AX","SAR.AX","ILU.AX","OZL.AX","IGO.AX","WHC.AX"],fields = ["GRSUM(TR.EVtoEBITDTAMean)"],parameters={'SDate': '2001-01-05','EDate': today,'Frq':'W','Curn':'USD',"Period":'NTM'}) 

    This however gives an error that : 

    LDError: The 'TR.EVTOEBITDTAMEAN' is unrecognized. Requested universes: ['BHP.AX', 'RIO.AX', 'FMG.AX', 'S32.AX', 'SAR.AX', 'ILU.AX', 'OZL.AX', 'IGO.AX', 'WHC.AX']. Requested fields: ['GRSUM(TR.EVTOEBITDTAMEAN)']

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @avinash.sonde

    “TR.EVTOEBITDTAMEAN” appears to be a typo. The correct one could be "TR.EVtoEBITDAMean". Please contact the content team to confirm it.

    Please share the formula used in the Workspace Excel file that returns the required data.

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    The code could be like this:

    import pandas as pd
    
    df = ld.get_data(
        universe=["BHP.AX" ,"RIO.AX","FMG.AX","S32.AX","SAR.AX","ILU.AX","OZL.AX","IGO.AX","WHC.AX"],
        fields =  [        
            "GRSUM(TR.EVtoEBITMean,universe='univ',SDate=2001-01-05, EDate=2025-09-09, Frq=W, Curn=USD)",
            "TR.EVtoEBITMean(SDate=2001-01-05, EDate=2025-09-09, Frq=W).CalcDate"
        ],
        parameters={"SORTD":"calcdate"}) 
    grsum = df[df["Instrument"] == 'n/a'].iloc[:,1].dropna().values.tolist()
    grsum.remove('NaN')
    calc_date = df[df["Calc Date"].notna()]['Calc Date'].unique().tolist()
    calc_date.sort()
    data = {
      "Date": calc_date,
      "GRSUM": grsum
    }
    df = pd.DataFrame(data)
    df