Stock market analysis using LSTM-Nasdaq data

Stock market analysis using LSTM-Nasdaq data

What is the stock market ?

The stock market is where investors buy and sell shares of companies. It’s a set of exchanges where companies issue shares and other securities for trading.

How the market works

When you purchase a public company's stock, you're purchasing a small piece of that company.

The stock market works through a network of exchanges. Investors purchase those shares, which allows the company to raise money to grow its business. Investors can then buy and sell these stocks among themselves.

What is the point of the stock market?

The point of the stock market is to provide a place where anyone can buy and sell fractional ownership in a publicly traded company. It distributes control of some of the world’s largest companies among hundreds of millions of individual investors. And the buying and selling decisions of those investors determine the value of those companies.

No alt text provided for this image

In this article, we will go through the steps to build a LSTM model to predict the stock prices .

Long Term Short Memory(LSTM)?is one type of recurrent neural network which is used to learn order dependence in sequence prediction problems. Due to its capability of storing past information, LSTM is very useful in predicting stock prices. This is because the prediction of a future stock price is dependent on the previous prices.

Firstly, we are going to use?yFinance?to obtain the stock data. yFinance is an open-source Python library that allows us to acquire stock data from Yahoo Finance without any cost.

In this case, we are going to acquire the stock prices of AAPL over the last 6 years.

No alt text provided for this image
No alt text provided for this image

Import all the required libraries and Use the yFinance download method to acquire the stock data for last 6 years and then preview the data.

Visualizing Stock Prices History

Prior to preparing to build a LSTM model, let’s take a look at the historical prices movement of AAPL by plotting a line chart.

No alt text provided for this image

Preparation of training set

Here we will only need the closing prices from our dataset to train our LSTM model. We are going to extract 80% of the closing prices from our acquired stock data as our training set

No alt text provided for this image

Preparation of test data

No alt text provided for this image

LSTM Network Architecture

Now, we are ready to use an open-source machine learning library,?Tensorflow,?to set up our LSTM network architecture.

No alt text provided for this image

Training LSTM Model

No alt text provided for this image

Model Evaluation

No alt text provided for this image

Visualizing the Predicted Prices

No alt text provided for this image

LSTM can be another great tool for stock price prediction. However, this is important to note that the prediction is only based on the historical prices movement that usually won’t be the only factor that affects the future price movement. predicted stock prices shall not be used as a solely definitive guide to make an investment decision without further analysis.

要查看或添加评论,请登录

Punam Gadekar的更多文章

  • Convert Image into Cartoon

    Convert Image into Cartoon

    Importing necessary Libraries reading and plotting the image read the image using the imread function and then convert…

  • Object Detection with YOLOv5

    Object Detection with YOLOv5

    Object detection is a computer vision task that involves identifying instances of an object of a certain class within…

社区洞察

其他会员也浏览了