Fama French Factors using Eikon API or RDP

Is there a Refinitiv python library that can be used to compute the Fama-french factors for a market? Specifically looking to create the SMB, HML, RMW and CMA factors for Singapore Market.

Best Answer

  • @rajanraju So I would do this in 2 steps.

    First we need to get all the book closing dates for FY0.

    ff_universe = ['VOD.L','RR.L']
    cols = ['TR.F.PeriodEndDate', 'TR.F.SourceDate']
    params = {'SDate':'0', 'Frq':'FY'}
    mkt_cap, _ = ek.get_data(list(ff_universe), cols, params)

    mkt_cap['MarketCapBookClosing'] = np.nan
    mkt_cap

    1645614008774.png

    Then we need to find the market cap on the period end date:

    for i, row in mkt_cap.iterrows():
        df2,err = ek.get_data(row[0],['TR.CompanyMarketCapitalization'],
                              parameters={'SDate':''+row[1]+''})
        if len(df2):
            mkt_cap['MarketCapBookClosing'][i] = df2['Company Market Capitalization']
        
    mkt_cap

    1645614133919.png

    I hope this can help.

Answers

  • I'd like to know this too. You could always compute them manually with a complete data set of SP stocks. Just keep in mind F/F factors don't translate into real world returns due to transaction costs and liquidity constraints on mutual fund holdings (& much of the supposed FF advantage in the US was from questionable datasets, at least pre-1962).

  • @cockcron Agree re the real world. I was looking to create the factors for specific Asian Markets as these are, unfortunately, not available on Ken French's excellent data library.

  • Hello @rajanraju,

    In my view, this is an excellent question.

    This forum is intended for and can be most helpful to you with Eikon Data API Python usage questions.

    The moderators of the forums are not experts in many types of content that is made available by Refintiiv, nor all of the content available via Eikon/Refinitiv Wworkspace.

    However, whenever we can help- we try our best to do so.

    And I can see how, your question, as it encompasses both content expertise and API usage expertise, it will not be trivial to obtain the clarification from Refinitiv content experts for this type of question, either, although the availability of the content is where, in my view, the answer takes it root.

    To explain, Eikon Data API python in it's essence is the way for retrieve content that is available via Eikon/Refinitiv Workspace, using python.

    In order to delve deeper into your question, let us consider:

    • Are you able to view this content via Eikon? If yes, please share the details
    • If yes, are you able to pinpoint the same content either via Eikon Data Item Browser or via Eikon Formula Builder? If yes, please share the information
    • If not, however, I am afraid this content will not be available via Eikon Data API.

    A subset of RDP services is available via RD library and it's predecessor, RDP library. You will find the available functionality and content exemplified in CodeBook _Examples_. In terms of where I would look for this, thinking under Quantitative Analysis, Advanced Use Cases->Modeling and Equity Research. From my review, I do not see this being offered "out of the box".

  • @zoya faberov Many thanks. I have been liaising with the content folks and find that the information is available. Specifically:

    1. Market capitalisation as of September 30 annually. The Eikon Field is TR.CompanyMarketCapitalization. The complication: for a more accurate representation and avoid data snooping, need the number of shares outstanding (one of TR.F.ShrUsedToCalcBasicEPSTot or TR.F.ComShrOutsTot) as of the last reporting and multiply this by the closing price on September 30.

    2. Book to Market (1/Price to Book):

    1. If the firm’s financial year ended in March, the B/M ratio is computed using the data at the end of March of the same year (Book Value, TR.F.BookValuePerShr, from reported financials and closing price as of March 30.)

    2. If the firm’s financial year ended in any other quarter, compute the B/M ratio using the book value reported in the firm’s financial yearend of year t − 1 and the closing price as of March 30 for year t.


    I provide the universe of RICs each year to get the data. For instance, would loop the following code snippet for each year to get the market capitalisation (in this case, the year is 2020-09-30)


    cols = ['TR.F.PeriodEndDate, TR.F.CompanyMarketCapitalization.date, TR.F.SourceDate, TR.CompanyMarketCapitalization']

    params = {'SDate':'2020-09-30', 'Frq':'CY '}

    mkt_cap, _ = ek.get_data(list(ff_universe), cols, params)


    However, this gives me the MC as of September 30 using the shares outstanding and closing price on that day. Appreciate any help in formulating the most efficient ek.get_data() call.

  • @jason.ramchandani01 many thanks. Very useful. I tried to avoid the 2-step process, but your note shows that there is no other reasonable option forward.

    Much appreciated @zoya faberov @jason.ramchandani01