---
abstract: |
    Stock market prediction is one of the most attractive research topic since the successful prediction on the market’s future movement leads to significant profit. Traditional short term stock market predictions are usually based on the analysis of historical market data, such as stock prices, moving averages or daily returns. However, financial news also contains useful information on public companies and the market.

    Existing methods in finance literature exploit sentiment signal features, which are limited by not considering factors such as events and the news context. We address this issue by leveraging deep neural models to extract rich semantic features from news text. In particular, a Bidirectional-LSTM are used to encode the news text and capture the context information, self attention mechanism are applied to distribute attention on most relative words, news and days. In terms of predicting directional changes in both Standard & Poor’s 500 index and individual companies stock price, we show that this technique is competitive with other state-of-the-art approaches, demonstrating the effectiveness of recent NLP technology advances for computational finance.
address: |
    Department of Electrical and Computer Engineering\
    Queen’s University, Canada\
    Kingston, ON, Canada K7L 2N8
author:
- Huicheng Liu
bibliography:
- 'references.bib'
title: 'Leveraging Financial News for Stock Trend Prediction with Attention-Based Recurrent Neural Network'
---

Recurrent Neural Network,Stock Prediction,Attention Mechanism,S&P 500

Introduction
============

Stock market prediction is the act of trying to determine the future value of a company stock [@malkiel1985random]. Apparently, the successful prediction of a stock’s future price can yield significant profit, making the prediction problem an area of strong appeal for both academic researchers and industry practitioners. However, Stock market prediction is usually considered as one of the most challenging issues among time series predictions due to its noise and volatile features [@wang2012novel]. During the past decades, machine learning models, such as Support Vector Regression (SVR) [@basak2007support] and Support Vector Machines(SVM) [@hearst1998support], have been widely used to predict financial time series and gain high predictive accuracy  [@refenes1994stock; @das2012support; @lu2009financial].

How to accurately predict stock movement is still an open question with respect to the economic and social organization of modern society. The well-known efficient-market hypothesis (EMH) [@malkiel2003efficient] suggests that stock prices reflect all currently available information and any price changes based on the newly revealed relevant information. However, due to the implicit correlations between daily events and their effect on the stock prices, finding relevant information that contribute to the change of price for each individual stock are difficult. Besides, the influences of events to stock prices can occur in indirect ways and act in chain reactions, which sets obstacles for precise market prediction. There are three approaches related to the information required to make a prediction. The first approach, technical analysis, is based on the premise that the future behavior of a financial time series is conditioned to its own past. Secondly, fundamental analysis, is based on external information as political and economic factors. A major source of information are text from the internet, these information are taken from unstructured data as news articles, financial reports or even microblogs. Nofsinger et al [@nofsinger2001impact] shows that in some cases, investors tend to buy after positive news resulting in a stress of buying and higher stock prices, they sell after negative news resulting in a decrease of prices. Finally the third approach considers as all relevant information coming from both, financial time series and textual data.

In this work, our goal is to leverage public released financial news and train a model named Attention-based LSTM (At-LSTM) to make prediction on directional changes for both Standard & Poor’s 500 index and individual companies stock price. Our model consists a Recurrent Neural network(RNN) to encode the news text and capture the context information, self attention mechanism is applied to distribute attention on most relative words, news and days . The model input are financial news titles extracted from Reuters and Bloomberg. Our model take advantages from the rapid development of deep neural networks and we show that our model is competitive with other state-of-the-art approaches, demonstrating the effectiveness of recent NLP technology advances for computational finance.

The rest of the paper are organized as follows. We introduce related work in Section 2. Followed by, we present some background and the methodologies for our proposed prediction model in Section 3. Experimental setup and results are demonstrated in Section 4. The paper finally concludes and point out future directions in Section 5.

Related work
============

Stock market prediction is an intriguing time-series learning problem in finance and economics, which has attracted a considerable amount of research. Efforts on predicting stock market have been carried out based on different resources and approaches. For example, one of the most widely studied approach relies on analyzing recent prices and volumes on the market [@schoneburg1990stock; @akgiray1989conditional; @goccken2016integrating; @adebiyi2014comparison; @kim2012simultaneous].

