The return rate is 29%! Great God uses sentiment analysis to create a bitcoin trading algorithm

Anyone who has played stocks knows that the volatility of the stock market is affected by various factors, and it has strong randomness and is difficult to predict. The emerging cryptocurrency market is very different from the stock market and is more difficult to predict.

Because the traditional method does not work, foreign netizen Marc Howard has taken a different approach to predict the volatility of the cryptocurrency market by analyzing the public's sentiment towards the cryptocurrency. In the 90-day experimental cycle, this method achieved a return on investment of 29%. How did he do it?

Let's take a look.

When I first started to contact cryptocurrencies, there were some problems that bothered me:

  • Can we really predict the price of Bitcoin?
  • Can the data disclosed by Google Trends Service reflect the general ups and downs of Bitcoin to some extent?
  • Can we build a reliable trading model that predicts market trends?

At the time, I set myself a seemingly unreachable goal, trying to understand the volatile and seemingly unpredictable market of cryptocurrencies .

Of course, I am not self-sufficient. The cryptocurrency market is full of charm, and many traders are intoxicated. Many traders try to uncover the mysterious veil of the cryptocurrency market through technical analysis, while some traders are clever and copy the basic analytical theory in the stock market.

However, the results are not optimistic, and no magical trading model can always beat the market, the "invisible hand." In principle, there are too many factors that may cause fluctuations in the cryptocurrency market . This market has a strong randomness, and even the best artificial intelligence-based trading models cannot guarantee continuous profit .

And I took a different approach and started building a trading model from another angle. This trading model is very simple, and in this article I will show my ideas in the most clear way .

It should be noted that my trading model is still a semi-finished product under development. Although it shows strong predictive ability in simulation experiments, it is by no means foolproof. If you use my trading model, please take risks at your own risk.

a trading model that defeats the "invisible hand"

According to my assumption, this trading model should be a relative consistency indicator for bitcoin prices, and I am constantly testing and correcting this trading model.

In this 90-day simulation, I “buy” a bitcoin worth $100,000 and make a buy/sell decision made through a trading model with a final return on investment of 29% .

However, as a simulation experiment, the profit here does not deduct the handling fee that needs to be paid to the cryptocurrency exchange during the actual transaction. This huge handling fee makes me eagerly look forward to the centralization of the cryptocurrency exchange.

The trading model was inspired by Willy Woo's work, and Willy first proposed using Google Trends services to predict the direction of bitcoin prices. I made some improvements based on his work, the specific method is as follows.

First, look up the search trends for "Bitcoin to US Dollar Price" and "Buy Bitcoin" in the last 90 days via Google Trends Service:

Search trends for "Bitcoin to US Dollar Price" and "Buy Bitcoin" during the 90 days from July 7th to October 4th

Secondly, I noticed that when the ratio of "bitcoin to dollar price" to "buy bitcoin" is less than 3:1 (accurately, the ratio of the latter to the former is greater than 35%), the next day The bitcoin closing price ( close price ) will rise .

If the ratio is greater than 3:1 (accurately, the ratio of the latter to the former is less than 35%), for example, 4:1 or 5:1, then this is a signal to sell because the next day Bitcoin closing prices will fall .

Next, I conducted further tests on the two-day closing price difference between Bitcoin and the price difference of more than $80. In these tests, the ratio of search volume showed a great correlation with price fluctuations.

The $80 here is a value I gave, and this value worked very well in the experiment. The bitcoin price during the experiment and the buy/sell strategy given by the trading model are as follows:

Bitcoin price during the experiment and a screenshot of the buy/sell strategy given by the trading model

According to the above figure, it can be seen that:

  • BTC USD (Bitcoin to US Dollar Price) : The daily search volume data given by Google Trends Service.
  • Buy Bitcoin ( Buy Bitcoin ) : The search volume data for the day given by Google Trends.
  • Price (Bitcoin Price) : The closing price of Bitcoin on the cryptocurrency ranking website Coin Market Cap.
  • Column E in the Excel table : Search Volume Ratio for "Buy Bitcoin" and "Bitcoin to US Dollar Price".
  • Column F in the Excel table : The buy/sell decision given by the trading model. For example, for cell F19, the formula for the decision is: F19 = if(AND(E19> 35%, G19> 80), "buy", "sell"), ie when simultaneously satisfying the "buy bitcoin" on the same day The search volume ratio (E19) of "Bitcoin to US dollar price" is greater than 35%. When the closing price of Bitcoin on the day is greater than 80 USD from the previous day (G19), it will be bought, otherwise it will be sold. In other words, the E column data in the Excel table is greater than 35% and the G column data greater than 80 is the buy signal .
  • Column G in the Excel table : The difference between the closing price of Bitcoin and the previous day.
  • Column H in the Excel table : Assume that on July 7, 2018 (first purchase) $100,000 worth of Bitcoin, during the period of trading according to the buy/sell strategy given by the trading model, held on the same day The total value of Bitcoin.

Optimization of trading model results

According to the above trading strategy, in the 90-day experimental period, theoretically my assets increased from 100,000 US dollars to 128,839 US dollars, almost achieving a return on investment of 29% . But I mentioned above, this is not an optimal model, I can also optimize from several aspects.

The criteria for “ratio greater than 35%” and “balance greater than $80” seem very random, as this is just the rule I found in a limited 90-day data set. Are there other decision criteria that can lead to better buy/sell decisions?

This trading model gives good decisions when the bitcoin price level is maintained at $6,000 to $8,000 .

After analyzing the trading information of the past one or two years, I made some improvements to the trading model. I refined the decision rules and made a table. The vertical axis of the table is “Buy Bitcoin” and “Bitcoin to US Dollar”. Search rate ratio for price, ranging from 1:3 to 1:5.

Considering the large fluctuations in bitcoin prices, the “$80” indicator does not always work, so I convert this indicator into the ratio of the difference to the bitcoin price of the day and list it on the horizontal axis of the table. In this case, a possible optimal trading model is to buy when the ratio of the search volume of “buy bitcoin” and “bitcoin to dollar price” is 1:2.86 (ie 0.35) and the price fluctuation ratio is 0.014543229. .

The improved form looks like this:

Decision rules for improved post trading models



Follow-up planning

In addition, this trading model has a lot of room for optimization.

First of all, I want to do some testing to find the best indicator to maximize profit by studying past transaction data, which requires regression testing of past price and search volume ratios.

My idea is that there are the same best indicators at different price levels, Good Luck!

Author | Marc Howard

Compilation | Guoxi

Produced | Blockchain Base Camp (blockchain_camp)