darusuna.com

Optimize Stock Evaluation: Calculating Ratios and Growth Rates

Written on

Chapter 1: Introduction to Stock Evaluation

In the realm of value investing, I have established a systematic approach to assess stock prices before making any purchasing decisions. My methodology includes several key steps:

  1. Screening potential stock candidates.
  2. Comparing various ratios and growth rates to pinpoint promising options.
  3. Estimating the intrinsic values of these stocks utilizing Benjamin Graham's formula and the discounted cash flow method.
  4. Selecting stocks priced below their intrinsic values.
  5. Finally, reviewing the financial reports of the top candidates.

Since analyzing financial reports can be quite labor-intensive, I prioritize it as the concluding step in my evaluation process. For the initial stock screening, I rely on platforms like Finviz and TradingView. Additionally, if a stock is recommended in a YouTube video, I take note of its ticker symbol for subsequent analysis.

While checking ratios and growth rates for a single company is relatively straightforward—thanks to the abundance of available online data—comparing ten or more stocks becomes a daunting task. To streamline this, I aim to develop a program that automates data retrieval and organizes it into a single table.

Chapter 2: Selecting the Right Library

As mentioned in my previous writings, I utilize an open-source library called yfinance to fetch financial data for companies. Although the Python script has expedited my stock valuation process, I've encountered some limitations with the yfinance library:

  • It only offers four years of historical data, whereas I prefer ten or, at the very least, five years.
  • It lacks essential financial metrics such as gross margin and debt-to-equity ratio, requiring me to write additional code to compute these metrics from the raw financial information.
  • For certain companies, some necessary data points for calculating these metrics are unavailable, which necessitates robust error handling in my code.

Consequently, I began searching for alternatives to yfinance. Being a novice investor, I wanted to avoid incurring expenses during my learning process, which led me to seek out free libraries. Unfortunately, many of the available options did not meet my requirements.

Eventually, I discovered a viable solution called Financial Modeling Prep (FMP). Its free tier allows up to 250 API calls daily and provides five years of historical data. The API not only supplies the raw data as reported in financial statements but also includes the crucial ratios and growth metrics I need.

Though five years of data is not ideal, it is still better than the four years offered by yfinance. It's worth noting that I have no affiliation with FMP; my discussions stem solely from my experiences. If you have any concerns regarding the accuracy of the data, I encourage you to cross-verify it with official financial reports and perform your own calculations.

The first video titled "Building a PEG Ratio Screener with Python" offers insights on how to automate the screening of stocks based on their PEG ratios, helping investors make informed decisions.

Chapter 3: Utilizing the FMP API

Key Metrics:

  • ROIC
  • Ratios (TTM)
  • P/E
  • P/FCF
  • ROA
  • ROE
  • Gross margin
  • Net income margin
  • Debt to equity
  • Current ratio
  • Long-term debt to capitalization
  • Cash flow to debt ratio

Financial Growth:

  • Revenue growth
  • Net income growth
  • EPS growth
  • Free cash flow growth
  • Dividend per share growth

Balance Sheet Growth:

  • Growth long-term debt

Enterprise:

  • Number of shares
  • Number of shares growth
  • Market capitalization
  • Market capitalization growth

To illustrate how to retrieve data using the Key Metrics API, here are the steps:

  1. Obtain Your API Key: Register for a free account to get your API key. This key is essential as it limits the number of calls you can make per day.
  2. Set Up Your IDE: I recommend using Google Colab, which is free and has the necessary libraries pre-installed.
  3. Import Required Python Packages: For data manipulation, you will need to import pandas and requests.

import pandas as pd

import requests

  1. Construct the API URL: For example, the Key Metrics endpoint for Apple would look like this:

ticker_input = 'AAPL' # Stock ticker

period_input = 'annual' # Only 'annual' is allowed for free accounts

API_KEY = 'YOUR_API_KEY'

  1. Retrieve the Data: Fetch the data using a simple GET request:

key_metrics_json = requests.get(key_metrics_url).json()

  1. Handle Errors: Implement error handling to manage cases where the API limit is exceeded.
  2. Extract and Calculate Data: You may wish to distill the data down to relevant metrics for your analysis.

Now that I've outlined the process, let’s take a closer look at how to aggregate and analyze the data efficiently.

The second video titled "Stock Market Analysis using Python" delves into leveraging Python for comprehensive stock market evaluations, emphasizing data analysis techniques.

Chapter 4: Final Thoughts

While five years of data isn't perfect, it suffices for preliminary stock evaluations. The daily API call limit of 250 can be restrictive, especially since I often need to check multiple financial metrics across various statements. This means I can effectively analyze only around 41 stocks daily.

After downloading the resulting data as a CSV file, I transfer it to Google Sheets for further comparison. If I identify stocks that seem promising, I then cross-reference the data on platforms like quickfs.net for additional historical insights. If everything still appears favorable, I proceed to compute intrinsic values and examine financial reports.

Although I cannot claim to be an expert in stock valuation, this thorough methodology certainly enhances my confidence in making investment choices. My next goal is to automate the intrinsic value calculation process, and I look forward to sharing my progress in future updates.

I hope you find this information and code helpful!

Share the page:

Twitter Facebook Reddit LinkIn

-----------------------

Recent Post:

Embrace the Unconditional Love: Join the Mother’s Day Contest

Participate in our Mother's Day writing contest to honor the love of mothers everywhere. Win prizes and share your heartfelt stories!

Cicada Cuisine: A Unique Culinary Adventure Awaits You

Discover the intriguing world of cicadas as a culinary delight and learn how to prepare them safely.

Escaping Negativity: A Pathway to Inner Peace and Growth

Discover how to shield yourself from negativity and nurture your inner peace through mindful strategies and self-awareness.

# Insights from My First 100 Medium Stories: Key Learnings

Discover my key learnings from publishing 100 stories on Medium in just four months.

Healing My Self-Worth: A Transformative Journey to Self-Love

Discover the path to self-love and healing self-worth through personal experiences and insights.

# Master Essential C++ Tricks to Enhance Your Programming Skills

Discover key C++ programming tricks that streamline your coding process and improve efficiency.

The Influence of Technology on Sustainable Energy Solutions

Explore how technology shapes sustainable energy and renewable resources, driving efficiency and innovation in the fight against climate change.

Embracing Change: The Heart's Guidance in Decision-Making

Explore how listening to your heart can guide you in making impactful life choices.