Bitcoin Trading with Machine Learning Anomaly Detection

Crypto-ML has been generating machine learning-based trade signals for its customers since February of 2018. During this time, we have logged strong trade results, showing the advantage of having a systematized approach to capturing wins while also minimizing losses.

Important: Crypto-ML has since upgraded to its 5.0 release, which upgrades the prediction engine to a Deep Neural Network. Read more here: Machine Learning Upgrade to 5.0: Deep Neural Networks.

We are pleased to now release a next-generation machine learning model that builds on the experience, learning, and feedback we have captured. This new system, which focuses on anomaly detection, is described below in this detailed post.

While this post is extensive, our customers and community have called out a clear desire to understand our approach in-depth. Apart from helping achieve our mission of being transparent, this is also the only way to bounce our concepts off of bright and enthusiastic people who will invariably help us find new opportunities.

Bonus: do you want to try creating a machine learning trading model on your own? Check out our guide: Bitcoin Price Prediction with DIY Machine Learning in Excel.

Crypto-ML’s model releases 1 through 3

Before discussing what has changed, it’s valuable to look at the production models 1 through 3. These models have fueled our results thus far. Fundamentally, we used machine learning to create a superset technical indicator that can grow and evolve.

Crypto-ML 2019 Year-to-Date Performance and Updates

To create these models, Crypto-ML used a broad array of technical indicators for training. As most traders and investors know:

  • Technical indicators often conflict
  • Some technical indicators only work in certain market conditions
  • It’s hard to know what parameters are optimal for each indicator (e.g. should I use a 10-day SMA, a 30-day SMA, or a 8.25674-day SMA?)

It is impossible for a human to sift through all of this data, try countless permutations, and answer these questions.

Using a machine to answer crypto traders’ questions

But this is an area in which computers can really shine. They can parse through the massive amount of data, find patterns, and show us what we should pay attention to when.

Superset indicator model

As a result of this deep learning and research, our models have become an amalgam of an ever-evolving mesh of indicators. Consider our current model to be a lengthy, sequenced mathematical equation with variable parameters.

In general, but not always, this model tends to favor a trend-following (momentum) approach. That is, once price starts moving up with enough momentum, our signals open a trade. The ideal result is to capture a portion of an uptrend, but not necessarily the entire move.

While each cryptocurrency uses the same mathematical and logical framework, each can determine its own parameters and weightings. As such, you may have noticed our Litecoin calls taking more of a “support and resistance” (counter trading) approach recently, whereas the others are typically “trend following.” The underlying model is flexible enough to allow for these differences.

To avoid large losses, dynamically-established stop losses, trailing stops, and other mechanism help protect the wealth that was generated.

Looking beyond technical data

As you can see, our current models are technical-analysis oriented.

What they don’t look at are the fundamentals. And they do not look at unusual events that may precede price changes. Our research and development team has focused on looking into these areas. As a result, we have a completely separate model, which is the new anomaly detector.

New anomaly model

Outside of technical indicators, the other way to analyze an asset is to look at developing “fundamental” scenarios in an attempt to identify when they are leading to an imbalance.

“Bitcoin Is Poised For Sudden, Major Move. …the bitcoin and cryptocurrency market could be poised for a sudden price swing, though it’s not clear which way it will go.” –Forbes: October 22

This quote from Forbes illustrates anomalous behavior while also showing the uncertainty analysts have about how the fundamentals of cryptocurrency interrelate.

Can a system provide us insights into the data? Can it help predict these events and reliably predict the direction?

What is anomaly detection in machine learning?

Anomaly detection looks for unusual variances in data that tend to precede unusual changes in an objective value.

In our case, the objective is the price of Bitcoin. To put this more clearly, we’re looking to identify unusual situations that tend to precede unusual changes in Bitcoin price.

Fundamentals