Analyzing stock market using relevant text is complicated but intriguing [@wu2009stock; @xie2013semantic; @ding2014using; @ding2015deep; @ding2016knowledge; @chang2016measuring; @peng2015leverage; @luss2015predicting; @skuza2015sentiment; @sehgal2007sops]. For instance, a model with the name Enalyst was introduced in Lavrenko et al. Their goal is to predict stock intraday price trends by analyzing news articles published in the homepage of YAHOO finance. Mittermayer and Knolmayer implemented several prototypes for predicting the short-term market reaction to news based on text mining techniques. Their model forecast 1-day trend of the five major companies indices. Wu et al. [@wu2009stock] predicted stock trends by selecting a representative set of bursty features (keywords) that have impact on individual stocks. Vivek Sehgal et al. [@sehgal2007sops] introduced a method to predict stock market using sentiment. Similarly, Michał Skuza et al. [@skuza2015sentiment] used sentiment from postings on twitter to predict future stock prices. However, these methods have many limitations including unveiling the rules that may govern the dynamics of the market which makes the prediction model incapable to catch the impact of recent trends.

More recently, neural networks have been leveraged to further improve the accuracy of prediction. In general, neural networks are able to learn dense representations of text, which have been shown to be effective on a wide range of NLP problems, given enough training sample. This is the case in stock market prediction where the prices of stocks are available together with a great collection of relevant text data. This provides a good setting for exploring deep learning-based models for stock price prediction. More specifically, dense representations can represent related sentiment, events, and factual information effectively, which can then be extremely challenging to represent using sparse indicator features.

Advance of deep learning models has inspired increasing efforts on stock market prediction by analyzing stock-related text. For example, Ding et al. [@ding2015deep] showed that deep learning representation of event structures yields better accuracy compared to discrete event features. They further augmented their approach  [@ding2016knowledge] to incorporating an outside knowledge graph into the learning process for event embedding. As another example, Chang et al. [@chang2016measuring] used neural networks to directly learn representations for news abstracts, showing that it is effective for predicting the cumulative abnormal returns of public companies. Other work,e.g., [@kim2012simultaneous; @goccken2016integrating; @adebiyi2014comparison], has proposed different models of neural network that improve the prediction accuracy.

Methodology
===========

In this section, we first introduce some relative background on our prediction models. Followed by, we introduce the design of our proposed model to predict the directional movements of Standard & Poor’s 500 index and individual companies stock price using financial news titles. The model is named as Attention-based LSTM (At-LSTM) and shown in Fig \[fig:traditional-convolutional-network\].

Background
----------

### Bag of Words Model and Word Embedding

The Bag-of-Words model is a simplifying representation often used in Natural Language Processing and Information Retrieval [@Bag]. Also known as the vector space model. In this model, a text (such as a sentence or a document) is represented as a bag of its words, disregarding grammar and even word order but keeping multiplicity. The bag-of-words model is commonly used in document classification where the occurrence of each word represents a feature for training a classifier.

Word Embedding is the collective name for a set of language modeling and feature learning techniques in Natural Language Processing (NLP) where words or phrases from the vocabulary are mapped to vectors of real numbers [@Word]. Conceptually it involves a mathematical embedding from a space with one dimension per word to a continuous vector space with much lower dimension. Neural networks can be used to generate this mapping and the most common algorithm used are continuous bag of words(CBOW) and skip-gram algorithm [@mikolov2013efficient].

Word and phrase embeddings, when used as the underlying input representation, have been shown to boost the performance in NLP tasks such as syntactic parsing and sentiment analysis.

### Convolutional Neural Network

As shown in figure \[fig:traditional-convolutional-network\], Convolutional Neural Network (CNN) is a class of deep, feed-forward artificial neural networks that has successfully been applied to analyzing visual imagery and NLP related tasks. Same as neural network, CNN are made up of neurons that have learnable weights and biases. Each neuron receives some inputs, performs a dot product and optionally follows it with a non-linearity. A Convolutional layer is composed by four consecutive operations: Convolution, subsampling(pooling), activation and dropout. The convolution layer can help select features so that CNN requires minimal pre-processing compared to other deep learning models. The core part of the Convolutional neural network is the convolution filter.

