Help with Pipeline Class Factors

Hi guys,I have really been enjoying research mode. I am trying to replicate Benjamin Graham's Fundamentals, but I am struggling with the class factors. Here are my following questions.

1) The Class Debt(CustomFactor) will not display values. I am trying to take Total_Debt/ Current_Assets
2) The Class BV(CustomFactor) tries to compute the book value using an equation I found on investopedia. The output displays a result very small and close to zero. I am trying to not use book-value-per share because it is not in live trading.
3) When I use this code, running in algorithm mode.

myPipe['fin_health']= myPipe['fin_health'].str.strip("D")
myPipe['fin_health']= myPipe['fin_health'].str.strip("C")

It says it has been deprecated. What other code can I use to remove the Bad Letter Grades?

Thank you,

With Love as always, Quantdog

1
Notebook previews are currently unavailable.
1 response

1) Use morningstar.balance_sheet.total_debt instead of 'debt_total'. The 'debt_total' field only shows up on companies which report on a Non-Differentiated Balance Sheet. Which isn't many. Otherwise it's filled in with NaN.

2) The Investopedia article is a bit misleading. You are looking for 'Price to Book Ratio'. This really isn't the current stock price, its the current market capitalization. If you think of it, you need to include shares in there someplace (which market cap does). Back in 2014, AAPL had a 7:1 stock split. Overnight the price of the stock was cut by 1/7. Unless you include outstanding shares somewhere in your calculation, you would infer that the P-B ratio just got cut by 1/7 too (which obviously isn't the case). Use morningstar.valuation.market_cap along with the 'close' price. Also, you may want to take a look at morningstar.valuation_ratios.pb_ratio which doesn't seem to be excluded from live trading. In the attached notebook I included 3 calculations and (maybe not surprising) they reported different values.

3) Do you want to remove the bad letter grade values or the rows with bad letter grades (ie the equities)?. To simply replace the 'C' and 'D' values with something (or nothing) you may want to consider the 'replace' method

myPipe['fin_health'].replace(['C', 'D'], '', inplace=True)



If you want to get the rows with an 'A' or a 'B' grade then consider the 'query' method

healthy_companies = myPipe.query('fin_health == "A" or fin_health == "B"')



I'm a fan of the 'query' method but you could also do it other ways too.

4