Looking at the fundamentals of Bitcoin and other cryptocurrencies can be challenging. We don’t have the traditional data that you would on other investments, such as cash flow, debt servicing, management, earnings, etc… We don’t have quarterly reports to review.

But with Bitcoin, there is a lot of data available that can serve as a proxy for its adoption and fundamental performance. This data should give us a sense of its supply and demand. For example, we can look at:

  • Price relative to a basket of traditional currencies
  • Price relative to other cryptocurrencies
  • Trading volume
  • Transaction volume
  • Transaction fees
  • Miner activity
  • Miner revenue
  • Quantity of active addresses
  • Consolidation of active addresses

A recent article in Forbes covers a high-level view of Bitcoin fundamentals. Coindesk also provides good insights into Bitcoin fundamentals.

“Many analysts noted the importance of user adoption, which is crucial to a cryptocurrency’s long-term viability. As for what drives user adoption, the analysts said money can have many uses. At its most basic level, money is a store of value, a medium of exchange and a unit of account.” –Coindesk

Additionally, you can find a variety of great data points on Blockchain.com.

Big data and machine learning

Armed with a broad set of data, we began asking what changes matter. Specifically, how do changes in past data affect future price?

For example, if trade volume has steadily been increasing, but suddenly spikes an anomalous 20% in one hour, is that significant? Does that mean anything for future price movements?

When you consider all of the interrelations, this question is too complex for humans to answer.

We need a machine to crunch the numbers and uncover variances that matter. The role of the humans involved is to structure the data in such a way that it can answer the questions posed. We want to expose unusual variations in current and past data that predict a variance in a future set of data (the objective).

Armed with this information, machine learning can analyze the data points and then build a model that sequences them in a way that provides a set of predictions.

Price

As expected, price (relative to a basket of currencies) plays a large role in determining future price movement. That is, if we see an anomalous move in price relative to various past time periods, the likelihood of a jump within the targeted future time frame is higher.

While some people may think of price as a single indicator, it is actually a summary of supply and demand. As such, we fully expected it to have heavy influence. When you begin comparing price against numerous other currencies, you get a concise view of the sentiment people have toward the asset.

In this way, price is not just a technical indicator, it is a summary of sentiment, value, and more. Anomalous movements in price may therefore indicate imbalances in the big-picture view of Bitcoin.

Volume

Volume was also an expected factor. Anomalous behavior in volume tends to precede unusual price changes.

Time

Surprisingly, there are also strong patterns related to time. The month, day-of-the-month, day-of-the-week, and hour-of-day all come together to make up about 29% of the importance of the model. This means big moves tend to happen at predictable points in time.

Time was initially just an observation our team had. It seemed as though big moves happened on certain days, such as Sundays or near contract expiration.

Based on these hunches and insights, it made sense to supply the machine with time-based data points.

None of us expected “time factors” to be so important. But that’s the advantage of letting machines run wild.

After seeing the results, additional research confirmed others have studied this unique behavior and certain time-based milestones do, in fact, tend to precede anomalous behavior.

Data limitations

Looking at the list above, you may think of thousands of items we aren’t considering.

A commonly questioned item is social sentiment. This is excluded based on our machine learning research. The reason is social trends follow price changes. That is, big moves in price tend to predict news, Tweets, and Reddit discussions. That’s the opposite of what we need. Social sentiment represents followers, not the “underground chatter” of traders before they make big, collective moves.

While many data points are invalidated by machines, another major limiting factor is data frequency. Since our models cater to traders, they must be able to access live data. This is a challenge because most data points are only available on a daily (once per day) basis. Further, the release of that data may occur 3-8 hours after the data point is determined.

This means that in a worst-case scenario, a critical event happens, but the data point isn’t available to our models until 32 hours afterward. That is too late and not acceptable for predicting price movements for traders.

{
"node_threshold": 462,
"max_training_time": 3600,
"optimize": true,
"stat_pruning": false
}

