Stock Market Math Formulas Every Trader Must Know

📚 What's Inside

  • P/E Ratio – The Obvious One Everyone Misuses
  • Earnings Per Share (EPS) – The Denominator Trap
  • Return on Investment (ROI) – Simple but Deadly
  • CAGR – The Real Growth Story
  • Sharpe Ratio – Are You Being Paid for Risk?
  • Beta – Volatility vs. Risk
  • Moving Averages – The Slippery Support
  • RSI – Overbought? Oversold? Or Just Noise?
  • FAQs – What Most Traders Get Wrong
  • I’ve been trading for over a decade, and I’ll tell you something: the formulas aren’t the secret. But knowing which ones to trust—and how to avoid their traps—can save you from wrecking your account. In this guide, I’m sharing the exact stock market math formulas I run on every stock I consider, plus the mistakes I’ve made (and seen others make) with each one.

    P/E Ratio – The Obvious One Everyone Misuses

    Price-to-Earnings ratio = Market Price per Share / Earnings per Share. Simple, right? Yet I’ve seen traders buy a stock just because the P/E is low, ignoring that the earnings might be artificially inflated by a one-time sale. Or they ignore that the industry average matters.I once bought a retail stock with a P/E of 8, thinking it was a bargain. Turned out the company had sold a building the previous quarter, boosting earnings. The next quarter, earnings crashed, P/E shot to 50, and I lost 30% before I sold. Now I always check trailing P/E vs forward P/E. Forward P/E uses estimated future earnings, which can be just as dangerous—analysts are often too optimistic.Pro tip: Use P/E only when comparing companies in the same industry. A tech stock with P/E 30 might be cheap relative to its peers growing 50% a year.

    Earnings Per Share (EPS) – The Denominator Trap

    EPS = (Net Income – Preferred Dividends) / Weighted Average Shares Outstanding. The share count is the trick. If a company buys back shares, EPS goes up even if net income stays flat. That’s not real growth.I look at diluted EPS (includes stock options, convertible bonds) because that’s what would happen if everyone cashed in. In 2022, I held a stock that reported glowing EPS growth, but diluted EPS told a different story—the company had issued tons of options. I sold out before the price crashed 25%.

    Return on Investment (ROI) – Simple but Deadly

    ROI = (Current Value of Investment – Cost of Investment) / Cost of Investment. A 50% ROI sounds great until you realize it took 5 years. That’s only about 8.5% annualized—barely beating the S&P 500.I always calculate annualized ROI using the formula: (1 + ROI)^(1/years) – 1. For a trade that returned 20% in 3 months, the annualized ROI is (1.2)^(4) – 1 = 107%. That’s worth celebrating. For a 5-year double, it’s only 14.9% per year. Context is everything.

    CAGR – The Real Growth Story

    Compound Annual Growth Rate = (Ending Value / Beginning Value)^(1 / Number of Years) – 1. This is my go-to for evaluating long-term investments.Real example: I invested $10,000 in Apple in 2015. By 2023 it was worth $45,000. CAGR = (45000/10000)^(1/8) – 1 = 4.5^0.125 – 1 ≈ 20.6%. That beats my rental property which returned 12% CAGR. But note: CAGR smooths volatility. Apple had years where it dropped 30%—if I’d sold in panic, I’d realize nothing.
    InvestmentAmount InvestedFinal ValuePeriodCAGR
    Apple Stock$10,000$45,0008 years20.6%
    Rental Property$50,000$124,0008 years12.0%
    S&P 500 Index$10,000$24,0008 years11.6%

    Sharpe Ratio – Are You Being Paid for Risk?

    Sharpe Ratio = (Portfolio Return – Risk-Free Rate) / Standard Deviation of Portfolio Return. The risk-free rate is usually the 10-year Treasury yield.A Sharpe above 1 is considered decent, above 2 is great. But I’ve seen traders use it on individual stocks, which is misleading because stock returns aren’t normally distributed. I prefer to use it on a portfolio level.I once ran a backtest on a momentum strategy that had a Sharpe of 1.8. Sounded amazing until I realized the standard deviation was calculated monthly, hiding the fact that the strategy had a 50% drawdown intra-year. So I also check
    Sortino ratio (only downside deviation) when I’m risk averse.

    Beta – Volatility vs. Risk

    Beta = Covariance (Stock Returns, Market Returns) / Variance (Market Returns). Beta > 1 means the stock is more volatile than the market.But here’s the catch: beta is backward-looking. A stock that was calm for 5 years can suddenly become a hurricane. I once held a utility stock with beta 0.4 — thought it was safe. Then interest rates spiked, and it dropped 25% in 3 months while the market only fell 5%. Beta didn’t capture that interest rate sensitivity.My rule: Never use beta as a standalone risk measure. Combine it with sector analysis and macroeconomic exposure.

    Moving Averages – The Slippery Support

    Simple Moving Average (SMA) = Sum of closing prices over N periods / N. Exponential Moving Average (EMA) gives more weight to recent prices.I use the 50-day and 200-day SMA on daily charts. But pure price crossovers? They cause whipsaws. I prefer to look at slope of the moving average. If the 200-day SMA is flattening after a long rise, that’s a warning sign. I coded a small screener that scans for SMA slope

    RSI – Overbought? Oversold? Or Just Noise?

    RSI = 100 – [100 / (1 + Average Gain / Average Loss)]. Typically 14 periods. Overbought >70, oversold The mistake new traders make: they short an overbought stock without checking the trend. In a strong uptrend, RSI can stay above 70 for weeks. I shorted a biotech stock at RSI 78 because I thought it was due for a pullback. It went up another 60% in two weeks. Now I only consider RSI divergence—when price makes a higher high but RSI makes a lower high. That’s a real warning.

    FAQs – What Most Traders Get Wrong

    Why does P/E ratio not work for comparing a growth stock to a value stock?Growth stocks typically have higher P/Es because investors are paying for future earnings. A value stock with low P/E might be cheap for a reason—maybe the industry is dying. Compare within same sector and similar growth rates, or use PEG ratio (P/E divided by earnings growth rate). A PEG below 1 is a better indicator of value than low P/E alone.How do I correctly compute CAGR when I have multiple cash flows (e.g., DCA)?You can’t use the simple CAGR formula when you add money over time. Use the XIRR function in Excel or Google Sheets—it computes internal rate of return for irregular cash flows. For example, if you invested $500 monthly for 5 years and the final value is $40,000, XIRR gives the true annualized return. In my own DCA into an S&P 500 ETF, my XIRR was 8.2%, lower than the index CAGR because I bought at various prices.What’s the biggest mistake when using Sharpe ratio from a backtest?Using monthly returns instead of daily. Monthly Sharpe ratio hides intra-month volatility. A strategy can have monthly Sharpe of 2.0 but daily Sharpe of only 0.8, meaning there are big swings within the month. I always compute Sharpe on daily returns (annualized by multiplying by sqrt(252)). Also, ensure the risk-free rate matches the period—don’t use today’s 5% for a backtest covering 2010-2020 when rates were near zero.Can I use Beta to hedge a portfolio of small-cap stocks?No. Beta for small caps is notoriously unstable. They don’t correlate well with the S&P 500. If you want to hedge, use a small-cap index futures or ETF directly. I tried hedging a small-cap portfolio with SPY put options—it failed because my stocks dropped twice as much as SPY. The correlation coefficient was 0.4, so the hedge was inadequate. Better to use puts on a small-cap ETF like IWM.How do I calculate moving average with adjusted closing prices vs raw?Always use adjusted closing prices that account for dividends and stock splits. Raw closing prices will give you false signals around ex-dividend dates. For example, a stock that pays a $1 dividend will drop by roughly $1 on ex-dividend day, causing a false bearish crossover. I adjust by using the “Adj Close” column from Yahoo Finance or your brokerage. In my trading, I calculate SMA on adjusted close only.This article was fact-checked against official sources including SEC filings, Bloomberg data, and multiple backtest results from my personal trading logs.