{"id":16190,"date":"2021-08-17T02:41:55","date_gmt":"2021-08-16T18:41:55","guid":{"rendered":"https:\/\/www.tejwin.com\/?post_type=insight&#038;p=16190"},"modified":"2024-07-03T17:25:45","modified_gmt":"2024-07-03T09:25:45","slug":"warren-e-buffetts-value-investing","status":"publish","type":"insight","link":"https:\/\/www.tejwin.com\/en\/insight\/warren-e-buffetts-value-investing\/","title":{"rendered":"Warren E. Buffett\u2019s Value Investing"},"content":{"rendered":"\n<p>Stock screening from Buffett\u2019s investing principles.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter is-resized caption-align-center\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1_1wWm5YjabWxKtaGLNdqOwTQ.jpg\" alt=\"\" style=\"width:852px;height:624px\"\/><figcaption class=\"wp-element-caption\">Photo Creds:&nbsp;<a href=\"https:\/\/www.flickr.com\/\" rel=\"noreferrer noopener\" target=\"_blank\">Flickr<\/a><\/figcaption><\/figure>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_81 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69f4bb4f6f9b4\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69f4bb4f6f9b4\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.tejwin.com\/en\/insight\/warren-e-buffetts-value-investing\/#Preface\" >Preface<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.tejwin.com\/en\/insight\/warren-e-buffetts-value-investing\/#The_Editing_Environment_and_Modules_Required\" >The Editing Environment and Modules Required<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.tejwin.com\/en\/insight\/warren-e-buffetts-value-investing\/#The_highlights_of_the_article\" >The highlights of the article<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.tejwin.com\/en\/insight\/warren-e-buffetts-value-investing\/#Quantitative_Indicators\" >Quantitative Indicators<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.tejwin.com\/en\/insight\/warren-e-buffetts-value-investing\/#Investing_Strategy\" >Investing Strategy<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.tejwin.com\/en\/insight\/warren-e-buffetts-value-investing\/#Stock_Pool\" >Stock Pool<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.tejwin.com\/en\/insight\/warren-e-buffetts-value-investing\/#Most_recent_year_ROE_%3E_Industry_average_ROE\" >Most recent year ROE &gt; Industry average ROE<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.tejwin.com\/en\/insight\/warren-e-buffetts-value-investing\/#Three-year_average_ROE_%EF%BC%9E_15\" >Three-year average ROE \uff1e 15%<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.tejwin.com\/en\/insight\/warren-e-buffetts-value-investing\/#Most_recent_year_Gross_margin_%EF%BC%9E_Industry_average_GM\" >Most recent year Gross margin \uff1e Industry average GM<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.tejwin.com\/en\/insight\/warren-e-buffetts-value-investing\/#Increase_in_market_value_within_7_years_Increase_in_retained_earnings_within_7_years_%3E_1\" >Increase in market value within 7 years \/ Increase in retained earnings within 7 years &gt; 1<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.tejwin.com\/en\/insight\/warren-e-buffetts-value-investing\/#Most_recent_year_FCF_FCF_7_year_ago_-1_%3E_1\" >(Most recent year FCF \/ FCF 7 year ago ) -1 &gt; 1<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.tejwin.com\/en\/insight\/warren-e-buffetts-value-investing\/#Current_market_value_The_discounted_value_of_FCF_in_next_10_years_Database_TWNAIM1A_code_R69B\" >Current market value \/ The discounted value of FCF in next 10 years. Database: TWN\/AIM1A, code: R69B<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.tejwin.com\/en\/insight\/warren-e-buffetts-value-investing\/#Review_portfolio_performane\" >Review portfolio performane<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.tejwin.com\/en\/insight\/warren-e-buffetts-value-investing\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.tejwin.com\/en\/insight\/warren-e-buffetts-value-investing\/#Related_Link\" >Related Link<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"141e\"><span class=\"ez-toc-section\" id=\"Preface\"><\/span><strong>Preface<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"cff7\">Warren E. Buffett is the person who has made the most money from stocks in the history of the world. He returned to Omaha in 1956 and started with $100. As of August 1999, his total personal assets have reached $36 B, becoming the second richest person in U.S. in that time. Buffet\u2019s investment principles are very simple. First, ignore the daily rise and fall of stock prices. Second, do not worry about changes in the overall economics situation. Third, invest with the mentality of buying a company instead of investing in stocks.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Company\uff1a<br><\/strong>a. Is this company simple and understandable\uff1f<br>b. Is operating history of this company stable\uff1f<br>c. Is the company\u2019s long-term development prospects promising\uff1f<\/li>\n\n\n\n<li><strong>Operation\uff1a<br><\/strong>a. Whether the operator is rational\uff1f<br>b. Whether the operator is honest and frank with his shareholders\uff1f<br>c. Whether the operator will blindly follow the action of other legal entites \uff1f<\/li>\n\n\n\n<li><strong>Finance\uff1a<br><\/strong>a. Focus on Return on Equity (ROE) rather than earnings per share (EPS).<br>b. Calculate discounted free cash flow (DCF).<br>c. Looking for high gross margin (GM).<br>d. For each dollars of retained earnings make sure that the company has created at least on dollar of market value.<\/li>\n\n\n\n<li><strong>Market\uff1a<br><\/strong>a. What is the value of this company?<br>b. Whether we can buy stocks at a significant value discount, that is, obtain a margin of safty.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"10c9\"><span class=\"ez-toc-section\" id=\"The_Editing_Environment_and_Modules_Required\"><\/span><strong>The Editing Environment and Modules Required<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"fea8\">We use Windows OS and Jupyter Notebook in this article.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import tejapi<br>import pandas as pd<br>import numpy as np<br>tejapi.ApiConfig.api_key = 'Your Key'<br>tejapi.ApiConfig.ignoretz = True<\/pre>\n\n\n\n<p id=\"3679\"><em>Note: Remember to replace \u2018Your key\u2019 with the one you applied for. The last line indicates that we ignore the time zone.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2326\"><span class=\"ez-toc-section\" id=\"The_highlights_of_the_article\"><\/span><strong>The highlights of the article<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Quantify investment principles<\/li>\n\n\n\n<li>Database search<\/li>\n\n\n\n<li>Data filtering:&nbsp;<code><em>loc<\/em><\/code>&nbsp;,&nbsp;<code><em>groupby<\/em><\/code>&nbsp;,&nbsp;<code><em>pivot_table<\/em><\/code><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"05e9\"><span class=\"ez-toc-section\" id=\"Quantitative_Indicators\"><\/span><strong>Quantitative Indicators<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"0284\">Due to part of principles cannot be quantified. Therefore, we choose only quantifiable principles. The basis of principles is to evaluate earning ability of company.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Most recent year ROE &gt; Industry average ROE\uff1asave to&nbsp;<code><em>set_1<\/em><\/code><\/li>\n\n\n\n<li>Three-year average ROE \uff1e 15%\uff1asave to&nbsp;<code><em>set_2<\/em><\/code><\/li>\n\n\n\n<li>Most recent year Gross margin \uff1e Industry average GM\uff1asave to&nbsp;<code><em>set_3<\/em><\/code><\/li>\n\n\n\n<li>Increase in market value within 7 years \/ Increase in retained earnings within 7 years &gt; 1\uff1asave to&nbsp;<code><em>set_4<\/em><\/code><\/li>\n\n\n\n<li>(Most recent year FCF \/ FCF 7 year ago ) -1 &gt; 1\uff1asave to&nbsp;<code><em>set_5<\/em><\/code><\/li>\n\n\n\n<li>Current market value \/ The discounted value of FCF in next 10 years &lt; 1 \uff1asave to&nbsp;<code><em>set_6<\/em><\/code><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"499e\"><span class=\"ez-toc-section\" id=\"Investing_Strategy\"><\/span><strong>Investing Strategy<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"4a09\">We choose the stocks which are eligible, and buy on 2020\/1\/1, hold until 2020\/12\/31. Each condition will make a set to save eligible stocks. Finally, make the intersection to get portfolio.<\/p>\n\n\n\n<p id=\"56c8\">When we comparing whether each dollar of retained earnings creates a dollar of market value, it involves whether the company has been listed for long enough. Therefore we selected the companies which are alive in 2020 and listed for more than 7 years. Due to the formula of ROE, we can improved by borrowing, so we exclude the industries with high debt ratio such as banking and finance holding.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2b62\"><span class=\"ez-toc-section\" id=\"Stock_Pool\"><\/span><strong>Stock Pool<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3d48\"><strong>Step 1.&nbsp;Search listed company database<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">tejapi.search_table(\"\u4e0a\u5e02\u65e5\")<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter caption-align-center\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1_1oGuKRuUpCvY8rSpeRslpTQ.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\">Results<\/figcaption><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"cf14\"><strong>Step 2.&nbsp;We use TWN\/AIND database. Filter choose listed before 2013 and exclude industry (28 &amp; 29).<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">comp_data = tejapi.get('TWN\/AIND',<br>                   elist_day1 ={'lt':'2013-01-01'},<br>                   ind = {'ne':('28', '30')},<br>                   mkt = 'TSE',<br>                   opts = {'columns':['coid', 'elist_day1', <br>                           'ind']},<br>                   chinese_column_name=True,<br>                   paginate=True<br>                  )<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter caption-align-center\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/11wwxP92mU6CaQfHYsqH9QQ.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\">comp_data<\/figcaption><\/figure>\n\n\n\n<p id=\"3078\">Obtain a list eligible companies and use it to create industry average data later.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">comp_list = list(comp_data['\u516c\u53f8\u7c21\u7a31'])<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"4402\"><strong>Step 3.&nbsp;Make industry dictionary<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">industry_list = comp_data[\"TEJ \u7522\u696d\u5225\"].unique().tolist()<\/pre>\n\n\n\n<p id=\"5fdf\">Create ROE&nbsp;<code><em>dict<\/em><\/code>&nbsp;of all companies in industry.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">industry_data = tejapi.get('TWN\/AIND',<br>                    ind = industry_list,<br>                    mkt = 'TSE',<br>                    opts = {'columns':['coid', 'ind']},      <br>                    chinese_column_name=True,<br>                    paginate=True<br>                   ).reset_index(drop=True)<\/pre>\n\n\n\n<p id=\"03e8\">The dict of&nbsp;<code><em>key<\/em><\/code>&nbsp;is industry and&nbsp;<code><em>value<\/em><\/code>&nbsp;is list of companies.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">industry_dict = {}<br>for i in industry_list:<br>    industry_dict[i] = industry_data[industry_data['TEJ \u7522\u696d\u5225'] == <br>    i]['\u516c\u53f8\u7c21\u7a31'].tolist()<\/pre>\n\n\n\n<p id=\"efd6\">For example, search the companies in industry 13.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">industry_dict[\"13\"]<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1-s_HTWsQ9DEeifFV4OAK7w.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"612a\"><span class=\"ez-toc-section\" id=\"Most_recent_year_ROE_%3E_Industry_average_ROE\"><\/span><strong>Most recent year ROE &gt; Industry average ROE<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Database TWN\/AIM1A<\/li>\n<\/ul>\n\n\n\n<p id=\"34b1\">The following stock selection methods are similar to this. This content will be more complicated. Readers can check the&nbsp;<a href=\"https:\/\/gist.github.com\/tommy780507\/3b58d38522b4b3cccf499416a823295c#file-ipynb\" rel=\"noreferrer noopener\" target=\"_blank\">complete code<\/a>&nbsp;if you do not understand.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"23c2\"><strong>Step 1.&nbsp;Obtain the ROE data.<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">ROE_data = tejapi.get('TWN\/AIM1A',<br>                  coid = comp_list,<br>                  mdate= '2019-12-01',<br>                  opts={'pivot':True,<br>                        'columns':['coid', 'mdate', 'R103']},<br>                  chinese_column_name=True,<br>                  paginate=True)<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1hZtZQ4i6Uf6JyHA3QQZ6-w.png\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3777\"><strong>Step 2.&nbsp;\u8fed For loop to turn industry into dictionary. Create 2019 industry average dict.<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">industry_roe = {}<br>for i in industry_list:<br>    data = tejapi.get('TWN\/AIM1A',<br>                  coid = industry_dict[i],<br>                  mdate='2019-12-01',<br>                  opts={'pivot':True,<br>                        'columns':['coid', 'mdate', 'R103']},<br>                  chinese_column_name=True,<br>                  paginate=True).reset_index(drop=True)<br>    industry_roe[i] = data.groupby('\u516c\u53f8\u4ee3\u78bc').mean().mean()[0]<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1_1hAc4pVZf0Tj3Zz6OjER9gQ.png\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1D72sWPrW9YXu90RTcNN7pQ.png\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"485d\"><strong>Step 3.&nbsp;\u5c07 Mapping the industry average dict to get average ROE.<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">ROE_data['\u7522\u696d\u6de8\u503c\u5831\u916c%'] = ROE_data['TEJ \u7522\u696d\u5225'].apply(lambda x: industry_roe[x])<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1_1lBF0kuokbXfhDe2gRVsi9A.png\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"50c3\"><strong>Step 5.&nbsp;Save eligible companies to&nbsp;<code><em>set_1<\/em><\/code>&nbsp;.<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">set_1 = set(ROE_data[ROE_data['ROE(A)\uff0d\u7a05\u5f8c'] &gt; ROE_data['\u7522\u696d\u6de8\u503c\u5831\u916c%']]['\u516c\u53f8\u7c21\u7a31'])<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"cafe\"><span class=\"ez-toc-section\" id=\"Three-year_average_ROE_%EF%BC%9E_15\"><\/span>Three-year average ROE \uff1e 15%<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"e62e\">Choose 3-year data and operate like point 1method&nbsp;<code><em>groupby<\/em><\/code>. Then get averaged number<code><em>mean<\/em><\/code>&nbsp;and save to<code><em>set_2<\/em><\/code>&nbsp;.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ROE_data_3Y = tejapi.get('TWN\/AIM1A',<br>                      coid=comp_list,<br>                      mdate=['2017-12-01','2018-12-01','2019-12-<br>                              01'],<br>                      opts={'pivot':True,<br>                            'columns':['coid', 'mdate', 'R103']},<br>                      paginate=True,<br>                      chinese_column_name=True,<br>                     )<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1_12AItuY3aISFpmV_y183SlA.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3c91\"><span class=\"ez-toc-section\" id=\"Most_recent_year_Gross_margin_%EF%BC%9E_Industry_average_GM\"><\/span>Most recent year Gross margin \uff1e Industry average GM<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"ad88\">The operation method is similar to point 1. We save eligible companies into&nbsp;<code><em>set_3<\/em><\/code>&nbsp;.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1_1aE3NRQUQXQshbmbsLNoq9A.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"0c65\"><span class=\"ez-toc-section\" id=\"Increase_in_market_value_within_7_years_Increase_in_retained_earnings_within_7_years_%3E_1\"><\/span>Increase in market value within 7 years \/ Increase in retained earnings within 7 years &gt; 1<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"c8dc\"><strong>Step 1.&nbsp;Obtain market value and retained earnings data.<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">MV_RE_data = tejapi.get('TWN\/AIM1A',<br>                coid = comp_list,<br>                mdate= ['2019\/12\/01','2013\/03\/01'],<br>                opts={'pivot':True,<br>                        'columns':['coid', 'mdate','MV','2341']},<br>                chinese_column_name=True,<br>                paginate=True<br>               ).reset_index(drop=True)<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1btrn7EKU9GY2TyFerj8i5g.png\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"c717\"><strong>Step 2.&nbsp;<code><em>pivot_table<\/em><\/code><\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">MV_RE_data.pivot_table(index='\u516c\u53f8\u4ee3\u78bc', columns='\u8ca1\u5831\u5e74\u6708').reset_index()<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1_1xbuoQK9rGKW_8ZMmz2f_lw.png\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"0d0c\"><strong>Step 3.&nbsp;Subtract the two columns to get the added value.<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">MV_RE_data['\u4fdd\u7559\u76c8\u9918\u589e\u52a0\u503c'] = MV_RE_data.iloc[:,2] - MV_RE_data.iloc[:,1]MV_RE_data['\u5e02\u503c\u589e\u52a0\u503c'] = MV_RE_data.iloc[:,4] - MV_RE_data.iloc[:,3]<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"6386\"><strong>Step 4.&nbsp;Calculate the signal.<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">MV_RE_data['\u6307\u6a19'] = MV_RE_data['\u5e02\u503c\u589e\u52a0\u503c'] \/ MV_RE_data['\u4fdd\u7559\u76c8\u9918\u589e\u52a0\u503c']<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"711d\"><strong>Step 5.&nbsp;Save eligible companies into&nbsp;<code><em>set_4<\/em><\/code>&nbsp;.<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">set_4 = set(MV_RE_data[MV_RE_data['\u6307\u6a19']&gt;1]['\u516c\u53f8\u4ee3\u78bc'])<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"4679\"><span class=\"ez-toc-section\" id=\"Most_recent_year_FCF_FCF_7_year_ago_-1_%3E_1\"><\/span>(Most recent year FCF \/ FCF 7 year ago ) -1 &gt; 1<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"74f1\"><strong>Step 1.&nbsp;Obtain FCF data.<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">cash_data = tejapi.get('TWN\/AIM1A',<br>                  coid= comp_list,<br>                  mdate=['2013-12-01', '2019-12-01'],<br>                  opts={'pivot':True,<br>                        'columns':['coid', 'mdate', 'R69B']},<br>                  paginate=True,<br>                  chinese_column_name=True,<br>                 )<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"5f3f\"><strong>Step 2.&nbsp;The operation method is similar to point 4. Use&nbsp;<code><em>pivot_table<\/em><\/code>&nbsp;and Subtract the two columns.<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1rMDR-uNBvPb8snUqvBEv6g.png\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"74d4\"><strong>Step 3.&nbsp;Save to<code><em>set_5<\/em><\/code><\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">set_5 = set(cash_data[cash_data['\u6307\u6a19'] &gt; 1].index)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2a83\"><span class=\"ez-toc-section\" id=\"Current_market_value_The_discounted_value_of_FCF_in_next_10_years_Database_TWNAIM1A_code_R69B\"><\/span>Current market value \/ The discounted value of FCF in next 10 years. Database: TWN\/AIM1A, code: R69B<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Calculate present and future value. We can import useful module&nbsp;<code><em>numpy_financial<\/em><\/code>&nbsp;. Its documentation is&nbsp;<a href=\"https:\/\/numpy.org\/numpy-financial\/latest\/\" rel=\"noreferrer noopener\" target=\"_blank\">here<\/a>. Type&nbsp;<code><em>pip install numpy_financial<\/em><\/code>&nbsp;in terminal.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">import numpy_financial as npf<\/pre>\n\n\n\n<p id=\"2244\">For instance, a company 4-year FCF are 100 \/ -150 \/ -200 \/ 400. We can use NPV method to calculate its present value by setting discount rate 10%.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cash_flows = np.array([100, -150, -200, 400])<br>npf.npv(0.1, cash_flows)<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter caption-align-center\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1kXrtKPMzNQyVUoNRh8VJlg.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\">example NPV<\/figcaption><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>We use two-stage discount model. The growth rate of the first stage is 15% ( first 3 years) and 5% in stage two. Assuming that the discount rate remains unchanged which is 9%. The following defines the cash flow for the next 10 years, and y0 is the 2019 cash flow.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">def Cashflows(y0):<br>    y1 = y0 * 1.15<br>    y2 = y1 * 1.15<br>    y3 = y2 * 1.15<br>    y4 = y3 * 1.05<br>    y5 = y4 * 1.05<br>    y6 = y5 * 1.05<br>    y7 = y6 * 1.05<br>    y8 = y7 * 1.05<br>    y9 = y8 * 1.05<br>    y10 = y9 * 1.05<br>    <br>    cashflows = np.array([y1,y2,y3,y4,y5,y6,y7,y8,y9,y10])<br>    <br>    return cashflows<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"1b79\"><strong>Step 1.&nbsp;Obtain 2019 FCF and market value.<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">MV_cash_data = tejapi.get('TWN\/AIM1A',<br>                  coid= comp_list,<br>                  mdate='2019-12-01',<br>                  opts={'pivot':True,<br>                        'columns':['coid', 'mdate', 'R69B', <br>                                   'MV']},<br>                  paginate=True,<br>                  chinese_column_name=True,<br>                 ).reset_index(drop=True)<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1E7UaKDWi_8ekUrYlYnFIKw.png\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3e12\"><strong>Step 2.&nbsp;Present value of 10-year FCF<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">MV_cash_data['\u81ea\u7531\u73fe\u91d1\u6d41\u91cf(D)'].apply(lambda x: npf.npv(0.09, Cashflows(x)))<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"6c56\"><strong>Step 3.&nbsp;Calculate the signal.<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">MV_cash_data['\u6307\u6a19'] = MV_cash_data['\u5b63\u5e95\u666e\u901a\u80a1\u5e02\u503c'] \/ MV_cash_data['\u81ea\u7531\u73fe\u91d1\u6d41\u91cf(D)'].apply(lambda x: npf.npv(0.09, Cashflows(x)))<\/pre>\n\n\n\n<p id=\"478f\"><strong>Step 3.&nbsp;<\/strong>Save to&nbsp;<code><em>set_6<\/em><\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">set_6 = set(MV_cash_data[(MV_cash_data['\u6307\u6a19']&lt;1) &amp; (MV_cash_data['\u6307\u6a19']&gt;0)]['\u516c\u53f8\u4ee3\u78bc'])<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"d378\"><span class=\"ez-toc-section\" id=\"Review_portfolio_performane\"><\/span><strong>Review portfolio performane<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"20f8\">Coming to the final stage we are most looking forward to, take the intersection of each set to get our portfolio.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">set_1 &amp; set_2 &amp; set_3 &amp; set_4 &amp; set_5 &amp; set_6<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1_1iz8_NJ1BKnb2QxtnEtcz2g.png\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1a27KT5oEfuPAcEjm_r2NWg.png\" alt=\"\"\/><\/figure>\n\n\n\n<p id=\"52ad\">Refer to\u00a0<a href=\"https:\/\/medium.com\/tej-api-financial-data-anlaysis\/application-5-modular-backtesting-system-ecfbe883899e\" class=\"ek-link\" target=\"_blank\" rel=\"noopener\">\u3010Application(5)\u3011Modular Backtesting System<\/a>. We put this list into the system. Because the price gap of the stock is too large, we use equal weight to buy and hold. Obtain the return rate is<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter caption-align-center\"><img decoding=\"async\" src=\"https:\/\/www.tejwin.com\/wp-content\/uploads\/1ngfxsBkFXgTX5-Pv6LElXQ.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\">ROI on Portfolio<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"78cf\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><strong>Conclusion<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"58d0\">More proficient in operating database, more able to design personalized stock selection. You can also test various stock selection stratigies. The content of this article is more complicated and requires more effort to study. If you have interest on this topic, you can go to our&nbsp;<a href=\"https:\/\/eshop.tej.com.tw\/E-Shop\/Edata_caseIntro\/2\" rel=\"noreferrer noopener\" target=\"_blank\">official website<\/a>. It provides various financial data to help you make better strategy.<\/p>\n\n\n\n<p id=\"543d\">The content of this webpage is not an investment device and does not constitute any offer or solicitation to offer or recommendation of any investment product. It is for learning purposes only and does not take into account your individual needs, investment objectives and specific financial circumstances. Investment involves risk. Past performance is not indicative of future performance. Readers are requested to use their personal independent thinking skills to make investment decisions on their own. If losses are incurred due to relevant suggestions, it will not be involved with author.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"b7a9\"><span class=\"ez-toc-section\" id=\"Related_Link\"><\/span><strong>Related Link<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/api.tej.com.tw\/index.html\" rel=\"noreferrer noopener\" target=\"_blank\">TEJ API<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/eshop.tej.com.tw\/E-Shop\/Edata_intro\" rel=\"noreferrer noopener\" target=\"_blank\">TEJ E-Shop<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Stock screening from Buffett\u2019s investing principles. Preface Warren E. Buffett is the person who has made the most money from stocks in the history of the world. He returned to Omaha in 1956 and started with $100. As of August 1999, his total personal assets have reached $36 B, becoming the second richest person in [&hellip;]<\/p>\n","protected":false},"featured_media":16195,"template":"","tags":[2371,3005],"insight-category":[690,50],"class_list":["post-16190","insight","type-insight","status-publish","has-post-thumbnail","hentry","tag-python","tag-tejapi-application","insight-category-data-analysis","insight-category-fintech"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight\/16190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight"}],"about":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/types\/insight"}],"version-history":[{"count":1,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight\/16190\/revisions"}],"predecessor-version":[{"id":24850,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight\/16190\/revisions\/24850"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/media\/16195"}],"wp:attachment":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/media?parent=16190"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/tags?post=16190"},{"taxonomy":"insight-category","embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight-category?post=16190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}