I Built a Stock-Picking Bot and It Kicked My Butt (and the Market’s… Sometimes)

So, I had this crazy idea a while back. The stock market is full of noise, right? Gurus, headlines, that one uncle who swears by some random penny stock. I started wondering, “What if you could boil it all down to the numbers? Could a simple, logical algorithm actually beat the market?”

And thus, my descent into madness—I mean, my journey into quantitative investing—began.

The goal was simple: build a bot that could pick winning stocks. How hard could it be? (Spoiler: Very. Very hard.)


Version 1: The “Momentum Amplifier” – My Beautiful, Flawed Creation

My first creation was a thing of beauty. I called it the “Momentum Amplifier.” It was an aggressive, unapologetic beast that chased what was hot. The logic was a mix of factors, with a heavy emphasis on recent performance: 60% Momentum, 20% Quality (like low debt), and a sprinkle of Volume and Valuation for good measure.

I fired up the backtester, feeding it data from the last few years. The results came back, and… oh my god.

During the “AI Boom” (2023-2024), it crushed SPY, posting a 62.1% return vs. the market’s 58.8%. Even better, during the wild “COVID Crash & Recovery,” it posted an insane 70.4% return, outperforming SPY by a whopping 16%.

I thought I’d done it. I was ready to quit my job and sail off on my yacht, “The S.S. Alpha.”


The Reality Check: My Ferrari Didn’t Have Snow Tires

Then came the hard part. A good strategy shouldn’t just work when the sun is shining. It needs to survive the winter. So, I built a “Walk-Forward Validator” to test my bot across four different market “regimes” since 2017.

The results were… humbling.

My bot was a fair-weather friend. In choppy, sideways markets or the beginning of a bear market, it got smoked. It turns out that chasing what’s hot is a terrible idea when everything is falling off a cliff. My Ferrari was spinning out in the snow.


The “Let’s Fix It!” Montage

This is where the real work began. I spent weeks testing every “smart” fix I could think of.

Experiment #1: The “Safety First” Hybrid Model. I decided to make my bot more defensive. I dialed back the aggression and added a “Low Volatility” factor, rewarding stable, boring stocks. The result? It worked perfectly during the 2022 bear market! But… it completely neutered my returns during the AI boom, underperforming SPY by a painful 13.8%. The cure was worse than the disease.

Experiment #2: The “Obvious” Market Timer. “Okay, simple,” I thought. “Let’s just get out of the market when it looks bad!” I coded in the classic SPY > 200-Day Moving Average rule. If the market is in a downtrend, sell everything and go to cash.

This was a catastrophic failure.

It correctly got me out during the COVID crash, but the market rebounded so fast that the slow-moving filter kept me in cash. I missed the entire V-shaped recovery. That single mistake turned a +16.0% outperformance into a -22.7% underperformance. I learned about a painful little thing called a “whipsaw.”


The Grand Revelation: The Flaw WAS the Feature

After testing a dozen other variations (don’t even ask about the “Market Health Score”), a shocking truth emerged. Every single attempt I made to make the model “safer” or “smarter” made it worse.

The original model, my beautiful, flawed “Momentum Amplifier,” was the best one all along.

Its aggressive, “always-on” nature wasn’t a bug; it was the entire source of its alpha. It works because it stays invested through the fear, allowing it to capture those violent, face-ripping rallies that market-timing systems are guaranteed to miss.

So, I reverted everything. The final backtest of the original model is the one I’m sticking with. It has a 50% win rate against the market in different regimes and generates massive alpha when the conditions are right. It’s not a perfect all-weather machine; it’s a specialist tool.



So, What’s Next? (Hint: V2 is Coming)

The journey so far has taught me more than I ever could have imagined. I went from a curious guy with a Python script to a battle-hardened quant who understands the brutal trade-offs of strategy design.

This whole project is what I’m calling Stock AI V1. It’s not a “set it and forget it” system. The best risk management isn’t another line of code; it’s a human pilot with a good checklist. The bot finds the opportunities, but I decide if the weather is clear enough to fly.

And I’m already neck-deep in designing V2, which will explore a “regime-switching” model that tries to be the best of all worlds. Can a bot learn to be a Ferrari in the sun and a Jeep in the snow? I have no idea, but I can’t wait to find out.

Thanks for following along!

Leave a Comment

Your email address will not be published. Required fields are marked *