Convolution filters leverage two important ideas that can help improve a machine learning system: sparse interaction and parameter sharing. Sparse interaction contrasts with traditional neural networks where each output is interactive with each input. As a result, the output is only interactive with a narrow window of the input. Parameter sharing refers to reusing the filter parameters in the convolution operations, while the element in the weight matrix of traditional neural networks are used only once to calculate the output.

### Long-Short Term Memory

Long Short Term Memory (LSTM) networks are a special kind of RNN, proposed by Hochreiter in 1997 [@hochreiter1997long]. LSTM units are a building unit for layers of a Recurrent Neural Network(RNN) [@LSTM]. A RNN composed of LSTM units are often called an LSTM network. LSTM are explicitly designed to avoid the long-term dependency problem. A common LSTM unit is composed of a cell, an input gate, an output gate and a forget gate. The cell is responsible for “remembering” values over arbitrary time intervals; hence LSTM is capable of learning long-term dependencies.

(ct) [$c_t$]{}; (int1) ; (x1) [$\times$]{}; (ht) [$h_t$]{}; (x2) [$\times$]{}; (int2) ; (x3) [$\times$]{}; (ft) [$f_t$]{}; (it) [$i_t$]{}; (ot) [$o_t$]{};

i/in [int2/x2, x2/ct, ct/int1, int1/x1, x1/ht, it/x2, ct/it, ct/ot, ot/x1, ft/x3]{} (i)–();

(ct) to\[bend right=45\] (ft);

(ct) to\[bend right=30\] (x3); (x3) to\[bend right=30\] (ct);

(fit) ;

(fit.west|-int2) coordinate (aux)–++(180:7mm) node\[left\][$x_t$]{}; (\[yshift=1mm\]aux)–++(135:7mm); (\[yshift=-1mm\]aux)–++(-135:7mm);

(fit.north-|it) coordinate (aux)–++(90:7mm) node\[above\][$x_t$]{}; (\[xshift=1mm\]aux)–++(45:7mm); (\[xshift=-1mm\]aux)–++(135:7mm);

(fit.north-|ot) coordinate (aux)–++(90:7mm) node\[above\][$x_t$]{}; (\[xshift=1mm\]aux)–++(45:7mm); (\[xshift=-1mm\]aux)–++(135:7mm);

(fit.south-|ft) coordinate (aux)–++(-90:7mm) node\[below\][$x_t$]{}; (\[xshift=1mm\]aux)–++(-45:7mm); (\[xshift=-1mm\]aux)–++(-135:7mm);

The expression long-short term refers to the fact that LSTM is a model for the short-term memory which can last for a long period of time. An LSTM is well-suited to classify, process and predict time series given time lags of unknown size and duration between important events. Besides, LSTM shows the promising result in sentence encoding in many NLP applications  [@sutskever2014sequence; @gers2002learning]. The LSTM archticture are shown in figure \[fig:traditional LSTM neural network\], the computations of LSTM cells are:

[1.0]{} $$\begin{aligned}
    f_t = \sigma(W_f[h_{t-1},x_t] + b_f)\end{aligned}$$ $$\begin{aligned}
     i_t = \sigma(W_i[h_{t-1},x_t] + b_i)\end{aligned}$$ $$\begin{aligned}
    \tilde{C}_t = tanh(W_C[h_{t-1}, x_t] + b_C)\end{aligned}$$ $$\begin{aligned}
    C_t = f_t \otimes C_{t-1} + i_t \otimes \tilde{C}_t\end{aligned}$$ $$\begin{aligned}
     o_t = \sigma(W_o[h_{t-1},x_t] + b_o)\end{aligned}$$ $$\begin{aligned}
    h_t = o_t \otimes tanh(C_t)\end{aligned}$$

The forget gate is described in Equation (1) and is used to decide whether a value should be reserved. The Input gate in Equation (2) is used to control which values should be updated through a certain time step. Here, a new value $\tilde{C}_t$ is created as per Equation (3) using the $tanh$ function. Next, with Equation (4), the cell state will be updated from $C_{t-1}$ to $C_t$, $f_t$ and $i_t$ are used here to decide whether an information should be discarded. in Equation (5), an output gate is used to filter out redundant values. The final output is calculated by Equation (6). $W$ is the weight matrix and $b$ refers to the bias.

