DEV Community

ghostdev
ghostdev

Posted on

I called the market bottom perfectly and still lost $55,000

Bug report

Title: User waits for the perfect moment to invest. Gets it. Still loses.
Severity: Expensive
Reproducible: Every market cycle
Status: Won't fix (it's a human bug)

You probably know this person. Maybe it's you.

Smart, well paid, a pile of cash sitting in a savings account. And a plan:

"The market is too high right now. I'll get in after it drops."

It sounds careful. Responsible, even. Let's run it and see what happens in production.

Steps to reproduce

Two engineers, Emma and Sam. Each has $100,000 in January 2016.

Emma invests all of it on day one. Her timing is bad: within weeks, the market drops about 10%. Classic "I bought the top."

Sam thinks the market is too expensive. He waits for a real crash. He waits four years, and then he gets exactly what he wanted: he invests everything at the very bottom of the COVID crash, on March 23, 2020. The best day to buy in years. Perfect execution.

Both hold until mid-2023.

Expected result

Sam wins. He bought at the bottom. That's the whole point of waiting.

Actual result

// S&P 500 with dividends reinvested, normalized so Jan 2016 = 100.
// Approximate levels, rounded for readability.
const index = {
  jan2016: 100,
  covidBottom: 126, // March 23, 2020
  mid2023: 265,
};

const invest = (amount, buyAt, sellAt) => amount * (sellAt / buyAt);

const emma = invest(100_000, index.jan2016, index.mid2023);
const sam = invest(100_000, index.covidBottom, index.mid2023);

console.log({ emma: Math.round(emma), sam: Math.round(sam), diff: Math.round(emma - sam) });
// { emma: 265000, sam: 210317, diff: 54683 }
Enter fullscreen mode Exit fullscreen mode
Strategy Result by mid-2023
Emma Invested immediately, "bad" timing ~$265,000
Sam Waited 4 years, bought the exact bottom ~$210,000

Sam called the bottom perfectly and still lost by about $55,000.

Even if his cash had earned interest while he waited, he'd still be behind by roughly $45,000.

Root cause

Look at the index object again. The bottom of the crash Sam waited four years for (126) was higher than the price Emma paid in 2016 (100).

While Sam was waiting, the market kept climbing. The "crash" only gave back part of what he'd already missed.

A market that grows over time spends most of its life near all-time highs. "Too high" isn't a warning sign. It's what normal looks like.

And that's the best case

Sam is a fantasy. He caught the exact bottom. Real people waiting for the dip almost never do. When the crash finally comes, the headlines are terrifying, so they wait for it to fall "just a bit more," and the market recovers without them.

The same bug shows up in the other direction, too. According to J.P. Morgan, 7 of the 10 best days for the S&P 500 between 2005 and 2024 came within two weeks of one of the 10 worst days. Miss just those 10 best days over 20 years, and your annual return is roughly cut in half. To catch the rebound, you have to be in the market at exactly the moment it feels scariest.

The fix

The fix is boring, which is why nobody ships it:

while (true) {
  buy(whateverIsBelowTarget);
  sleepWellAtNight();
  // never call sell()
}
Enter fullscreen mode Exit fullscreen mode
  1. Invest when you have the money, not when the market "feels right"
  2. Automate a monthly deposit so there's no decision to make
  3. Don't open the app during crashes

Market timing is a bug that works in the demo and fails in production. The best moment to invest is almost always the moment you have the money.


I'm a developer, not a financial advisor. This is educational content, not personalized advice. Figures are approximate historical examples, and past performance doesn't guarantee future results.

This example comes from a short ebook I wrote for developers on simple, long-term investing: The Algorithm of Wealth. There's also a free calculator there to see when your money could cover your expenses.

Top comments (0)