Fundamental Analysis of Stocks for Programmers and Beginners

The crucial accounting and finance topics you need to know to invest like a seasoned professional in 11 minutes

May 5, 2020 · 11 min read

Fundamental analysis and technical analysis should be familiar terms if you have ever dabbled in the stock markets. Technical analysis is defined by using statistical trends from historical trading activity, and other datasets to identify future trading opportunities. Many data science specialists believe that this is the way to do it, and there are many companies built around this ideology. On the other hand, analysts who believe in Fundamental analysis believes in finding a company’s “true” intrinsic value, through analyzing its financial statements. Warren Buffett has stood behind this methodology time and time again, betting that long-term value investments generate the best investment returns.

I’ve seen the strengths and weaknesses of both ideologies. Buffett, who has made a fortune through his investment holdings, has recently seen cracks and losses. Airline stocks have taken a nose-dive after Berkshire Hathaway sold them all in April. Warren Buffett makes mistakes, and unanticipated events occur, but he has also made his fortune using this ideology. Technical analysis also produces insane returns, such as the 70% average annual returns from the Medallion Fund of Renaissance Technologies.

Photo by Dan Freeman on Unsplash

Through “statistical arbitrage”, a system which aims to capture small price discrepancies between two related securities, an investment firm can profit. This is done through statistical analysis, but arguably also requires an understanding of the companies fundamentally. Now I’m not here to tell you that one methodology is better than the other, traditional finance is arguably driven off fundamental analysis. However, just like the changing times, there is tremendous value in technical analysis, and I believe a combination of the two will help achieve higher investment returns.

For example, from speaking to a famous Tiger Cub hedge fund portfolio manager with no programming experience, he told me that he utilizes both strategies to pick stocks. He and his team utilize millions of dollars of data from credit cards to find trends in spending patterns and consumer sentiment. With this exclusive set of data, he can locate secular trends and make accurate real-time investment decisions. His technical team of analysts produces a dashboard for him, which he then looks at in a fundamental analysis lens. The official term for this type of analysis is quantinomics, and you can find out more about it here:

Programmers, you have the statistical and computational knowledge required for optimal investing, so stick with me and learn the ins and outs of fundamental analysis too.

What is Fundamental Analysis?

Warren Buffett is famous throughout the world for his investment prowess, but he easily gives credit to his teacher, Benjamin Graham, the father of security analysis and value investing. Fundamental analysis is closely tied with these other concepts, because it requires looking at the business through a financial lens, and identifying gems that the market undervalues.

The mindset of a value investor…

One of the most important concepts to value investing is the concept of the margin of safety. Simply put, if you can buy an asset worth $100 for $50, you have a limited downside, and margin of safety because even if the asset was worth $75 instead of $100, you would still have a return on investment.

Next, Benjamin Graham and his devout followers distinguish between being a speculator vs. an investor. To make consistent returns in the stock market, you must be an investor and not a speculator. The difference is clear in theory, but difficult to see in practice. Investors look at purchasing stock as more than just a piece of paper for resale, they see it as owning a part of the business, and care about the business as much as a small owner does.

There are different ways to find an undervalued asset, but it’s important to know your accounting ratios and related concepts. The end goal of fundamental analysis is to use company information to conduct a DCF analysis to calculate the intrinsic value of the company:

Company Accounting Ratios and Concepts

For the course of this tutorial, we’ll be looking at some key ratios of Apple, and also conduct a historical financial performance analysis. We’ll be looking at the latest annual report for 2019, and also the latest quarterly report dated May 1, 2020.

To begin, accounting ratios are metrics to help business professionals conduct relative analysis because if we used absolute measures, different characteristics of a company would skew the way you look at the business. For example, consider the two companies in the same industry:

Example Comparison of Two Companies

If we only looked at the net income of the two companies, we would prefer Company A over B, because $1 million is higher than $500k. However, absolute amounts are rarely compared, because Company A is just a larger company when in reality, Company B is much more profitable. This explains the first concept of margins. Margins are generally always calculated using a Sales amount as the denominator.

