paint-brush
How I Built A Million Dollar Algo-Trading Strategy Then Lost It Allby@peregrinebuckler
2,041 reads
2,041 reads

How I Built A Million Dollar Algo-Trading Strategy Then Lost It All

by Peregrine BucklerJuly 1st, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

CNN.com will feature iReporter photos in a weekly Travel Snapshots gallery. Please submit your best shots of our featured destinations for next week. Visit CNN iReport.com/Travel next Wednesday for a new gallery of snapshots. Visit www.dailyimpact.com for a gallery next week for snapshots of places to go next week in the gallery.com. Submit photos of your favorite destinations to see next week's gallery next Wednesday. Submit your gallery next Tuesday for next next week. Submit your next destination.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - How I Built A Million Dollar Algo-Trading Strategy Then Lost It All
Peregrine Buckler HackerNoon profile picture

On 23rd May 2021 I awoke at 4.23 am to perform my insomniac routine of checking my Binance trading account, bitcoin had crashed as it so often does. This time was different though, my $1.88 million was gone. I had made a mistake in my code which caused my leverage trading algorithm to miss its stop-loss I and had been liquidated.


You see whilst many will say it’s only money, I had not slept properly for more than half a year, every waking hour glued to my screen. Line after line of code one more line, one line closer to immortality. I had convinced myself that if I make enough money every problem in life will disintegrate from reality. So as that cool 1.88 million vanished in a flash, I re-inherited the everyday anxiety, the questions of purpose, crippling self-doubt and the social anxiety's in a millisecond. It propelled me out of my body and flipped me back facing myself, I pirouetted a frozen with terror stranger, my slouched frame my arms side by side gripping the duvet. I thought to myself ‘this is how it feels to die. The following month can only be described as feeling like someone had actually died. Still, it was only money, now a month wiser, a month poorer and after a month of mourning, I can finally tell my story.


Imhotep - a diamond in the roughI thought maybe I had some of the right ingredients to make it in algorithmic trading. I had worked in architecture, in financial technology, I had learned to code, I had mined crypto with commercial ASICS and I had traded for years. Presuming I had covered some of the grounds necessary to build a truly degenerate trading algorithm. I set to work. It started with a race with myself to build the Valhalla of all algorithms. At peak productivity, I was running 50,000 algorithms. I would run these continuously over six months with only a few select permutations making all the way through the walk-forward testing. One was beautiful, the simplicity of it mesmerizing I thought… First went in the paycheck, then went in the next paycheck, and then another paycheck. Eventually, all my bitcoin went in and by April my account was growing by $10,000 every time I looked at it. And before I knew it at the grand old age of 32, I was a millionaire.




How to build a profitable trading algorithm?


  • Fade your assumptions

  • Aim for robust returns over gains

  • Momentum is an edge

  • Understand what is happening when you push new code

  • Stop-loss > risk / reward ratio > criteria for entries


I have read my fair share of economics, trading, and technical analysis books. I have traded a lot of crypto over the years. But to be honest those only contributed the smallest of portions. I built many that looked great on paper and in back-testing but performed woefully in live testing. My problem was I started by building my algorithms on technical indicators like RSI, MACD, or machine learning concepts. In back-testing, these would not reveal the lag they experience in real-time. I was over-fitting to imaginary timeframes, with no slippage or rate limits and free transaction fees.


What gave me my break was when I started reading economic and finance research papers on trading strategies. In them, I would ‘find’ inspiration then flesh out a strategy and build it into a bot. I would optimize it through back-testing, often combining multiple concepts or stripping them back. Combining the ideas that don’t necessarily reinforce one another on paper but cover different territories is an important aspect of building a robust strategy. Some were terrible. Well, most of them were apart from one that I coined ‘Imhotep’-after the Egyptian architect of the pyramids. You see Imhotep performed better in live testing than it did in back-testing, the inverse is usually the case. Before long I was specifying Ferrari’s and scouting houses in Normandy.



takeProfit = close[1] - d*2
                                                            *The single line that saw Imhotep reign supreme*



What went wrong?

  • I used leverage.
  • I didn’t test my stop loss
  • I didn’t have proper monitoring.
  • I was trading with 100% of my capital.
  • I was an idiot.


You may say well none of the things you should ever do. Yes, when it’s going that well you think you’re invincible. When my stop loss didn't trigger, and as I didn't have sufficient monitoring to alert me, my margin would no longer cover my long position and I was liquidated. I didn't even get a margin call, no email, nothing it was just gone. Then arrived an email from CZ of Binance “We regret to inform you your position has been liquidated” first thing I could think was I have let my family down. My girlfriend, even Freki the dachshund. I had been comprehensively beaten by CZ.


There's no need to fear or hope, but only to look for new weapons.

Gilles Deleuze



So what did I do next? well after a week of complete disassociation from reality, I got back into code I did my best to wipe the loss from my mind by coding it out of the strategy. The results are a lot tamer but I'm hopeful that eventually, I will be able to write the second part of this article, detailing ‘how to make it all back’. Stay safe out there and please don’t trade with too much leverage.



Some calmer and more refined versions can be subscribed to HERE