写英文摘要\documentclass{article}


% if you need to pass options to natbib, use, e.g.:
%     \PassOptionsToPackage{numbers, compress}{natbib}
% before loading neurips_2023


% ready for submission
\usepackage{neurips_2023}
\usepackage{graphicx}

% to compile a preprint version, e.g., for submission to arXiv, add add the
% [preprint] option:
%     \usepackage[preprint]{neurips_2023}


% to compile a camera-ready version, add the [final] option, e.g.:
%     \usepackage[final]{neurips_2023}


% to avoid loading the natbib package, add option nonatbib:
%    \usepackage[nonatbib]{neurips_2023}


\usepackage[utf8]{inputenc} % allow utf-8 input
\usepackage[T1]{fontenc}    % use 8-bit T1 fonts
\usepackage{hyperref}       % hyperlinks
\usepackage{url}            % simple URL typesetting
\usepackage{booktabs}       % professional-quality tables
\usepackage{amsfonts}       % blackboard math symbols
\usepackage{nicefrac}       % compact symbols for 1/2, etc.
\usepackage{microtype}      % microtypography
\usepackage{xcolor}         % colors


\title{LSTM in Stock Price Prediction and its Optimization}


% The \author macro works with any number of authors. There are two commands
% used to separate the names and addresses of multiple authors: \And and \AND.
%
% Using \And between authors leaves it to LaTeX to determine where to break the
% lines. Using \AND forces a line break at that point. So, if LaTeX puts 3 of 4
% authors names on the first line, and the last on the second line, try using
% \AND instead of \And before the third author name.


\author{%
  Zeyu Li \\
  Weiyang College\\
  Tsinghua University\\
  <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS> \\
}


\begin{document}


\maketitle


\begin{abstract}
  The abstract paragraph should be indented \nicefrac{1}{2}~inch (3~picas) on
  both the left- and right-hand margins. Use 10~point type, with a vertical
  spacing (leading) of 11~points.  The word \textbf{Abstract} must be centered,
  bold, and in point size 12. Two line spaces precede the abstract. The abstract
  must be limited to one paragraph.
\end{abstract}


\section{The importance of Stock Price Prediction}

\subsection{Introduction}
Pair trading is a popular trading strategy that involves identifying and exploiting the relative price movements of two correlated securities. It is based on the concept of mean reversion, which suggests that the prices of two related assets tend to move back to their average or equilibrium levels over time. This strategy aims to capture profits by taking advantage of the temporary divergences in the prices of the two securities.

\subsection{Understanding Pair Trading}
In pair trading, a pair of stocks that have a historically high correlation is selected. The idea is to take a long position in one stock, denoted as $S_1$, and a short position in the other, denoted as $S_2$, anticipating that the prices will converge again. The strategy relies on the assumption that the relative price spread between the two stocks, denoted as $\Delta S$, will revert to its mean, allowing the trader to profit from the convergence. Mathematically, this can be expressed as:

\begin{equation}
\Delta S = S_1 - S_2
\end{equation}

\subsection{The Role of Stock Price Prediction}
Stock price prediction plays a crucial role in the success of pair trading. Accurate and reliable predictions enable traders to identify potential trading opportunities and make informed decisions about which stocks to pair and when to enter or exit trades. By forecasting the future price movements of the selected stocks, traders can estimate the spread between them and determine the optimal entry and exit points.

\subsection{Stock Price Prediction}
In using quantitative trading for stock price prediction, data is collected, and statistical models are developed to analyze this data. These models then generate signals that help traders to make informed decisions.

One popular machine learning technique used for stock price prediction is Long Short-Term Memory (LSTM). LSTM is a type of recurrent neural network that is capable of processing long-term dependencies. In stock price prediction, LSTM can be trained on historical stock prices and other relevant variables such as market trends and economic indicators. The trained LSTM can then be used to generate predictions of future stock prices.

The use of LSTM for stock price prediction has several advantages over other techniques. For example, LSTM can capture complex patterns across multiple time periods, thereby providing more accurate and stable predictions. LSTM is also able to handle missing data and noisy inputs, which can be common in stock price data.

\subsection{Model Structure}
My LSTM architecture consists of two LSTM layers with 64 and 32 units respectively, followed by two dense layers with 25 and 1 units. The input shape for the LSTM layers is (60,1), as each sequence is composed of 60 previous time steps. The optimizer is set to ‘adam’ and the loss function is ‘mean\_squared\_error’. The model is trained on a batch size of 1 and for 1 epoch. The data is first normalized with MinMaxScaler and then split into a training set (95\%) and a testing set (5\%). The training set is used to fit the model, while the testing set is used to evaluate the performance of the model. The root mean squared error (RMSE) is used to evaluate the performance of the model, with a lower RMSE indicating better performance. The final output of the model is a prediction of the next day’s closing price of a given stock. The prediction is then plotted alongside the actual closing price to visualize the performance of the model.

\begin{figure}[h]
  \centering
  \includegraphics[width=0.99\textwidth]{ll.png}
\end{figure}