Margins allow you to compare profitability

Snippet from Apple 10-Q Income Statement

When I analyze a business, I like to create an excel sheet so I can quickly calculate growth and margins. Having an excel sheet allows you to move things around for your groupings. For the rest of this article, I’ll only be posting the excel versions, which are manually inputted from the statements.

Reformatted Income Statement to Show Margins

Everyone knows Apple for its products, such as their iPhones, iPods, and Macbooks. Not as many people know that Apple has been progressively increasing its focus on services, which cost less and are recurring. The services segment includes the App Store, Apple TV, AppleCare, licensing, and other services. From a quick margin analysis, we can see that on average, every product sold, it costs Apple 30% less to produce (excluding selling and other costs). For services, it costs them only 35% of service revenues to provide the service. Apple also provides their breakdowns on a more granular level, providing detailed information for each of their products.

Product breakdowns allow you to create accurate models

Breakdown of Product Sales

Interestingly enough, services are now the 2nd largest product sold by Apple at ~23% of total sales. Wearables have also gained popularity significantly throughout the years, and are now the 3rd largest product group by revenue. Applying this information to a DCF model, we would forecast the sales of each product group and apply their % split to come up with a final revenue number.

Key accounting ratios to remember for initial analysis

Accounting ratios are used to help you see the efficiency, liquidity, and profitability of a company. It can tell you whether or not a company has enough current assets on hand to take care of its near-term obligations. It can also you whether or not the assets are being used efficiently to generate company profit.

Apple Accounting Ratios from Latest 10-Q

Nothing surprises us about these ratios, we know that Apple is a large enough company, who enjoys premium pricing on its product offerings, who can also pay off its debt interest and has no trouble with its short-term obligations. If you had to sell all current assets to pay off all of Apple’s current liabilities, you would be able to do so 1.5x (current ratio). Using just your operating income, you would be able to pay off the interest expense 17x over, meaning that you are more than enough prepared for contractual obligations.

You must remember that in accounting and finance, you must compare with other comparable companies and the same company’s performance in the past.

As a programmer, if somebody asked you if C was a powerful language, you would most often compare C with other languages to prove your point. You might say C is a middle-level language and harder to learn compared to Python, and Python would be better for Data Science. Just listing out the facts about C is not a good way to promote the language to others, and it’s the same with analyzing companies.

Peer comparisons can show competitive advantages

Starting with peer comparisons, we’ll look at Apple’s competitors, Microsoft and Alphabet(Google) to see how well Apple’s profitability fares. Arguably these are similar companies and would be the best to compare Apple against. We’ll look at these three behemoths because they are often compared to each other, and they reported their first-quarter earnings of 2020 recently. Remember that your choice of comparable companies will make or break your peer comparison analysis. A poor universe of peers will cause your analysis to be useless, so this is why analysts spend a ton of time reading filings and finding ways to justify similarities.

Q1 2020 Profit Margin Peer Comparison

Surprisingly, Microsoft has the highest profit margin. Looking at the breakdown of gross profit, this is explained by much higher profits on each product sold.

MSFT Revenue Profitability Analysis

Microsoft’s 31% profit margin is explained by a ~80% gross profit on product sales. This means that on average, for every Microsoft product sold, it costs them only 20% of the price to manufacture the item. Through this analysis, we’ve learned that compared to its peers, Apple does not have the highest unit profitability, and can help us shape our investment thesis.

Historical analysis shows company improvement or deterioration

Now, we’ll be analyzing the company historically. This process is important to find positive trends and spot issues. A significantly higher expense this year compared to 5 years ago should raise red flags if there is no corresponding increase in revenues. Conversely, a significant increase in R&D expenses, or capital expenditures, which correspond with higher revenues show successful investments and management expertise.

3 Year Historical Analysis of Gross Profit