### Optimization Algorithm and Loss Function

In this section, we will briefly introduce the Optimization algorithm and loss function we used in our prediction model.

-   ***Adadelta Optimization Algorithm***: Apart from Stochastic Gradient Descent, Adaptive Gradient Algorithm or the famous Adam algorithm [@kingma2014adam], we chose Adadelta [@zeiler2012adadelta] as our optimization algorithm. Adadelta is an optimization algorithm that can be used to update network weights iterative based on training data. Adadelta combines the advantages of two other extensions of stochastic gradient descent, Adaptive Gradient Algorithm and Root Mean Square Propagation Algorithm. The method dynamically adapts over time using only first order information and has minimal computational overhead beyond vanilla Stochastic Gradient Descent [@zeiler2012adadelta]. The method requires no manual tuning of a learning rate and appears robust to noisy gradient information, different model architecture choices, various data modalities and selection of hyperparameters.

-   ***Cross Entropy Loss***: In information theory, the cross entropy between two probability distributions $p$ and $q$ over the same underlying set of events measures the average number of bits needed to identify an event drawn from the set [@Cross]. Cross entropy is the most suitable loss function since we want to measure the output from our prediction model with it’s true output. A binary cross entropy loss formula are shown in Equation (7). In which, $J(w)$ refers to the loss, $N$ refers to the number of examples, $y_n$ is the expected output and $\tilde{y}_n$ is true output. We use this formula as our loss function in the model. $$\begin{aligned}
        J(w)=-\frac{1}{N}H(p_n,q_n)=-\frac{1}{N}\displaystyle\sum_{i=1}^{N} [y_n*\log\tilde{y}_n+(1-y_n)*\log(1-\tilde{y}_n)]\end{aligned}$$

Model design
------------

In this subsection, we introduce the design of our Attention-based LSTM model (At-LSTM). The design has four stages: Input and Embedding layer, news-level Bi-LSTM and self-attention layer, day-level Bi-LSTM and self-attention layer and the final output and prediction layer. These stages will be described below and shown in figure  \[fig:model\].

![\[fig:model\]Model Structure](Model.png){width="100.00000%" height="3.5in"}

### Input and Embedding Layer

***Model Input***: The same world event can be described in different expression ways. This variety makes the representation space for events very sparse. Several approaches [@ding2015deep; @ding2016knowledge] represent the event as tuple $< S; V; O >$ to gain generalization. However, we argue that this representation is oversimplified and might lose lots of valuable information. Instead, we use the entire news title content as our models input and use LSTM-based encoder to encode it to a distributional representation to tackle with sparsity problem.\
***Word and Character Embedding***: For each input news, we remove the punctuation and then use a word embedding layer to calculate the embedded vectors for each word. The embedding layer takes a sequence of sentences as input, this sequence corresponds to a set of titles of news articles. These embedding are unique vectors of continuous values with length $w = (w_1,...,w_l)$ and $w_i\in R^{m}$ for each word in the training corpus, $m$ is the word level embedding dimension.

Existing pre-trained word embedding such as Glove [@pennington2014glove] and Word2Vec [@mikolov2013efficient] typically comes from general domains( Google News or Wikipedia, etc). However, these word embeddings often fail to capture rich domain specific vocabularies. We therefore train our own word embedding with financial domain news text consisting of news articles from Reuters an Bloomberg. The data are further described in Section 4.

In addition, we leverage character composition from Chen et al. [@chen2017recurrent] and concatenate the character level composition with the original word embedding to gain rich represent for each word. The character composition feeds all characters of each word into a Convolutional Neural Network (CNN) with max-pooling [@kim2014convolutional] to obtain representations $c = (c_1,...,c_l)$ and $c_n\in R^{n}$ for each word in the training corpus, $n$ is the character composition dimension. Finally, each word is represented as a concatenation of word-level embedding and character-composition vector $e_i = [w_i;c_i]$. A matrices $e^s\in R^{k*(m+n)}$ can be used to represent a news after the embedding layer, where $k$ is the length of the news.