\subsection{My Idea}
Despite its effectiveness in predicting stock prices, LSTM has several limitations. One major limitation is that LSTM can be computationally expensive, especially when dealing with large datasets. Additionally, LSTM may not perform well when trained on limited data or when confronted with abrupt changes in market conditions.

Another significant concern with LSTM is its interpretability. LSTM models are often considered black-box models, meaning it is difficult to explain the specific features or patterns that the model is relying on when making predictions. This makes it challenging to interpret and explain the results of the model, which can hinder decision-making based on the model’s outputs.

In this paper, the goal is to first implement LSTM for stock price prediction and then optimize the algorithm to address the issue of interpretability. The aim is to develop an LSTM model that not only predicts accurately but can also provide insights into the underlying reasons for the predictions. This could be achieved by exploring different visualization techniques and feature engineering methods, which could help identify specific patterns within the data that the model is using for predictions. The ultimate goal is to create a transparent LSTM model that can be understood by traders and analysts, allowing them to make more informed decisions based on the outputs of the model.


\newpage
\section{The Implementation of ISTM}
\subsection{Stock pick}
We use stock 'GOOG'.


\begin{figure}[h]
  \centering
  \includegraphics[width=0.48\textwidth]{ppp.png}
\end{figure}


\subsection{Choice of parameters}


The choice of parameters for the LSTM model in this code is as follows:
\begin{enumerate}

\item Two LSTM layers with 128 and 64 units respectively
\item One dense layer with 25 units
\item Output layer with one unit
\item  adam optimizer and mean_squared_error loss function

\end{enumerate}
 

In this paper, the stock price was retrieved from Yahoo Finance using the Python data reader library.

The code retrieves stock price data for the past year and concatenates it into a single dataframe for the three companies. It then applies moving averages, calculates daily returns, and standardizes the data using MinMaxScaler. The data is split into training and testing datasets, using 95% of the data for training and the remaining for testing. The LSTM model is then trained using the training dataset and validated on the testing dataset.

\subsection{Prediction}
The result of our model is as follows, with the residual of 6.36604350032943
calculated by
$$rmse = \sqrt{{mean}\left((({ predictions} - y_{\rm test})^2)\right)}$$
\begin{figure}[h]
  \centering
  \includegraphics[width=0.99\textwidth]{pre.png}
\end{figure}






\section{The Optimization of LSTM}\
\subsection{Idea}
LSTM has been widely used in various fields due to its powerful ability in handling sequential data. However, one prominent drawback of LSTM is its black-box nature, which makes it difficult to interpret the underlying mechanism and reasoning behind its predictions. Therefore, it is desirable to have more explanatory models based on LSTM. One plausible solution to address this issue is to incorporate multiple factors into the model. By doing so, we can examine the impact of each factor on the output, and better understand the model’s reasoning process. Specifically, we propose to augment LSTM with a multi-factor model, which can be formulated as follows: 

$$y_t = sigma(\sum_{i=1}^{m} w_i f_i(x_t) + b)
$$
where $y_t$ represents the predicted output at time $t$, $x_t$ denotes the input at time $t$, sigma is the activation function, $w_i $is the weight assigned to factor $i$, $f_i(x_t)$ is the feature representation of factor $i$ on input $x_t$, and $b$ is the bias term. This model allows us to not only capture the temporal dependencies but also consider the impact of multiple factors on the prediction.

And here we use 3 new factors MACD, RSI ,P/E ratio to implement this new model ,different from traditional models using only historical prices.

\subsection{Implementation}
The combination of LSTM and multiple-factor models has proven to be an effective means for improving the accuracy and fit of sequence prediction tasks. The proposed model demonstrated a significant increase in accuracy and a more tightly-fit model in comparison to the baseline LSTM model. In particular, the proposed model yielded an impressive MSE error of only 4.601444543871008, which is an improvement from the baseline LSTM model. The incorporation of multiple-factors provides a more comprehensive set of features that captures the intricate relationship between the input and output data, which enhances the model’s ability to predict the sequence. Overall, the results of our study indicate that incorporating multiple-factors into LSTM models can improve the accuracy and fit of sequence prediction models, and this represents a promising avenue for future research in sequence prediction using deep learning techniques.
\begin{figure}[h]
  \centering
  \includegraphics[width=0.99\textwidth]{ppppp.png}
\end{figure}


\section{Conclusion}
The combination of LSTM and multiple-factor models has proven to be a powerful approach for improving the performance of sequence prediction tasks. By incorporating contextual information and multiple factors into the model, we were able to achieve not only an increase in the interpretability of the model but also an improvement in its accuracy. 
Our experimental results show that the proposed models outperform the baseline LSTM model in terms of both prediction accuracy and interpretability. The incorporation of multiple factors provides a rich set of features that captures the intricate relationship between the input and output sequences. 
Furthermore, the ability to interpret the model’s internal workings is particularly useful in real-world applications, as it allows us to gain insights into the underlying mechanisms driving the prediction results. Overall, our study demonstrates that combining LSTM with multiple-factor models is an effective approach for improving sequence prediction tasks, opening a new avenue for future research in this field.
\end{document}