Wednesday, September 24, 2014

First attempt at implementing recurrent neural network FOREX trend prediction


My first attempts at implementing the experiment from the russian paper with neurolab failed miserably. It just doesn't have all the options I needed. I've decided to switch to PyBrain (https://github.com/pybrain/pybrain/wiki/installation). Note that I've only worked with the EUR/USD trading rate.

Although the results were better, they were not satisfactory. The following plot shows how close the Elman RNN got to the normalized training set. After around 1500 epochs, PyBrain couldn't get any closer. Also, the quality seems to depend heavily on the initial random values of the net.


I did not follow the paper closely. An important step I missed was using the modified logistic function. I tried modifying it in the file named /usr/local/lib/python2.7/dist-packages/PyBrain-0.3.1-py2.7.egg/pybrain/tools/functions.py, but PyBrain's training function failed after the modification.

If you would like to try it yourself, you can find the source code and all the instructions here:

https://www.dropbox.com/s/3v63go1zlfux9l5/euro2.tar.gz?dl=0

All you have to do is install the dependencies and run a couple of shell scripts. The scripts will download the data directly from the european central bank, create and train the RNN, and generate the plots automatically.

My next steps will be to: 1. write a RNN builder and trainer in C from scratch, and 2. try to predict only return rate direction (positive or negative) with PyBrain.