### News Level Bi-LSTM and Self-Attention Layer

***Bi-LSTM Encoding***: After the embedding layer, we fed the words and their context in the news title into a Bi-LSTM based sentence encoder to perform distributional representation. Bidirectional LSTM (Bi-LSTM) is a variant of LSTM which shows better result then uni-direction LSTM in recent NLP tasks as they can understand context better. A bidirectional LSTM runs a forward and backward LSTM on a sequence starting from the left and the right end, respectively [@chen2017recurrent]. In this case, Bi-LSTM can not only preserve information from the past, but also catch the information from the future. We obtain the hidden vectors($\overrightarrow{h_i}$ and $\overleftarrow{h_i}$ shown in Equation (8) and (9)) from the sentence encoders and concatenate them to $H^t=[\overrightarrow{h_1};\overleftarrow{h_1},....,\overrightarrow{h_m};\overleftarrow{h_m}]$, $H_i^t\in R^{2u}$ represents the $ith$ news title after encoding in date $t$ and $m$ refers to the sequence number.

[1.0]{} $$\begin{aligned}
    \overrightarrow{h_n} = \overrightarrow{LSTM}(e^s)\end{aligned}$$ $$\begin{aligned}
    \overleftarrow{h_n} = \overleftarrow{LSTM}(e^s)\end{aligned}$$

***Word level Self-attention layer***: Instead of taking the average of the hidden vector after the sentence encoding, we leverage multi-hop self-attention mechanism [@lin2017structured] on top of the Bi-LSTM layer. The attention mechanism takes the whole LSTM hidden states $H^t_i$ as input, and outputs a vector of weights $A$:

$$\begin{aligned}
    A = softmax(W_2tanh(W_1H_i^{t\intercal}))\end{aligned}$$

Shown in figure \[fig:attention\], here $W_1$ is a weight matrix with a shape of $W_1\in R^{d_a*2u}$ which u refers to the hidden unit of the news level Bi-LSTM. and $W_2$ is a vector of parameters with size $W_2\in R^{r*d_a}$, $d_a$ and $r$ are hyper parameter that can be set arbitrarily. $H_i^t$ are sized $H_i^t\in R^{n*2u}$, and the annotation vector $A$ will have a size $A\in R^{r*n}$, the $softmax()$ ensures all the computed weights sum up to 1. Then we sum up the LSTM hidden states $H_i^t$ according to the weight provided by $A$ to get a vector representation $N_i^t$ for the input sentence. We can deem Equation (10) as a 2-layer MLP without bias, whose hidden units numbers are $d_a$ and parameters are ${W_1,W_2}$. We compute the $r$ weighted sums by multiplying the annotation matrix $A$ and LSTM hidden states $H_i^t$:

![\[fig:attention\]Self attention mechanism](attention.PNG){width="100.00000%" height="4.0in"}

$$\begin{aligned}
    N_i^t = AH_i^t\end{aligned}$$

Eventually, the sentence encoding vector $H_i^t$ then becomes a matrix $N_i^t\in R^{r*2u}$ and we use $N_i^t$ to represent the $ith$ news title in date $t$ after encoding. By using multi-hop attention mechanism, the vector representation usually focuses on a specific component of the sentence, like a special set of related words or phrases. Therefore, it is expected to reflect an aspect, or component of the semantics in a sentence instead of adding attention on a specific word.

Shown in equation (12), we apply another MLP layer on top of our self-attention layer to learn which attention group should be rewarded with the highest assign value. We name this as attention-over-attention, the weight matrix have a shape of $W_3\in R^r$, and the final representation of the sentence encoding vector $N_i^t$ are shaped as $N_i^t\in R^{2u}$. At last, we use $N_i^t$to represent a news title encoded from the input.

$$\begin{aligned}
    N_i^t = tanh(W_3N_i^t+b_1)\end{aligned}$$

***News level Self-attention layer***: Not all news contributes equally to predicting the stock trend. Hence, in order to reward the news that offers critical information, we apply the same structure multi-hop self-attention on top of the encoding layer to aggregate the news weighted by an assigned attention value. Specifically:

