Forex trading neural networks

Forex trading neural networks

Posted: Kriss Date of post: 18.07.2017

This is first part of my experiments on application of deep learning to finance, in particular to algorithmic trading. I want to implement trading system from scratch based only on deep learning approaches, so for any problem we have here price prediction, trading strategy, risk management we gonna use different variations of artificial neural networks ANNs and check how well they can handle this. I highly recommend you to check out code and IPython Notebook in this repository.

forex trading neural networks

In this, first part, I want to show how MLPs, CNNs and RNNs can be used for financial time series prediction. In this part we are not going to use any feature engineering.

We have information from to about open, close, high, low prices for every day in the year and volume of trades. Download the dataset from Yahoo Finance or from this repository.

We will consider our problem as 1 regression problem trying to forecast exactly close price or return next day 2 binary classification problem price will go up [1; 0] or down [0; 1].

For training NNs we gonna use framework Keras. For example, having close prices from past 30 days on the market we want to predict, what price will be tomorrow, on the 31st day. Here is example of loading, splitting into training samples and preprocessing of raw input data:. It will be just 2-hidden layer perceptron. Number of hidden neurons is chosen empirically, we will work on hyperparameters optimization in next sections. Between two hidden layers we add one Dropout layer to prevent overfitting.

We want one output that can be in any range we predict real value and our loss function is defined as mean squared error. Below is plot of predictions for first points of test dataset. We can clearly see that our algorithm is not even close by value, but can learn the trend.

forex trading neural networks

On the plot below you can see actual scaled time series black and our forecast blue for it:. For using this model in real world we should return back to unscaled time series.

xelenew.web.fc2.com - Deep Learning, Trading, Neural Networks, Forex

MSE in this case equals Here is the plot of restored predictions red and real data green:. I am not going to dive into theory of convolutional neural networks, you can check out this amazing resourses:.

Forex prediction - Prediction using neural networks

MSEs for scaled and restored data are: Even looking on MSE on scaled data, this network learned much worse. Most probably, deeper architecture needs more data for training, or it just overfitted due to too high number of filters or layers.

Altredo - Binary Options Robot, Binary Options Signals, Forex Robot

We will consider this issue later. As recurrent architecture I want to use two stacked LSTM layers read more about LSTMs here.

Neural Networks for Forex Trading

Now we will use not close prices, but daily return close price-open price and we want to predict if close price is higher or lower than open price based on last 20 days returns. To load binary outputs, change in the code following line:. Also we change loss function to binary cross-entopy and add accuracy metrics.

Check out the results below. We can see, that treating financial time series prediction as regression problem is better approach, it can learn the trend and prices close to the actual. What was surprising for me, that MLPs are treating sequence data better as CNNs or RNNs which are supposed to work better with time series. You can reproduce results and get better using code from repository.

I think we can get better results both in regression and classification using different features not only scaled time series like some technical indicators, volume of sales. Alex Honchar Blocked Unblock Follow Following teaching machines and rapping.

Neural networks for algorithmic trading. Simple time series forecasting. Machine Learning Artificial Intelligence Trading Deep Learning Neural Networks.

forex trading neural networks

Blocked Unblock Follow Following. Alex Honchar teaching machines and rapping. Never miss a story from Alex Honchar , when you sign up for Medium. Blocked Unblock Follow Get updates.

Rating 4,1 stars - 769 reviews
inserted by FC2 system