Consider an example with Apple shares.

Our trading idea is to wait for release of Apple's revenue report and on its basis, and also taking into account the previous change in the share price, the previous change in the market as a whole (S&P500) and the market reaction to the report, - make a decision about opening long or short position in Apple share.

We will open a position on the day after the revenue report release just before the closing of the trading session, and then we will close the position one day before new report release in the next quarter. So, the position holding time will be about one quarter.

To make a decision on trade direction (long or short), we need to make a prediction of Apple's stock price change in the next quarter.

To create the prediction, we will use the following data (factors):

  • Date - the date of entry into the trade;

  • Time - the time of entry into the trade;

  • Change - price change (percent) in the previous quarter;

  • Gap - size of the gap (percent) on the next day after the report was released;

  • Day movement - price change on the next day after the report release (from the the session open until the trade entry);

  • SP500 change - S&P500 index change (percent) in the previous quarter;

  • Earning delta - change in Apple's revenue compared to the previous quarter according to the published report.

Let's create an Excel file with historical data, on which the neural network will be trained and make a prediction for the next quarter.

Add column names:

Fill in the first line with data:

  • Date = 21.07.2010 – the day in which we open a trade (the day after the release of the report);

  • Time = 23:00:00 – trade entry time (at the end of the trading session);

  • Change = -2,83% - Apple's stock price change in the previous quarter (at the moment of the end of previous trading session, that is, before the report was released);

  • Gap = 5,25% - gap on the next day, July 21, 2010, after the report was released;

  • Day movement = -4,09% - day price change (excluding gap) on July 21, 2010 from the session opening time (excluding gap) until the trade entry;

  • SP500 change = -10,09% - S&P500 index price change in the previous quarter (at the moment of the end of previous trading session, that is, before the report was released);

  • Earning delta = 4,16% - change in Apple's revenue compared to the previous quarter according to the published report.

Then the value in the Change column of the second line is price change in the next quarter. In fact, this is profit or loss that we will get depending on our choice of the direction at the moment of opening position on 21.07.2010. And this is exactly the value that the neural network will predict.

So, the first line of our file contains the data that are known to us at the time of opening position, and the value of the Change column of the second line is future price change, which is unknown to us at the time of opening position on 21.07.2010.

Let's fill in similarly the rest lines of the file:

The lines, from the first to the penultimate one, are the traning data for the neural network.

The last line of the file is the last known data, on which the neural network will make a prediction for the future period:

Now save the file in csv format:

A similar file can be created in a simple text editor:

Now, when the data file is ready, let's load it into the forecasting service:

Expecting the result of processing:

The training of the neural network was completed and we have received a prediction for the next quarter:

  • Prediction - predicted price change in percent for the next quarter;

  • Estimated accuracy of prediction - the percentage of correct predictions of the trade direction (long or short);

  • Mean error - the average deviation of the predicted price change from the real one.