[1.0]{} $$\begin{aligned}
    A = softmax(W_5tanh(W_4N^{t\intercal}))\end{aligned}$$ $$\begin{aligned}
   D_t = AN^t\end{aligned}$$ $$\begin{aligned}
    D_t = tanh(W_6D_t+b_2)\end{aligned}$$

Here, $N^t=(N_1^t,....,N_m^t)$ and $N^t\in R^{m*2u}$, in which $m$ refers to the number of news in date $t$. Note that the weights $[{W_4,W_5,W_6,b_2}]$ in the news level attention layer are different from the word level attention layer weight $[{W_1,W_2,W_3,b_1}]$. A vector $D_t$ represents the temporal sequence for all the news proposed in the date $t$. The merit of using multi-hop self-attention mechanism is that it learns and assign different groups of attention value to the news encoding. Formally, the first group of attention reward the news that contains positive sentiments to the stock market(“raise”, “growth” or “decrease”, “down” etc). Whereas the second group of attention assign there reward to the news that mentions the major companies in the S&P 500 (“Microsoft”,“Google” instead of a small company outside of the S&P 500).

Obviously, the attention layer can be trained end-to-end and thus gradually learn to assign more attention to the reliable and informative news based on its content.

### Day level Bi-LSTM and self-attention layer

[1.0]{} $$\begin{aligned}
    \overrightarrow{h_i} = \overrightarrow{LSTM}(D_t)\end{aligned}$$ $$\begin{aligned}
    \overleftarrow{h_i} = \overleftarrow{LSTM}(D_t)\end{aligned}$$

We adopt day level Bi-LSTM to encode the temporal sequence of corpus vectors $D_i$, $t\in [1,N]$. Shown in Equation (16) and (17), We obtain the hidden vectors($\overrightarrow{h_i}$ and $\overleftarrow{h_i}$) from the day-level Bi-LSTM and concatenate them to $H_i=[\overrightarrow{h_1};\overleftarrow{h_1},....,\overrightarrow{h_N};\overleftarrow{h_N}]$, $H_i$ represents a vector that encodes the temporal sequence $D_t$ where $N$ refers to the sequence number. Since the news published at different dates contribute to the stock trend unequally, we adopt self-attention mechanism again to reward the dates that contribute most to the stock trend prediction, Shown in Equation below:

[1.0]{} $$\begin{aligned}
    A = softmax(W_8tanh(W_7H_i^\intercal))\end{aligned}$$ $$\begin{aligned}
    V = AD\end{aligned}$$ $$\begin{aligned}
    V = tanh(W_9V+b_3)\end{aligned}$$

In the formula, $D=(D_1,....,D_t)$ and $D\in R^{N*2v}$ , $V\in R^{2v}$ represents the final vector for all news proposed before the prediction date $t+1$ in a delay window with size $N$, where $v$ is the hidden unit number in the day level Bi-LSTM. Note that the weight matrix $[{W_7,W_8,W_9,b_3}]$ in the day level attention layer are different from the weight matrices mentioned in the previous section.

### Output and Prediction Layer

The last stage of our At-LSTM model is a traditional fully connected layer with softmax as activation function whose output is the probability distribution over labels. In this work, the objective is to forecast the direction of daily price movements of the stock price, this direction are used to create a binary class label where a label \[1,0\] represents that the stock price will increase and label \[0,1\] represents that the stock price will decrease.

Experiments
===========

Experimental Setup
------------------

### Data

We evaluated our model on a data set of financial news collected from Reuters and Bloomberg over the time period from October 2006 to November 2013. This data set was made publicly available by Ding et al. [@ding2014using] and shown in table \[tab:Data set\]. We further collected data from Reuters for 473 companies listed in the Standard & Poor’s 500 over the time period started from November 2013 to march 2018. Meanwhile, the historical stock price data from October 2006 to March 2018 for all individual shares in Standard & Poor’s 500 are collected from Yahoo Finance. The second part of the data are used for individual stock price prediction and shown in table  \[tab:individual\]. Due to the page limit, We only show the major companies listed in the S&P 500, this will also be applied in the result section.

