Assuming that the current date is $ T $, we use Deep Learning to predict the simple moving average of daily prices from $ T + 1 $ to $ T + 30 $. We conducted a simulation trade in which profits are confirmed if the price exceeds (below) the predicted moving average from the price when holding (or shorting) a long position. Also, if you hold it for 30 days, you will be forced to close it. I will do my best to make entries if there is a balance for each date and time.
chainer ver1.3~1.5 Just in ver1.5, the compatibility has changed significantly, and it was difficult to deal with it. It seems that it is ver2.0.2 as of August 2017.
Mizuho Historical Data https://www.mizuhobank.co.jp/rate/market/historical.html Below, we used the date and time data of 23 currencies. All are against Japanese yen. The top 8 currencies in bold are the currencies that have verified the trading simulation. (From 2002/4/1 to 2016/1/29, only currencies that have daily data without fail for a day) At the time of learning, all are normalized by 0-1.
Daily data for the currencies of the above 23 countries and the past 30 days. The reason for choosing this input data is that we speculate that exchange rate fluctuations in each currency may be correlated with fundamental and technical factors.
The teacher data is a 30-day simple moving average 30 days after one currency. This time, we predicted each of the eight currencies (currencies in bold in the above data) that are often used by Japanese Forex companies. By the way, I tried some one-point forecasts (such as forecasting daily data for the next day) instead of moving averages, but I did not get good results. After all, it is said to be a random walk, so it may be difficult unless you predict the trend for a certain period of time.
A simple feedforward NN with 3 middle layers. (Input layer is 690, intermediate layer 1 is 512, 2 is 256, 3 is 128, output layer is 1) It is delicate to say that it is deep learning, but in wikipedia it seems that it can be said from the middle layer 3 layers, so I am allowed to name it for the time being. I used ReLU as the activation function and Adam as the optimization function. Hyperparameters should have been Chainer's default. I also used dropouts, but I remember not getting very good results. The activation function of the output layer is $ tanh $, and the error function is the square error.
We learned and verified with 2000 days of training data and 1325 days of test data. Below are the results of the pound sterling vs. the Japanese yen, which gave particularly good results. All results tended to be more divergent in the second half of the test period. It doesn't seem to be simply rock-paper-scissors (the rate of the previous day is used as a predicted value). I think this is partly due to the changing market trends, so it may be better to divide the learning period and verification period into smaller parts, or to use a time-series-specific model such as LSTM. .. The overall learning result is as follows. The error is expressed as variance. The Swiss franc has a big gap because the part of the 2015 surge has just overlapped with the test period. Since it is impossible to predict price movements that are not related to the input data used for learning, if there are large price movements due to fundamental factors, it is difficult to simply use past time series data, and from the latest information such as twitter and news. I think that it is necessary to detect the part that is likely to affect the price movement as soon as possible.
I easily made a back test on my own and did it. The verification period is 1325 days from 2010/7/7 to 2015/12/11, which is the test data period. The initial amount is 10 million, the transaction unit is 1000 currency units, and the spread is also taken into consideration. However, since the data uses only the above daily data, it fluctuates finely in actual trading, and it is not known whether the contract will be decided, so the reproducibility as a back test is low. After all, good results were obtained with GBP, which had the highest learning accuracy. On the contrary, CHF has poor learning results, so trading results are also bad.
As a caveat, since we are learning to reduce the error of the test period to the lower limit, this learning result is optimized in the test period, and it does not work even if we test using the same learning result in another period. (Curve fitting) There is a possibility. For example, the way the market moves changes depending on the period, as the divergence becomes larger in the latter half of the test period. Therefore, it is better to set a verification period outside the test period and perform the actual simulation, but this time we have not done so.
I think it is difficult to predict the exchange rate exactly by deep learning. However, depending on the usage data and ingenuity of trading methods, it seems that trading using deep learning may produce results even from time series data alone. Of course, there is a risk that the market trend will fluctuate, so it seems that it will not be profitable in the long run. Since there are a lot of issues, I would like to study and verify by reading other verification results and papers. If you are confident that you will make a profit by repeating improvements and verifications, I would like to try actual operation.
↓ Tutorial to create a forex (FX) trading system using deep learning http://qiita.com/jiji_platform/items/268377c542706e6f44b1
Recommended Posts