Value Investing Dashboard with Python Beautiful Soup and Dash Python

This guide will teach you the basics.

Best Brokers…www.


comWe will use Market Watch Balance Sheet and Income Statements links and assign them to variables.

Note here that the ticker refers to the company’s ticker.

Therefore the link to Apple Income statement is https://www.


com/investing/stock/AAPL/financials and the and to Apple Balance Sheet is https://www.


com/investing/stock/AAPL/financials/balance-sheeturlfinancials = 'https://www.


com/investing/stock/'+ticker+'/financials'urlbalancesheet = 'https://www.


com/investing/stock/'+ticker+'/financials/balance-sheet'text_soup_financials = BeautifulSoup(requests.


text,"lxml")text_soup_balancesheet = BeautifulSoup(requests.


text,"lxml")Similar to extracting the company tickers, we also used Beautiful Soup to identify the ratios from the financials and balance sheets url.

We will extract them with by going through all of the siblings of attributes with label texts as the indicators.

# Income Statementfor title in titlesfinancials: if 'EPS (Basic)' in title.

text: epslist.

append ([td.

text for td in title.

findNextSiblings(attrs={'class': 'valueCell'}) if td.

text]) if 'Net Income' in title.

text: netincomelist.

append ([td.

text for td in title.

findNextSiblings(attrs={'class': 'valueCell'}) if td.

text]) if 'Interest Expense' in title.

text: interestexpenselist.

append ([td.

text for td in title.

findNextSiblings(attrs={'class': 'valueCell'}) if td.

text]) if 'EBITDA' in title.

text: ebitdalist.

append ([td.

text for td in title.

findNextSiblings(attrs={'class': 'valueCell'}) if td.

text])# Balance sheettitlesbalancesheet = text_soup_balancesheet.

findAll('td', {'class': 'rowTitle'})equitylist=[]for title in titlesbalancesheet: if 'Total Shareholders' Equity' in title.

text: equitylist.

append( [td.

text for td in title.

findNextSiblings(attrs={'class': 'valueCell'}) if td.

text]) if 'Long-Term Debt' in title.

text: longtermdebtlist.

append( [td.

text for td in title.

findNextSiblings(attrs={'class': 'valueCell'}) if td.

text])We will populate the extracted values into a separate data frame.

df= pd.

DataFrame({'eps': eps,'epsgrowth': epsgrowth,'netincome': netincome,'shareholderequity': shareholderequity,'roa': roa,'longtermdebt': longtermdebt,'interestexpense': interestexpense,'ebitda': ebitda},index=[2013,2014,2015,2016,2017])Result of the extractionsThis dataframe will be dumped into the dash table object as belowCritical Variables and Ratios TableWarning Signs List based on value investing logicWe will then create the eligibilitycheck.

py to iterate through these rules and identify some possible risks given the ratios extracted.

Given list of the companies, find out the feasibility to investBeen in market minimal 10 yearsHave the track records (EPS per year)Have efficiency (ROE > 15%) — Net income / shareholder equityDetermine manipulation (ROA > 7%) — Net income / Total AssetHave small long term debt (Long term debt <5* total income)Low Debt to EquityAbility to pay interest: (Interest Coverage Ratio >3) — EBIT / Interest expensesUsing the generated dataframe above, we will retrieve a list of warningsWarning FlagsDecision Machine based on Marginal Price From Stocks EPSWe will then create the last of our steps by deriving whether the users should buy from the expected Future Values and the marginal values from users’ defined parameters.

Following are the steps that were implemented in futurepricing.

pyDecision making from each company in terms of return rate given the value investing methodologyFind EPS Annual Compounded Growth RateEstimate EPS 10 years from nowEstimate stock price 10 years from now (Stock Price EPS * Average PE)Determine target by price today based on returns(discount rate 15%/20%)Add margin of safety (Safety net 15%)Buy if market price is lower than the marginal priceSell if market price is higher than the marginal priceFrom here, we will generate the following parameters derived from the logic of Sean Seah’s book.

In this functionality, we will allow users inputs such as discount rate and marginal rate.

Discount rate indicated predicted inflation over the period of 5 years, margin calculation rate is the toleration for error.

You add on additional safety net in the case of calculation error.

The more the margin calculation rate, the more risk averse you are or vice versa.

Discount and Margin Calculation Rate at 15% for bothdfprice['peratio'] = findMinimumEPS(stockpricedf,financialreportingdf)dfprice['FV'] = dfprice['futureeps']*dfprice['peratio']dfprice['PV'] = abs(np.

pv(discountrate,years,0,fv=dfprice['FV']))dfprice['marginprice'] = dfprice['PV']*(1-marginrate)dfprice['lastshareprice']=stockpricedf.



values[0]dfprice['decision'] = np.

where((dfprice['lastshareprice']<dfprice['marginprice']),'BUY','SELL')This will generate data frame with the following data and decision (buy/sell)Future Price and Decision Making CalculationIn this case, based on eps growth and pe ratio, you could find the future price and present price valuations.