[ |p[3cm]{}||p[3cm]{}|p[3cm]{}|p[3cm]{}| ]{}\
Data set & Training & Development & Testing\
Time interval & 20/10/2006-27/06/2012 & 28/06/2012-13/03/2013& 14/03/2013-20/11/2013\
News& 445,262 & 55,658 & 55,658\

[ |p[3cm]{}||p[3cm]{}|p[3cm]{}|p[3cm]{}| ]{}\
Company Symbol & Training news& Development news& Testing news\
GOOG & 5744 & 718 & 718\
AMZN & 3245 & 406 & 405\
CSCO & 2471 & 309 & 308\
MSFT & 4056 & 406 & 405\
AAPL & 9720 & 1215 & 1214\
INTC & 4355 & 545 & 544\
IBM & 2016 & 252 & 252\
AMD & 1224 & 153 & 153\
NVDA & 1440 & 168 & 167\
QCOM & 924 & 116 & 115\
WMT& 2793 & 350 & 349\
T& 1228 & 154 & 153\

Following Ding et al. [@ding2014using] we focus on the news headlines instead of the full content of the news articles for prediction since they found it produced better results. We use news articles on each day and predict if the S&P 500 index closing price movement (increase or decrease) in the day $t+1$ compared with the closing price on day $t$.

### Implementation Details

As mentioned in the previous section, We pre-trained 100 dimentional word embedding [@mikolov2013efficient] with skip-gram algorithm on the data set shown in table \[tab:Data set\], the size of the trained vocabulary is 153,214. In addition, firm names and an UNK token to represent any words out of the vocabulary are added to the vocabulary set, having an initial embedding initialized randomly with Gaussian samples. The word embedding are fine-tuned during model training. The character embedding has 15 dimensions, and CNN filters length are \[1,3,5\] respectively, each of those are 32 dimensions. The news level Bi-LSTM and day-level Bi-LSTM both have 300 hidden units, the day level LSTM window size $N$ has been set to 7. Hyper-parameters $d_a$ and $r$ in the self attention layer are set to 600 and 10, respectively. Mentioned in section 3, we use Adadelta for our optimization algorithm, the initial learning rate has been set to 0.04. Our model are trained for 200 Epoch.

Base Lines and Proposed Model
-----------------------------

In this subsection, we propose a few baselines to compare with our proposed model. For the sake of simplicity, the following notation identifies each model:

-   ***SVM***: Luss and d’Aspremont et al.  [@luss2015predicting] propose using Bags-of-Words to represent news documents, and constructed the prediction model using Support Vector Machines (SVMs).

-   ***Bag-At-LSTM***: At-LSTM without sentence encoder. We take the average of the word embedding inputs instead of using Bi-LSTM to encode the news title.

-   ***WEB-At-LSTM***: Same as our proposed model but without the character level composition.

-   ***Ab-At-LSTM***: Instead of the news title, we use the news abstract as input for our model, the model structure remains the same.

-   ***Doc-At-LSTM***: We further leverage a Hierarchical Attention Networks proposed by Yang et al. [@yang2016hierarchical] to represent the entire news Document, this model adds a sentence level attention layer into our proposed model to differentiate more and less important content when constructing the document representation.

-   ***Tech-At-LSTM***: We concatenate seven Technical indicator leveraged from Zhai et al. [@zhai2007combining] shown in figure  \[fig:tech\] with the vector $V$ after the day level LSTM layer and fed together into the prediction layer.

    ![\[fig:tech\]Self attention mechanism](tech.PNG){width="100.00000%" height="3.0in"}

-   ***CNN-LSTM***: We use CNN instead of the news level self-attention layer. Note that the word and day level self-attention layer still remains the same. We want to see how well the self-attention layer works compared to CNN which is good at capturing local and semantic information from texts.

-   ***E-NN***: Ding et al. [@ding2014using] reported a system that uses structure event tuples input and standard neural network prediction model.

-   ***EB-CNN***: Ding et al. [@ding2015deep] proposed a model using event embedding input and Convolutional Neural Network as prediction model.

-   ***KGEB-CNN***: Ding et al. [@ding2016knowledge] further incorporated an outside knowledge graph into the learning process for event embedding. The model structure is the same as EB-CNN.

