You buy a product for $25.00. The store has a sale and drops the price by 30%. Then they raise the price again by 30%, so now the product costs $23.43. What happened? Well, it’s a typical case of misleading percentages. The store applied the price increase to the discounted price.

Percentage calculations

What is 4% of 10? 20 is what percentage of 30?

Questions like these can be answered by the following equations. We use \(p\) to denote the percentage amount and \(n\) to denote the number we’re comparing to.

The percentage of a number with respect to another number is found with

\[y = pn\]

Remembering to convert the percentage into decimal, we can implement it in Python with

def nfind(p, n):
  return (p / 100) * n

What is 4% of 10?

nfind(4, 10)
## 0.4

To find what percentage of a number a given number is, you can use

\[p = \frac{n}{y}\]

def pfind(n, y):
  return n / y

What percent of 60 is 12?

pfind(12, 60)
## 0.2

There are more calculations and ways to pose percentage related questions; percentages can be confusing and tricky to grasp despite their widespread use in business settings.

Account balance example

Now, let’s pose that we have a porfolio account with a balance of $1000 on a given day. Let’s also suppose that the portfolio loses 10% of its value after a week. That amounts to $100, meaning that the balance at the end of the week is $900.

nfind(10, 1000)
## 100.0

The percentage change equation is

\[c = \frac{V_2 - V_1}{|V_1|} \times 100\] Where \(V_1\) and \(V_2\) are respectively the first and second values we’re comparing, and \(c\) is the percentage change.

def pchange(v1, v2):
  return round(((v2 - v1) / abs(v1)) * 100, 2)

Interestingly, the change from $1000 to $900 is 10% but going from $900 to $1000 is a change of 11%.

pchange(1000, 900)
## -10.0
pchange(900, 1000)
## 11.11

This mathematical artifact tells us that it takes more work to recuperate a loss. However, the amount of effort necessary to recover larger losses increases (almost) exponentially as the losses increases.

In general, to calculate the gains necessary to restore losses, you can use

\[r = \frac{1}{(1 - p)} - 1\] where \(r\) is the percentage needed to break even, and \(p\) is the percentage loss.

def pneeded(p):
  return round((1 / (1 - (p / 100))) - 1, 2)
pneeded(10)
## 0.11

When investments lose ground, they must make up more ground, percentage-wise, just to get back to even.

These numbers lead to some interesting points like:

  • it’s better to cut your losses short (ideally at less than 10%)
  • don’t fall prey to sunk cost fallacy reasoning
  • active investing can be a better strategy than “set it and forget it”
  • it’s not a bad idea to buy trending stocks, even at higher prices
  • the time a stock spends recovering its value is opportunity cost
losses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]
gain = [pneeded(x) * 100 for x in losses]
import matplotlib.pyplot as plt
from matplotlib.ticker import PercentFormatter

fig, ax = plt.subplots()
ax.plot(losses, gain)
ax.yaxis.set_major_formatter(PercentFormatter())
ax.xaxis.set_major_formatter(PercentFormatter())
ax.set_title("Great losses require greater gains")
ax.set_xlabel("portfolio loss")
ax.set_ylabel("needed gain to recover losses")
ax