Sub topic 1
Reading the market through an index
A stock market index is one number that tracks the prices of a group of stocks. Investors use it as a gauge of the whole market. When someone says "the market rose 2% today," they usually mean an index such as the S&P 500 or the Dow Jones Industrial Average rose 2%.
Because an index combines many stocks, one company's bad day moves it less than it would move that company's own price.
Prerequisites
This chapter assumes you know what a stock is, can compute percentages, and can read a list of prices. The code uses Python 3.
Peaks, troughs, and trends
A peak is the highest index value before a decline. A trough is the lowest value before a recovery. A trend is the general direction prices move over months or years. Short-term swings can hide the trend, so analysts often look at longer windows.
Measuring declines: drawdown and the math of recovery
A drawdown is the percentage fall from a peak. It equals the current price divided by the running peak, minus 1.
Recovery takes a bigger percentage gain than the loss. A 20% drop needs a 25% gain to return to the old peak, because the gain applies to a smaller base.
def max_drawdown(prices):
"""Return the largest peak-to-trough decline as a negative fraction."""
peak = prices[0]
worst = 0.0
for price in prices:
peak = max(peak, price)
worst = min(worst, price / peak - 1)
return worst
prices = [100, 110, 105, 88, 92, 120]
print(f"{max_drawdown(prices):.1%}") # -20.0%What a bull market is
A bull market is a sustained rise in prices. It is commonly defined as a gain of 20% or more from a recent low. Bull markets often last years. The 20% figure is a convention that analysts use, not a legal or scientific rule.
What a market correction is
A correction is a decline of at least 10% from a recent peak. Corrections are common, and many end without becoming larger declines. A smaller dip, below 10%, is usually called an ordinary pullback.
Exercise
Using the prices [100, 120, 90, 130], what does max_drawdown return, and what label does that decline get?
Show answer
The peak is 120 and the lowest later price is 90. The drawdown is 90 / 120 - 1 = -0.25, so the function returns -0.25, or -25.0%. A decline of 20% or more is usually called a bear market, which is covered in the next chapter.