Added with discount rate and margin rate, you will get margin price.

Since margin price is less than last share price, we could assume that the stocks is currently overpriced even given the tolerated error rate.

Hence the Sell decision.

The opposite also worked for the Buy decisionA very simple logic, but a powerful one to leverage on your stocks purchases.

Of course the caveat is that you should do your due diligence on the qualitative analysis before purchasing the stocks.

ResultAfter developing this tool, I feel the need to test it out.

Therefore in 2017, I decided to buy some stocks using the screenings from this tool.

Buying SkechersSkechers View from Value Investing DashboardAs you could view here, the application marked Skechers as an abnormally high marginalized price.

This means that given 10% discount rate assumption (from economic instability or inflation) and 50% marginal rate assumption (from degree of potential error), we still work the marginal share price to be very high — our valuated price.

Further glimpse at eps growth shows the fast growing nature of Skechers from 2012–2016.

However, at the same time, if you view the long term debt ratio, Skechers’ debt had reduced or stabilized.

Overall, increasing revenue, high growth, and low long term debt is one of the biggest reason why I bought Skechers.

Over one and half a year, I have received 34.

55% stocks price increaseBuying QualcommIn 2017, I received news of Qualcomm being in dispute with Apple.

This made the stocks dropped into 44.

Hence, I tried to use the tool to see if I could extract the information quickly and analyze quantitatively.

After taking a quick look, I realized that Qualcomm gave me a high future value as $115 given the pe ratio and the annual growth rate.

Even when I put 50% as margin rate (I am a very risk averse guy), I could see that the marginal price still fared comfortably from the present share price.

As there are not much warning signs and increase in long term debt except for one year negative growth, I bought Qualcomm.

Over one and half a year, I have received 62.

87% stocks price increase.

Buying GamestopGamestop is my newest investment I made with the value investing dashboard.

It is considered a cigarette butt investing as this is a stocks in declining growth that no investors want — hence, cigarette butt (get it?! Haha).

At the Warning Flags, three warnings were present: that there are negative growth, high long term debt, and small ROE.

However, if you take a look at the decision at the bottom: the application remarked it as Buy.

The reason why is that although the stocks is dropping in lieu with the negative growth, the market valuate the stocks too low: people are too afraid to invest in GameStop.

The rate of declining business is lower than the rate of declining market’s sentiment.

As you could see, even when I put margin rate for 50%, I still saw the margin price ($13) to be higher than the share price ($8).

For that reason, I bought Gamestop expecting for investors to realize this gap, while at the same time, hoping for buyouts.

Up to now, I am losing 7.


Holding 18% Returns of PortfolioUsing this application, I made it a point to first screen, purchase and hold the stocks.

Currently, some of my successful purchases included: Keppel Reits DC, CSE Global Limited, Qualcomm, and Skechers.

With some screened stocks such as Skechers and Qualcomm to be the high performers up to date.

Results: Stocks Portfolio Gain by 18.

53% since 2017As you could see, I am currently managing working portfolio that generated up to date returns of 18% after 1 and a half year of holding.

If dividends are included, then the returns are estimated to be 22%.

Although this is a great return after a year and not much, this is still not long enough to prove the app’s usefulness.

Feel free to try it out and comment below.

Furthermore, I would like to further highlight the important caveat: do your due diligence.

You should still evaluate your stocks by asking about the following qualitative assessment:Advantages in business (product differentiation, branding, low price producer, high switching cost, legal barriers to entry)Ability of foolhardy management (even a fool can run)Avoid price competitive business.

Understand how the business makes revenue.

Lastly, I hope this application or at least my little piece of investing journey could inspire you to innovate.

Feel free to refer the codes for better understanding on how I crunch the number to derive buy/sell action.

Then, please feel free to fork and contribute if there are further improvements you would like to work on.

Everything is up for grab for free!! Please contribute to make it the best open source value investing tool.

Conclusion and Future WorkThis project gave me the opportunities to solve a practical and relevant problem, which many of my finance friends seem to face.

There are many functionalities we could add to improve the user experience, but for now, this application has successfully handled the mentioned core problem of extracting relevant financial ratios and information for preliminary stocks screening.

From this project, I also learnt many of basic finance theories, which I could implement to valuate stocks.

I am not an expert at finance and I bet you probably know way better than me.

Therefore, feel free to improve on the solutions as you see fit.

My contact detail is below if you would like to say hi or have a chill discussion :).

AcknowledgmentsI would like to thank you my fellow Accountancy and Finance friends who inspired me to build this tool.

I really enjoyed learning a bunch of finance terms from them and used that to tackle real life problems that they have been encountering.

Finally…Whew… That’s it, about my idea which I formulated into writings.

I really hope this has been a great read for you guys.

With that, I hope my idea could be a source of inspiration for you to develop and innovate.

Please reach out to me via my LinkedIn and subscribe to my Youtube ChannelComment out below for suggestions and feedbacks.

Happy coding :).. More details

Leave a Reply