Result and Discussion
---------------------

Shown in table \[tab:Result\], the results on the comparison between the models SVM and the rest of the models indicates that deep neural network model achieves better performance than the SVM model. Comparison between Bag-At-LSTM and At-LSTM demonstrates that sentence encoding with LSTM have slightly better result than Bag-of-words model. Furthermore, WEB-At-LSTM and At-LSTM indicates that the character level composition helps improved the models accuracy. The technical Indicator leveraged from Zhai et al. [@zhai2007combining] doesn’t show any performance improvement to our model. In contrast, it results in a decline on the accuracy and it might be caused by adding noise to the dense representation vector $V$ before the output and prediction layer. The comparison between CNN-LSTM and At-LSTM shows that the news level self-attention layer can help capture more relevant news titles and their temporal features. As Ding et al. concluded in [@ding2014using], the news titles might contain more useful information where as the abstract or article might cause some negative effect to the model. The Ab-At-LSTM and Doc-At-LSTM confirmed this viewpoint since their accuracy are lower than the proposed model that only used the information from the title.

Our proposed model has a 65.53% max accuracy and a average accuracy of 63.06% which is lower than the KGEB-CNN proposed by Ding et al., this is likely due to Knowledge graph event embedding (KGEB) is a more powerful method for model the content in news titles than the sequence embedding shown in this work.

[|p[3cm]{}||p[3cm]{}|p[3cm]{}|]{}\
Model & Average Accuracy & Max Accuracy\
SVM & 56.38% & –\
Bag-At-LSTM & 61.93% & 63.06%\
WEB-At-LSTM & 62.51% & 64.42%\
Ab-At-LSTM & 60.6% & 61.93%\
Doc-At-LSTM & 59.96% & 60.6%\
Tech-At-LSTM & 62.51% & 64.42%\
CNN-LSTM & 61.36% & 63.06%\
E-NN & 58.83% & –\
EB-CNN & 64.21% & –\
KGEB-CNN & **66.93**% & –\
At-LSTM & 63.06% & **65.53**%\

We use the At-LSTM model for individual stock price prediction after confirmed that it out performs other approaches. The results are shown in table \[tab:indiResult\], each stock shown in the table has more than 66% accuracy and the company WALMART has an average accuracy of 70.36% and max accuracy of 72.06%. Apparently, predicting individual stock price leads to higher accuracy than predicting S&P 500 index, and this is mainly due to the news article we used for input. In terms of the individual stock prediction, the news article we used are more relative to it’s corresponding company. In contrast, we used the full corpus as input for S&P 500 index prediction and certainly this adds noise to our model and hence effects the accuracy.

[|p[3cm]{}||p[3cm]{}|p[3cm]{}|]{}\
Company & Average Accuracy & Max Accuracy\
GOOG & 68.75% & 71.25%\
AMZN & 67.32% & 69.46%\
CSCO & 66.82% & 67.62%\
MSFT & 67.92% & 69.89%\
AAPL & 67.52% & 69.42%\
INTC & 67.12% & 67.63%\
IBM & 69.49% & 71.41%\
AMD & 66.12% & 69.10%\
NVDA & 69.35% & 70.51%\
QCOM & 68.53% & 69.70%\
WMT& **70.36**% & **72.06**%\
T& 68.53% & 69.70%\

Conclusion
==========

This paper has been motivated by the successes of Deep learning methods in Natural Language Processing task. we proposed a Attention-based LSTM model(At-LSTM) to predict the directional movements of Standard & Poor’s 500 index and individual companies stock price using financial news titles. Experimental results suggests that our model is promising and competitive with the state-of-the-art model which incorporate knowledge graph into the learning process of event embeddings [@ding2016knowledge].

There are some directions in our future work. While previous work and our result has found that including the body text of the news performs worse than just the headline, there may be useful information to extract from the body text, other directions include looking at predicting price movements at a range of time horizons, in order to gauge empirically how quickly information are absorbed in the market, and relate this to the finance literature on the topic. The financial time series are known by its volatility, in many cases small changes in the series that can be interpreted as noise. Moreover, the elimination of small variations makes the model focus only on news with significant variation on prices which might lead to accuracy increase.
