Vibe Coding my trades

For a few years, I have been following Garret Baldwin’s Substack and trading on momentum, but I have always struggled to keep emotions out of my trading. I would exit a position early after a decline, only to see it climb the next day again, or I would stay in a losing trade for too long. So I decided to outsource decision-making to a cold, dead, lifeless Python script.

Now, I had never used the Schwab (the platform I use) API and SDK for anything, and with a demanding job and 3 kids, I wasn’t going to write this thing, but ChatGPT would. Back then, one of the O3 versions was pretty decent at coding, and over a MEX-EWR flight, I had it do the first draft:

  • Authenticate to Schwab (the model guided me through the whole account setup process)
  • Get a new session for my account (it figured out that the API uses a hash of the account, which would have probably taken me hours reading StackOverflow (remember StackOverflow?) and Reddit posts.
  • Get the quotes for a list of symbols
  • Define the stop (in this version, it was the higher of a 10 exponential moving average and a chandelier stop)
  • Create or update the stop market order

It was pretty cool! It was mesmerizing to have that ready in the span of a 4.5-hour flight! It even used dotenv for the configuration and to keep secrets in a safe spot, and structured the whole repo for me. Of course, these things have gotten so much better in the last year that it’s no longer impressive, but back then, that was my aha moment with vibe coding.

In time, I have been adding some stuff. When Cursor introduced agent mode, I (well, Claude Sonnet) did a whole refactoring. I added three strategies: loss-cutting to limit downside, a break-even conservative stop to keep a tight stop if the ticker doesn’t take off, and a chandelier stop to trail winners and not sell too early.

At this time, my experience has been much better. I know buy (if momentum is green) and run the script daily after the close to update my stops. I also added an export feature to upload the trades to my Databricks Free Edition account and built a tracking dashboard. Today (on another MEX-EWR flight), I added a giveback percentage feature to limit the profit I give away if a runner that has been running for a while falls too fast, too suddenly.

The results have been pretty good as the script has improved! Per my Schwab dashboard, my “play portfolio” (I keep the serious stuff in boring AF index funds) has been beating their “Total Return Aggressive” benchmark by a solid 40 points, and the S&P 500 by 24. Of course, sample size is one year, results may vary, past results don’t guarantee crap, and using it is terrible advice (of the non-financial kind).

But here is the repo, anyway.


Hello, World

Firsrt micro.blog post!