For longer-term investors, considering a broader set of data supplied on a daily basis may be valuable. Indeed, this is how most investment strategies are managed. However, statistics become our enemy at this point. Bitcoin has simply not been mature long enough to have enough daily data for machine learning models to be effective.

If you see someone say machine learning doesn’t work for cryptocurrency, I can tell you three things about them:

  • They don’t know how to structure the data, objectives, and equations.
  • They don’t understand how to time-base fundamental changes.
  • They are looking at daily data.

Because of these factors, the universe of data we consider for our models is limited.

The model

As we let our machines optimize the approach we take, we end up with a model streamlined down to 9 variance calculations. The results of these calculations are then passed through a decision tree which outputs the predicted price of Bitcoin for a given period in the future.

We take it one more step and apply thresholds to the predictions. These thresholds are parameters as follows:

  • If the prediction exceeds a certain value, then a trade can be opened.
  • If the prediction is below a certain value, the trade can be closed.

Additionally, we establish two more parameters:

  • If we hit a stop loss level, the trade can be closed.
  • If we hit a trailing stop level, the trade can be closed.

Based on the above, we have a model and four parameters. We once again use machines to optimize those four parameters; it is impossible for humans to do so effectively.

Robust machine learning model

Now that we’ve covered the details behind how this new model is structured, it’s important to get to the “so what.” So, why is this new model valuable?

The answer comes down to its robustness.

If we look at a technical indicator like the Stochastic Oscillator, you see it is listed with two parameters, such as STOCH(9,6) in the image earlier in this post. These two values represent period counts that work behind the scenes on the Stochastic calculation. In this case, you are considering a 9-day period and a 6-day moving average. However, the commonly-used values are 14 and 3.

So which numbers are better? And under what circumstances?

As noted above, setting these parameters is best done by a machine. But, the best values depend on the situation. The problem with most technical indicators is they are not robust. Their parameters need to be optimized and those parameters go stale as the market evolves.

Non-robust tools

One indicator may work in uptrends. Another may work in channeling markets. And the parameters you set may make or break the results.

If a tool only work in a few situations and the parameters need to be constantly adjusted, you could say the tool is not robust.

The risk of relying on a non-robust tool is that conditions may have changed, yet you do not realize it. Instead, you start to see your trade performance drop off with mounting losses.

People make this mistake all the time with backtesting. They run a simple technical indicator against past data, playing with the parameters a bit. Eventually they find a parameter combo that seems to work. Maybe STOCH(9,6) produces major losses but STOCH(11,6) produces decent results. Excited by their finding, they begin trading with that indicator only to find it doesn’t work going forward.

Crypto-ML 3.5 model robustness

By comparison, our 3.5 models have 5 parameters that feed into 21 calculations. These hold up pretty well in a variety of market conditions. They are far more robust than traditional technical indicators. However, the parameters are optimized differently for each crypto. And the parameters do adjust as the macro market changes.

If you have followed Crypto-ML for a while, you have likely seen changes in behavior and changes in factors such as frequency. This is typically a result of changing parameters.

So while the 3.5 models are robust, they do still need to react to macro market changes.

Anomaly detection robustness

What if we had a model with the same parameters that worked across multiple crypto? And what if that same template worked in different time frames and different market conditions?

That would be a highly-robust model.

It would be extremely reliable and you would feel much more confident in its capabilities.

This is the real value we receive with our anomaly detection model: it is exceptionally robust. With the exact same model and exact same parameters, we get positive results across different time frames, different market types, and different various cryptocurrencies.

In other words, it seems to truly understand the fundamental behavior of the cryptocurrency markets.

Testing machine learning

There are many ways to test your model. Common approaches we utilize are:

  • Training the model with a random subset of the data and then testing it against the excluded subset.
  • Training the model in one market condition (bullish) and testing in another (bearish).
  • Training the model in one time frame and testing in another.
  • Training the model with one cryptocurrency and testing against another.

