2D·

Hello dear community,


Since I'm not the best investor, I'm trying to find another way to try my luck using my background in the computer science industry. Artificial intelligence (AI) is often a controversial topic, so let's call it by its proper name. I want to use a neural network model - or a combination of several - to predict an estimated price value for a particular stock. With this post, I not only want to show you how I approach this endeavor, but also give you some knowledge.


Let's start with the basics


My current approach is to use an LSTM model that receives as input the daily price data of the last 20+ years as well as calculated indicators such as the MACD.


LSTM model


An LSTM model stands for "Long Short-Term Memory Model" and is well suited to my project, as it doesn't just look at the last price to predict the next one. It has a so-called offset, which enables the model to analyze the last 60 days simultaneously, for example, without having to define this manually in the input. It can also memorize both long and short patterns.


Input and output


As already mentioned, the model receives the daily prices, volatility and various indicators as input. These inputs can have a significant impact on the forecast, as neither too much nor too little data should be passed. My current input is as follows:

['close', 'open', 'high', 'low', 'volume', 'SMA', 'RSI', 'MACD']

In the output, the model only returns the close price.


Hypertuning


As a model can vary in size in terms of the number of nodes, a lot of testing is required here. This process is known as hypertuning. Numerous models are trained with different configurations in order to find out which one works best.


You can think of it like this: It is not good if the model's "brain" is too small, as it will then be unable to memorize certain patterns. On the other hand, it shouldn't be too big either, otherwise the model will start to memorize all the data. In this case, it practically knows the entire history of the share by heart. If it then tries to predict something that it has not memorized, it will fail miserably. This phenomenon is called "overfitting".


How good is my current model?


To be honest: it's not very good yet, but it shows potential in this approach.


For my test I used $AAPL (+0,08%) (Apple) and used the input described above. Here is the output for a prediction where the model was fed with data it has never seen before during the training process:

attachment

You can see that there are still scaling issues as the prediction does not start with the same price as the actual price. However, the model recognizes a trend towards the end of the 7-day forecast, which is also confirmed by the actual price.


Now that you have an insight into my project, I plan to post a larger update once a month. I will present improvements and report on other approaches that I have tried out.


I welcome any suggestions on this topic or feedback on the format of this post. I would also like to try out the model on other stocks. So I'm open to suggestions here too.


Have a good week from the coding corner!

14
7 Comentários

If you don't get in touch again, then we know it worked :)
3
Mostrar resposta
Brilliant, I would like to have the daily closing price of Nvidia from 02.12.2030 ;-)
2
imagem de perfil
Hey, why don't you try to set up your own AI and feed it with data?
Mostrar resposta
How does it account for news or probably easier, earnings dates?
Mostrar resposta
Participar na conversa