For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
5 0 0 1

How to integrate ESG data into investment decisions

Hi,


I am reading the research article: How to integrate ESG data into investment decisions.


I do not understand:

df,err = ek.get_data('{}{}({}-01-01)'.format('0#', index, year), fields=['TR.TRESGScore'], parameters={'SDate': '{}-01-01'.format(year), 'Period': 'FY0'})

https://developers.refinitiv.com/en/article-catalog/article/how-integrate-esg-data-investment-decisions

We do not define the "year" before. How to understand the year in this code? When I run the code, python reports errors.


Thanks

eikon-data-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Upvotes
Accepted
24.5k 86 10 22

Hi @c.xue

The full source for the above article is available as a notebook at Example.EikonAPI.Python.DiversityAndInclusion - as per the link at the top and bottom of the article

The code snippet you quote above is actually from a function in the above notebook:

def getDataForYear(year):
    display('Getting data for: {}'.format(year))
    # get index constituents at the begining year
    df,err = ek.get_data('{}{}({}-01-01)'.format('0#', index, year), fields=['TR.TRESGScore'], parameters={'SDate': '{}-01-01'.format(year), 'Period': 'FY0'})
    # filter out the instruments based on ESG ratings
    subset = getSubset(df)
    # get the performance data for this subset
    df2,err = ek.get_data(subset, fields=['TR.CLOSEPRICE.date', 'TR.CLOSEPRICE'], parameters={'SDate': '{}-01-01'.format(year), 'EDate': '{}-01-01'.format(year + 1), 'Frq':'CQ'})
    df2 = df2.dropna()
    # consolidate the price data for instruments
    alphaList = []
    ser = df2['Date'].value_counts()
    for x in ser[ser > 5].index:
        ser = df2.loc[df2['Date'] == x].sum()
        alphaList.append({'Date': x, 'Close Price': ser['Close Price']})
    return alphaList


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.