As we go through each of these tests, we validate with the statistical measures appropriate, such as error, variance, and R-squared. But given the massive size of our data sets, we are primarily interested in one metric: profit.

If we have a model with set parameters that can generate profit in each of those testing scenarios, we have something extremely robust.

You can see how strongly this approach differs from the common mistake people make with back testing, which we described above.

Performance expectations

The real measure of this model will be known in a year. Between now and then, we’ll see real results roll in, which will help us build a clearer and clearer picture.

But in the meantime, we can reference how this data would have performed against past data. We can do the same exercise for our current models and share the differences.

Portfolio profit

This is the objective for our models; they should grow the trader’s account value over time. The anomaly detection model performs multiples better. This is true in all market conditions and across all time periods.

By this measure alone, the model is a success.

As a secondary metric, we can look at the he average individual trade return. As can be seen in our Trade History, it doesn’t take big trades to grow account value. Rather, it takes consistent gains. When it comes to the average trade, results are similar. The current models range from about 3% to 4% depending on market conditions. The anomaly detection models range 2% to 6% depending on market conditions.

Frequency

The anomaly detection models issue almost exactly twice as many trade alerts. You can generally expect 2-4 trades per month.

It should also be noted that trades are a bit less regular than the current models. If you’ve followed Crypto-ML signals for a while, you have likely noticed the signals wave in and out. You can begin to get a sense of when they’ll generate. However, the anomaly detection is more exceptional in behavior and therefore does not support concepts such as the Trade Meter.

Wins and losses

The anomaly detection models do issue losing trades. If you are looking for a system that generates only wins, you will need to look elsewhere. The win ratio (wins divided by total trades) varies between 51% and 62%.

The lower end of that range occurs during bearish market conditions and the higher end occurs during bullish markets.

As a comparison, our production models run a win ratio between 29% and 44%, depending on macro conditions. What this tells you is that the new model is more consistent across market conditions, which matches with other testing and data points.

Also, I cannot stress this enough, the anomaly model is realizing these tighter numbers without any variation in the model or parameters. In order for our existing models to achieve their numbers, they need to continuously react and evolve.

The other interesting finding from this is the model doesn’t have to be right all the time or even most of the time.

In fact, Crypto-ML R&D has experimented with optimizing models to “win ratios” and “average trade.” While these two metrics can be optimized significantly, the real result we’re seeking (account value) actually suffers. As we dug deeper, the reason is you actually want the model taking risks. By avoiding risks and only taking “sure bets,” the model misses opportunities.

As noted earlier in this article, machine learning systems are only as good as the questions being asked and the data structure being provided.

Future direction

The anomaly detection model described in this post will roll out as a long signal for Bitcoin. Future functionality will include:

  • Auto trade (November) – update: Auto Trade is live as of October 31
  • Visualization
  • Expansion to other cryptocurrency
  • Combined long and short signals
  • Application to longer-term investor time scales

Look for more information and dates in the near future.

Availability and getting started

The Bitcoin Anomaly Detection model will be available this week (by October 26, 2019) as a new Beta BTC signal on the Member Dashboard.

It will support long calls to start. If you are signed up for long notifications, you will receive the Beta BTC notifications by email and mobile alert, just as you would for our current long signals.

Auto Trade is also available and listed as BTC-BETA in the dashboard.

For access, the following memberships are needed:

And of course, this post can’t cover anything. If you have questions, comments, or suggestions, please let us know on the Community Forums!

About Crypto-ML

Whether you want to own 1, 10, or hundreds of bitcoins, we strive to help you realize your goal faster. Learn more and join for free.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to the Newsletter

Join 7k+ working professionals to "The Five-Year Plan". Every Saturday morning, you'll receive one actionable tip to create life-changing wealth in crypto.

Your Saturdays Just Got More Powerful!

Every Saturday morning, you'll receive one actionable tip to create life-changing wealth in crypto.