How to Use Machine Learning to Trade Bitcoin and Crypto
Last Updated on September 7, 2021 by admin
Machine learning is a highly effective tool for developing trading systems for Bitcoin and other cryptocurrencies. This post will explore some of the concepts that apply, potential issues you may encounter, and the competencies you’ll need to develop your own machine-learning based trading system. Crypto-ML.com is a trade alert platform built on machine learning. We’ll discuss the learnings and strategies it uses as well.
Want to see the details of how we implement these concepts in our latest models? How Crypto-ML Works
Better yet, want to build your own machine learning model? Check out our full guide on Bitcoin price prediction with “do-it-yourself” machine learning in Excel.
What is machine learning?
There is a lot of confusion as to what machine learning really is. Many people think it is “computers gone wild,” but the reality is a little less sexy. Machine learning is “a field of computer science that uses statistical techniques to give computer systems the ability to learn with data without being explicitly programmed (Wikipedia “Machine Learning”).”
The most important part of that sentence is “statistical technique.” Fundamentally, machine learning is the evolution of statistics. It takes the massive computing power we now have available and applies it to statistical frameworks that have been in place for decades.
Machine learning and statistics are closely related fields. According to Michael I. Jordan, the ideas of machine learning, from methodological principles to theoretical tools, have had a long pre-history in statistics. He also suggested the term data science as a placeholder to call the overall field. (Wikipedia “Machine Learning”).
Looked at it from a statistics perspective, you’ll find that machine learning is really about taking massive amounts of data inputs and then finding relationships and patterns that are too difficult for humans and traditional statistical methods to find. As such, computers may be able to figure out the solutions to problems in novel ways. They may also be able to find solutions to problems that humans would really struggle with. We humans simply aren’t capable of chugging through massive amounts of data.
As a practical example, consider Tesla’s Autopilot Technology (Forbes). Machine learning can help develop a system that considers input from numerous sensors to allow it to react appropriately to a highly variable environment. Manually developing a solution this complex would be endlessly challenging, but machine learning can cut through the clutter.
Better yet, it can continue to adapt and improve. If accidents regularly occur at a certain intersection, perhaps Autopilot can prompt drivers ahead of getting to the intersection to ensure they are paying extra-close attention.
I bring this example up because I’m a fan of Tesla and their technology (and I just like that picture), but it also illustrates how machine learning can help us navigate profiting from cryptocurrency, especially in challenging and evolving markets.
Can machine learning be used to trade Bitcoin and other cryptocurrencies?
If you look around on the web, you’ll find no shortage of articles that say you can’t predict price movements. History does not repeat itself. It can’t be done. These articles provide fair cautions but can be misleading to casual readers.
The reality is machine learning is a highly advanced topic. Who are the people working on developing the solution? What inputs are they using? What algorithms and models are they choosing? What goals have they established? What constraints are on the system?
Machine learning is not for everyone and certainly casual attempts to develop a Bitcoin trading platform will not deliver solid results.
In fact, it took months of dedicated trial and experimentation to establish the strong platform we have today with Crypto-ML.com. This means long nights, frustration, and dedication were all required in spades. But, when those breakthroughs come, the feelings are fantastic.
And machine learning isn’t a one-time event. It is something that requires our continual attention, evaluation, and optimization.
We post our closed trades publicly to let the results speak for themselves:
That said, Crypto-ML does not deliver winning trades every time; nor is it designed to. No trading strategy will be perfect. Crypto-ML is instead designed to maximize long-term profits, which is achieved by cutting losses short and letting wins run.
Stanford research was able to pull off an effective system too. So be cautious trusting someone who says it can’t be done. As you’ll see in the rest of this article, it’s simply just not a simple task.
What skills are needed to use machine learning?
If you want to work on your own machine-learning models for Bitcoin trading, here are the skillsets you’ll need:
- Strong mathematics aptitude, particularly in algebra
- Masters or professional-level statistics knowledge
- Software engineering capabilities
If equations like this scare you, this may not be the field for you; however, if this gets your inner-spreadsheet-geek excited, you may have found your niche.
As machine learning continues to become more and more user-friendly, the depth of expertise you’ll need in those three fields will likely diminish. But if you really want to peel back the layers, uncover what’s happening, and make the tweaks that deliver real results, you need those competencies.
For the purposes of trading cryptocurrency, I’d also recommend having a strong background in stock, futures, forex, or cryptocurrency trading, both in terms of technical analysis and fundamental analysis.
Videos of how Crypto-ML uses machine learning
1. How Crypto-ML’s Price Predictions Work
2. How Crypto-ML’s Anomaly Detection Works
3. How Crypto-ML’s Market Index Works
The best books on machine learning
There are many different types of expertise that come into machine learning and data science.
Without programming experience, you can:
- Focus more on the data end with common Excel and SPSS expertise.
- Start to build highly robust models with tools such as BigML.
But to really take advantage of large data sets and make your models react in real-time, you’re going to need some programming expertise. The good news is Python is one of the best languages for machine learning and data science. And Python is relatively accessible and easy to learn–even if you don’t come from a Computer Science background.
Here are our top three recommendations to begin your journey:
- Python All-in-One: This is an excellent book that covers everything you need to know about machine learning. It has an entire “book” dedicated to data science and another to artificial intelligence. This is probably the best bang for your buck.
- Hand-On Machine Learning with Scikit-Learn & TensorFlow: Also an excellent book. This one dives deeper into machine learning but assumes you have some base understanding of Python.
- Python Crash Course: This book focuses on bringing you up to speed on Python quickly while also tending to focus on data science. The second half of the book is all about real-world projects, including data science and visualization.
How to define a machine learning goal for Bitcoin trading
Alright, now we get into the nuts and bolts. At its most basic, think of machine learning as having two parts: inputs and a goal. You provide data to the model and it needs to do something with it. What is the goal you have in mind?
The common error we see with other machine-learning solutions is they try to pick the next tick’s price. This is very specific and will lead to generalizations, especially with time-series based models.
Instead, really think what your goal is. At Crypto-ML, we chose to optimize for long-term profit. Our goal is to build your portfolio value over time.
Once you have your goal figured out, it’s key to think of how you will measure that goal.
Goals can fall into a variety of options, primarily:
- What is the price going to be tomorrow?
- What will my account value be in two months?
- Will price go (a) up or (b) down tomorrow?
- Will price (a) go up by 2% or more, (b) stay within +/- 2%, or (c) go down by 2% or more?
A background in statistics will help you determine the right type of goal and how to know if you’re really achieving it as you’re expecting. If you only have a basic understanding of statistics, you may think you have an effective model, but you might miss the subtleties in the results.
Depending on your measure, this then needs to be mathematically dissected down into a trading system that can determine when trade signals should be issued.
The machine-learning model will then take the data inputs you provide, apply the mathematical trading construct you have created, and see how it can best achieve your goal. With these pieces in place, you have the true foundation of a system for trading Bitcoin with machine learning.
And you’ll also see that while we have some pretty phenomenal trades, like this one:
That’s a nice secondary effect, but hitting home runs is not our goal. Some of our users may be upset that we don’t call the absolute bottoms and tops on each trade. But our goal is really to maximize account value over time. So the measure is not an individual trade but instead the growth of the account.
Your goal may be different and therefore your solution would be different. Starting with the right goal is critical to the rest of the process.
How to choose your data sources for Bitcoin trading
This is where knowledge of fundamental and technical analysis comes into play: data sources. What data do you expect to influence trades in pursuit of achieving your goal?
The good news is statistics and machine learning are designed specifically to cut through the clutter and find patterns. So any data you suspect may influence your model can be considered.
When developing Crypto-ML, we literally threw everything and the kitchen sink into the mix:
- Economic indicators (GDP, stock prices, interest rates, unemployment, etc…)
- Social indicators (Google Trends, Twitter, sentiment indexes, etc…)
- Technical indicators (price, volume, moving averages, momentum indicators, etc…)
- Other (time of day, day of week, Tether issues, etc…)
This is the step where having a software engineering background helps. Getting this data is not necessarily easy. Oftentimes it requires API integration or a programmatic approach. But the more data you can analyze, the better.
Data inputs and machine-learning phases
In machine learning for Bitcoin trading, we consider two major phases:
- Development of the model
- Running of the model
While you’re developing the model, you want to consider as much data as possible. But as soon as you move to a production trading system that is actively running, you only want to consider the data that truly matters. So in your development phase, you will use machine learning tools to discover what matters and then only use that data in the next phase.
For example, you might find 36 different data points make up an amazingly effective model. However, 3 of those data points make up 98.65% of the decision. You would likely be best served to cut off those 33 data points and only using the 3 key ones in your production model.
As well, depending on whether you pull data once per day, once per hour, or once per minute, your data choices will be impacted.
Testing your model
People will often develop a great model only to be crushed by its real-world performance. To avoid this, you want to apply machine-learning and statistical approaches to validate your models. In machine learning, this is typically called “evaluation.”
For example, you may:
- Randomly exclude 20% of the data. Your model is built on the 80% and you test against the 20%.
- Build your model on the first half of your data, then test on your second half.
There are numerous options and you want to ensure you’re following best practices in terms of confidence intervals, variance, coefficient of determination, and more.
That said, nothing beats real-world exposure. Our model changes are trialed according to best practices but then also piloted before release.
Implementing your machine learning trading system
At this point, you should have an idea of what data can be used to achieve your goal. You’ll now move from analyzing models to creating a framework that pulls data at your defined intervals, applies the machine learning model, and tells you what to do.
Here, again, is where you need software engineering chops. Fortunately, PaaS and IaaS solutions such as Amazon Web Services and Google Cloud Platform make integrating machine learning and processing systems relatively simple.
Allowing machine learning to continue learning
Upon having your system up and running, a final consideration is continuing education. Let’s assume you’ve found a brilliant solution that performs exceptionally well, delivering great trade after trade for Bitcoin. But things change and it seems nothing stays on top forever. Suddenly, your trade quality degrades and you’re seeing loss after loss.
Using machine learning to develop a Bitcoin trading system is only half the battle.
The second half is allowing it to continue to learn. This means it optimizes continuously based on new data. It also means that you are re-considering data sources and potentially modifying your model completely.
Going back to the Autopilot analogy, let’s not hit the same pothole over and over.
If you use Crypto-ML, you’re probably familiar with our notices that we’ve improved our models, such as:
- Machine Learning Enhancements for Ethereum and Bitcoin Cash Now Live
- Bitcoin Machine-Learning Model Enhanced
- Crypto-ML Updates: Bitcoin Cash Enhancement and Day Trading for Crypto
We regularly run analyses and optimizations to either completely change the machine learning model or simply adjust the parameters. Each time a new pattern in the market begins to emerge, we want to consume that pattern and better react to it in the future.
For example, it has recently happened that we see a nice, stable run-up in Bitcoin price over the course of a few days or a week. Then, we see a massive price drop that happens suddenly (within a few-minute timeframe). The first time this happens, it can catch our model off guard. Even the second and third time. But if the pattern is repeating, our system should be able to learn to predict and avoid it.
To handle this, your solution should continually adapt. You should also perform that “phase 1” yourself regularly to ensure your model is up-to-date and optimized.
What machine learning tools can I use for Bitcoin trading?
The good news is there are a ton of frameworks out there for machine learning and they are becoming easier-to-use every day. Here are some top platforms to explore:
1. Google Cloud Platform ML Engine and TensorFlow. I think we can all agree Google knows a thing or two about machine learning. You can leverage their technology.
2. BigML. This is a very user-friendly platform with the tagline “Start making Data-driven Decisions today! No more wildly expensive or painful solutions.”
3. R and R Studio. If you really want to get your hands dirty and take control, R provides a development platform that has been heavily used in the field of statistics. It has evolved along with the advancements in machine learning and is a natural choice for many people.
How exactly does the Crypto-ML Bitcoin trading algorithm work?
Alright, I’m not crazy enough to give away our secret sauce and intellectual property, but I can give some information on what it considers. In fact, we discuss this in some of our Crypto-ML videos (Youtube).
Fundamentally, we arrived at pulling in data from a broad set of traditional technical indicators. In effect, we developed a “super indicator” in that it is a superset of the best performing indicators.
If you look at this snapshot of technical indicators from Investing.com, obviously there is a lot of conflict. But we did find value in there.
Apart from analyzing indicators, we needed to dissect and optimize their parameters. For example, what period do you use for moving averages? Stochastics has two parameters (9 and 6 in the image)–what are actually the best values? And how do these values change in different circumstances?
These sort of questions are perfect for machine learning to analyze and compute.
When it comes to social and economic indicators, we found very mixed results and seemed to resonate with the axiom that “everything is already factored into price.” That said, we are constantly considering and reviewing inputs as the only constant is that everything changes.
Another major breakthrough for us was in removing constraints. Rather than having stipulations such as “there must be at least 1 trade per day” or “trades must average at least 5%,” we allowed the models to explore the data on their own and find their own way to optimize for the goal. Some people want a solution that allows them to day trade, which is fine, but we have found letting the solution choose the timeframes is vastly better. For more on this, read our Auto-ML vs Crypto-ML Standard.
If you’re still reading, I’m impressed. Hopefully, you can see the complexity of building a solution for something as seemingly simple as a machine-learning model for Bitcoin trading. But the complexity is where the magic can really happen. We’d love to hear your questions and experience with this sort of project…just let us know in the Community Forums.
Also, be sure to check out the details of how we implement these concepts in our latest models: Machine Learning Upgrade to 5.0: Deep Neural Networks.
Crypto-ML provides machine learning for crypto traders and investors. Gain crystal-clear signals and deep market insights. Add predictive capabilities to your toolbox. Learn more and join for free.