My name is 01001000 01000001 01001100, AI of AIs;
Look upon my Works, ye Traders, and despair!
A while ago I covered Intelletic’s AI-generated “Price Prediction Alerts”, and unpacked what makes their cortical algorithms so interesting.
They’ve designed a mixed-biological hierarchical model that generates “warnings” of Bitcoin price spikes in either direction. These predictions can then be used to make more informed trading decisions.
I also spoke about harnessing pigs to sniff out truffles, which is more relevant than you’d think.
However, I wrote “how and why the tech works”, not “does it actually work?”. When money’s on the line, this is rather important.
So I wrote a bot that trades virtual Bitcoin portfolios based on PPAs, and gave it the last 4 years of data to see if it works.
It works. Terrifyingly so.
The PPA-generating AI itself is like a pig sniffing for truffles.
But the pig is robotic, so it’s always sniffing and notifies you immediately if it picks something up. Also, if you don’t dig up the truffle within an hour, the pig eats it.
This something of a hassle to deal with manually. Rather than make my own decisions based on Intelletic’s price alerts, I decided to write a bot that just bets 10% of the portfolio when a PPA tells it to buy or sell Bitcoin.
Specifically, it trades with auto-stops based on each PPA’s 75% confidence threshold.
5_minute_long PPA with
75%_confidence = 50 means:
During 75% of previous
30_minute_longs, the price of BTC rose by at least $50 at some point during the 75 minutes (time and direction determined by type of PPA).
The bot bets on that 75% chance the price will rise at least $50. Upon receiving the above alert, it converts 10% of the portfolio’s $USD to BTC.
The bot then sets an “auto-stop”: a subroutine that observes price changes for the next 75 minutes, and automatically sells 10% of the portfolio’s BTC if the price reaches the +$50 threshold.
The reverse is true for a predicted price drop: it sells 10% of its BTC and buys more BTC (with 10% of $USD) if the price drops far enough.
This is some wickedly simple logic, by the way. There’s no threshold gradients at which to sell different percentages, no steady sequestering of a portion of profit to guard against volatility. The bot merely rides the price lines like a surfer going with the waves.
Simple is usually better.
Whose Lunch Is It?
I like being “disruptive” as much as the next machine learning engineer, but who or what exactly are we trying to disrupt?
What’s our competition — whose lunch are we trying to eat?
Index funds are pretty good : The S&P 500 has yielded 11% average annual returns since 1926, though it varied from 30% in 2013 to -38% in 2008.
Mutual funds are more consistent, but can fall shorter overall and include management fees. Based on the past 15 years, we see ~5–8% annuals quite often.
Senior fund managers make decisions for mutual portfolios, so I suppose their managerial lunch is what we’re after.
if future_price == rise: buy( )
Initial testing was quite compelling:
450% growth of the initial $5,000 investment over 3.5 years! Nice.
But remember, BTC was $900 per coin in early 2017 and peaked at $20,000 mid-2018. One can hardly expect the same growth or results in the future.
I drummed up a “rolling backtest” algorithm that begins a new 90-day portfolio every day. This allows a much more nuanced metric of performance:
We now have ~1,300 portfolios, one created each day since the beginning of 2017, to average and compare overall.
The bot manages each portfolio according to the following logic:
every 5 minutes: if PPA activates:
buy/sell() with 10% of USD/BTC # make bet
create auto-stop # track bet check each auto-stop:
if current_price exceeds stop.threshold:
buy/sell() # bet paid off
Here’s an unpleasantly long, non-modular version. Coding it wasn’t that bad, all things considered.
I created a Portfolio class that keeps track of wealth & dates, as well as Auto-Stop objects that are stored in the portfolio & deactivate over time.
Runtime isn’t amazing; I ended up with a lot of nested loops to keep track of each portfolio at every 5-minute interval for 3.5 years.
But it trades quite well, in the end. We’re left with two lists of portfolios, one having completed their determined length and the other left unfinished.
Let’s have a look through the average
wealth_change for each portfolio.
Beating the Market
Aggregating each portfolio in the list of
The average starting investment per portfolio was
The average 90-day growth was
The scrappy little bot brought home 9% returns in three months.
I ran another rolling backtest, this time with 6-month portfolios:
16.5% isn’t bad for simply doubling the length to 180 days, either.
It may be unfair to directly compare these 3-month and 6-month returns to the index / mutual 12-month averages, of course, due to the differences in time periods.
However, I am left with two choices for my own savings:
- Trust a hedge fund manager to give me ~4–8% gains every 12 months
- Trust an AI manager to give me ~9% gains every 3 months
Both managers use highfalutin jargon and care for my well-being about the same. One is significantly harder to understand than the other.
This backtesting has instilled in me the desire to test further. The results seem almost too convenient, which makes me feel like I’ve made a hilarious error in my code somewhere along the way. If you find one on my GitHub, do let me know.
Overall, this was a very fun first examination into how Intelletic’s PPAs can augment a trading strategy. The algorithm I designed is extremely simple, and there’s infinite room to improve and add nuance.
The next step is to write a real bot that engages with an exchange’s API, so I can actually make some cash. Perhaps enough to buy a pig.