2
$\begingroup$

I have an assignment to create a LSTM network predicting price and trend of cryptocurrencies based on stock market data from the past.

The network I am using is a multilayered LSTM, where layers are stacked on top of each other. I provide keras code for the model below:

model = keras.Sequential()
model.add(LSTM(input_shape=(720, 4,), units=32, return_sequences=True, use_bias=True))
model.add(LSTM(units=64, return_sequences=True, use_bias=True))
model.add(Dense(units=32, use_bias=bias, activation="linear"))
model.add(Dense(units=1, use_bias=bias, activation="linear"))

I use SGD optimizer, but I have also tried Adam and RmsProp. My loss function is mean squared error. As input I am providing 720 samples of stock prices with 1h intervals, sales volume, and two moving averages of prices over different number of samples. Input data is taken from stock price history of different cryptocurrencies. The output is supposed to be stock price 10 time units in the future.

The predictions are pretty bad, the network seems to just randomly choose some nuber that is close to the last price in series. My profesor expects the predicted price to be trending in the right direction about 70-80% of the time and it is definitely not the case here.

Am I doing something wrong? Is the network architecture all wrong, or do I use LSTM network incorrectly? Or maybe I should provide the network with some additional data? I have already tried changing number of units in each layer in range from 10 to 100, I have also changed the number of LSTM layers between 2-4, and there was no noticeable improvement.

If someone could provide any pointers on how to proceed I would be very grateful.

$\endgroup$
  • $\begingroup$ Predicting stock market prices, in general, is extremely hard problem. Unlikely to get you 70%-80% accuracy by tuning the network on such small data, no matter what you do. Recheck the objective too. Do you want to predict direction or exact value? Also think if RMSE is a good error metric (whether you under-estimate or over-estimate, the error is same). May be RMSE is not a good error metric in stock application. $\endgroup$ – hssay Jan 18 '18 at 8:36
  • $\begingroup$ The main objective is to predict value as accurately as possible, but the teacher told me to use predicted data to calculate direction as a measure of correctness. And he suggested that direction calculated this way should be correct 70+% of times. As for the error metric, Im not sure if I follow. The error should be zero when the prediction is correct and positive when it is not. How should I differentiate between an over- and under-estimation? $\endgroup$ – RegyN Jan 18 '18 at 10:50
  • $\begingroup$ This might be too late, but did you tried tuning the hyperparameters yet? My personal findings showed that a unit size of around 100 - 150 provides the most accurate prediction (for a continuous value prediction). $\endgroup$ – krismath Mar 31 '18 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.