Generally, you want to calculate a growth rate for revenue line items and use total revenues or total COGS as a base for the expenses. From the analysis above, we see that product revenues have slowed, but service revenues have been growing fast (high 10s in growth rate). We can also see that Apple is becoming more efficient with its service offering, with a lower cost of sales (from 45% in 2017 to 36% in 2019), meaning that they can keep more profits.

This would be a positive sign if you were looking to invest in Apple, and this would eventually translate to a higher intrinsic value. If you found this for a different company, and the market did not recognize the company for its success, it might be a sign where you found an undervalued business.

The famous trap of accounting and finance is the paradox where historical performance is not indicative of future results. This paradox is a weird concept, as many investment firms will keep this in their disclaimers, to relieve legal liability. The basic premise is that just because a company has been performing well, increasing profitability and share price, it does not mean that it will continue this into the future. Just because something worked in the past, does not necessarily mean that they will continue this success in the future.

Slide from EC.Gov showing a Past Performance Disclaimer

However, the opposing fact to this is that because a company has the experience, and management is capable, they will be able to continue certain successful aspects into the future, which would then translate into positive future results. The main idea to remember here is to take operational success with a grain of salt, and ask yourself if it’s possible to continue. There may be an underlying factor of success that could be continued.

Cash Flow is King, EBITDA is a Proxy

Unfortunately, potentially due to geopolitical issues and tariffs, Apple was not able to continue the growth of operating income. However, ultimately we care about whether a company’s share price will go up or down. Many factors influence share prices, such as EPS, corporate events, and profitability, but for the sake of fundamental analysis, we’ll learn about EBITDA and Free Cash Flow.

Apple’s Operating Income Historical Analysis

First, to understand Earnings Before Interest, Taxes, Depreciation & Amortization (EBITDA), we should also understand its importance. This amount tries to strip out the effects of capital structure (how much of a company is debt, and how much is equity), to get a vanilla picture of the company’s operations. In other words, we calculate EBITDA for a candid view, without the impacts of accounting and other non-cash factors irrelevant to the underlying business. EBITDA is also known as a proxy for cash flow, because it is easier to calculate, but is still accurate.

Calculation of Apple Historical EBITDA

For the calculation of EBITDA, we can easily just take Operating Income (EBIT) from the income statement, (1) Depreciation & Amortization, and (2) Share-Based Compensation from the cash flow statement, since many companies include these two expenses within SG&A expenses to calculate EBIT.

The benefits of EBITDA also include that it is a universal metric, and we use it for many different valuation multiples. Because it is a close proxy for cash flow, we commonly use EV/EBITDA multiples to compare and contrast peers. Now that we know how to calculate EBITDA, we can dive deeper into calculating the true cash flow of a business, Free Cash Flow.

Calculation of Apple’s 2019 Free Cash Flows

The Free Cash Flow number is the amount of money available to investors from the operations of the business, after accounting for expenditures of cash required to keep the company functioning. Since the value of a company is the present value of all its future free cash flows, this number is crucial to fundamental analysis. Note that this is different from the change in the company’s total cash movement since this is the cash available to investors. Investors only care about the cash that they will receive from a company.

These concepts are more than enough for you to get started on the path of fundamental analysis. Keep in mind that this is just the tip of the iceberg, and should be a guide to your future learning. Remember that historical and peer analysis is mandatory, and always try to strip away the effects of accounting wherever possible. Just because a company has performed exceptionally well in the past, does not mean it will continue to do so automatically.

For more related Python and Money topics:

The Startup

Get smarter at building your thing. Join The Startup’s +788K followers.

Sign up for Top 10 Stories

By The Startup

Get smarter at building your thing. Subscribe to receive The Startup's top 10 most read stories — delivered straight into your inbox, once a week. Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.


Written by


Investment banker, global citizen interested in the pursuit and sharing of knowledge. Inquiries to

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +788K followers.


Written by


Investment banker, global citizen interested in the pursuit and sharing of knowledge. Inquiries to

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +788K followers.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store