[PYTHON] Cryptocurrency price fluctuation forecast

It is a sharing of the results of experiments to see if it is possible to predict when to buy Bitcoin. I hope it will be helpful.


What is virtual currency?

--Bitcoin is famous. There is also a virtual currency called Altcoin. --Something has been in the news lately --BicCamera starts using virtual currency at stores [^ 4] --YouTuber Hikaru VALU uproar [^ 5] --"Bitcoin" female abandonment case [^ 6] - COMSA[1]


What is Altcoin?

--A currency created as an alternative to Bitcoin --There are currencies whose value increases 100 times or more in half a year [^ 1]. --There are hundreds or thousands of types of altcoins. ――At the moment, is it mainly used for speculative purposes? --The usage is different for each currency. --There are coins that will rise by nearly 100% as of August 2017. (e.g. Lisk [^ 2], Bitcoin Cash [^ 9])


Benefits of speculation on cryptocurrencies?

――The daily fluctuation is drastic. (It may fluctuate more than 100% in one day.) --In addition to Bitcoin, there are so many coins called altcoins that go bad (thousands) --There are coins that are hundreds of times more valuable ――If there is good news, the price will rise at once


Why did you try to predict price fluctuations?

――I felt that the atmosphere seemed to fluctuate in a short time. ――If you do it yourself, it depends on your emotions, so please trade with the machine. ――The people who buy it should be for basic speculative purposes.


Let's look at it first

image.png Transition of various normalized virtual currencies

--Until July, Bitcoin and Altcoin will fluctuate in the same way ――It started to change after August of this year (from around the division of Bitcoin) ――The trend in the medium term is changeable, so it seems that it is not suitable for computer prediction. --Large price changes are difficult to predict due to external information such as events (I do not know, so aim for short-term small fluctuation prediction) ――If it's a small width, it may be quite so with a pattern.


policy

――We will accumulate small profits by short-term trading without doing long-term trading. (Small profits steadily) --I don't do high-speed trading (HFT) [^ 8](I don't know) --The buy timing is judged every few minutes, and the sell timing is determined by the threshold value. --Discard the fluctuations at the event. ――Predict fluctuations in a short period of time and try not to lose as much as possible by cutting losses.


theme

--A positive sample if the Bitcoin price goes up by 3000 yen (about 0.6%) --Negative sample if Bitcoin price drops by 1000 yen (about 0.2%) --If the threshold is not reached even after leaving for 5 hours, a negative sample --Maximize F value

There are exchanges where the commission is 0 for Bitcoin only (for a limited time), so if precision (win rate when betting) exceeds 25%, you should be profitable.


data set

--Data acquired every 3 minutes


approach


Feature selection

--Rate information --Highest / lowest / average for the last 24 hours --Rate of deviation from moving average / moving variance of 15 minutes / 60 minutes / 240 minutes rate --Board information ――Which is more, buy or sell? ――How much is on the board


model


How was the performance?

- Alt + Bit Bit Only
Positive Rate 0.329 0.330
Accuracy Score 0.672 0.683
Recall Score 0.005 0.045
Precision Score 0.636 0.914
F1 Score 0.010 0.085

It seems that the altcoin information can be ignored.


Obtained findings

--If you include Altcoin in the features, the performance will decrease, so it seems good to judge only by Bitcoin. --Recall is not improved even if the board information is used as a feature. (Are you stuck on something like a show board?)


Future tasks

――Since it is a premise that you can buy at the limit price, it is necessary to calculate how much it will happen. --The line of profitability and loss cut is too appropriate, so improvement is required. ――If you don't make a small amount, your own buying and selling will become a barrier and you can't help it, so it seems difficult unless you improve the recall. ――The price difference with other exchanges is likely to be a feature. ――Since a large amount of sales may occur for numbers with good sharpness, it is necessary to improve the method of extracting features from the selling board.


Summary

--Infrequently, there are 9 allocation timings ――It seems that improvement is necessary because it is a premise that you can buy and sell at the limit price. ――It seems better not to use Altcoin as a feature at this point. --Price difference with other exchanges may also be a feature


References


  1. COMSA [^ 8]: [High Frequency Trading](https://ja.wikipedia.org/wiki/%E9%AB%98%E9%A0%BB%E5%BA%A6%E5%8F%96%E5% BC% 95) ↩︎

  2. dmlc, XGBoost [^ 4]: Nihon Keizai Shimbun, BicCamera starts using virtual currency in stores [^ 5]: [YouTuber Hikaru VALU uproar] What are the regulations necessary for future service development [^ 6]: "Bitcoin" female abandonment case re-arrested on suspicion of murder-robbery ↩︎

Recommended Posts

Cryptocurrency price fluctuation forecast
Kaggle ~ House Price Forecast ② ~
Kaggle ~ Home Price Forecast ~
Stock Price Forecast 1 Chapter 1
Stock price forecast with tensorflow
Python: Stock Price Forecast Part 2
Python: Stock Price Forecast Part 1
Bitcoin Price Forecast on TensorFlow (LSTM)
[Python] My stock price forecast [HFT]
Stock price forecast using machine learning (scikit-learn)
Stock price forecast using deep learning (TensorFlow)
Stock Price Forecast with TensorFlow (LSTM) ~ Stock Forecast Part 1 ~
Stock price forecast using machine learning (regression)