Stock Trading Using PE ratio: A Dynamic Bayesian Network Modeling on Behavioral Finance and Fundamental Investment

Stock Trading Using PE ratio: A Dynamic Bayesian Network Modeling on Behavioral Finance and Fundamental Investment

Haizhen Wang, Ratthachat Chatpatanasiri, Pairote Sattayatham
School of Mathematics, Suranaree University of Technology, THAILAND,,

On a daily investment decision in a security market, the price earnings (PE) ratio is one of the most widely applied methods being used as a firm valuation tool by investment experts. Unfortunately, recent academic developments in financial econometrics and machine learning rarely look at this tool. In practice, fundamental PE ratios are often estimated only by subjective expert opinions. The purpose of this research is to formalize a process of fundamental PE estimation by employing advanced dynamic Bayesian network (DBN) methodology. The estimated PE ratio from our model can be used either as a information support for an expert to make investment decisions, or as an automatic trading system illustrated in experiments. Forward-backward inference and EM parameter estimation algorithms are derived with respect to the proposed DBN structure. Unlike existing works in literatures, the economic interpretation of our DBN model is well-justified by behavioral finance evidences of volatility. A simple but practical trading strategy is invented based on the result of Bayesian inference. Extensive experiments show that our trading strategy equipped with the inferenced PE ratios consistently outperforms standard investment benchmarks.

Keywords: Bayesian Inference, Dynamic Bayesian Network, Fundamental Investment, PE Ratio, Behavioral Finance

1 Introduction

With the rapid advancement of machine learning technology, recent works make attempts to incorporate these machine learning techniques to construct trading systems that support decisions of investors in security markets [1, 2, 3, 4, 5, 6] (see also references therein). These recent works have the following common philosophical theme.

Common Philosophy of Applying Machine Learning to Financial Data:
There exist hidden patterns in financial time series. Complicated techniques (and their combinations) such as support vector machine, multiple kernel learning, independent component analysis, hidden Markov models, fuzzy modeling and so on, can help investors discover hidden patterns represented by complicated mathematical formulas. The retrieved formulas can be used as forecasting rules to predict stock’s directional movements, which in turn can be incorporated into investor’s trading strategy (buy low and sell high, as predicted by the rules) to make an excess return in the market.

Based on the same philosophy mentioned above, existing works, however, have common limitations. Firstly, the discovered patterns are so complicated (highly non-linear) and lacked of financial interpretation; note that, in general, higher degree of pattern complexities are more risky to overfit the training data [7]. Secondly, each financial time-series has to be trained separately, resulting in one set of distinct patterns for each different security. In other words, there is no common pattern in the data of interested securities. Thirdly, because of pattern complexities, practical trading implementations are not easy for some investors. In fact, sophisticated trading program has to be constructed by users themselves. Lastly, there is no direct way to incorporate existing expert information (such as professional security analysts’ recommendations) into the learning system. Fairly speaking, although having the mentioned limitations, the core philosophy of existing research matches the philosophy of one certain investor group called technical analysts [8, 9]. Technical analysts believe in price patterns and do not pay much attention to economic interpretation of the patterns. Therefore, this line of existing research may benefit this group of investors.

On another side of investment practitioners, there is a group named fundamentalists whose trading strategies have clear financial interpretations and are based on well-defined financial information [10, 11, 12]. Price-earning ratio (simply called PE ratio, to be defined below shortly) is one of the most widely applied valuation toolkits for fundamentalists to make their investment decisions [11, 13]. Also, investment recommendations by security analysts are often based on PE ratios [14]. Nevertheless, it is unfortunate that recent academic advancements in financial econometrics and machine learning rarely look at this tool so that the current practical application of PE ratio has to depend solely on expert knowledge. To our knowledge, there is currently no formal framework capable of integrating expert knowledge with historical financial time-series data to make a systematic inference of PE ratio from available information.

In this research, we focus on applying a Bayesian statistical analysis to formalize the process of stock valuation using the PE ratio. We apply the powerful framework of dynamic Bayesian network [7, 15] to model the valuation process. In contrast to existing machine learning frameworks mentioned above on price pattern discovery where the discovered patterns have no meaning in finance, the interpretation of our model is well justified according to behavioral finance [16] as explained in the Section 2. The main contributions of our work are threefold. Firstly, to our knowledge, we are the first to propose applying the machine learning framework to formalize the PE ratio valuation process which somehow rarely gets attention from academic researchers. Secondly, unlike existing works where there are different discovered patterns for different securities, our proposed trading strategy resulted by the Bayesian framework is unified, i.e. we propose a single trading strategy which can be applied to every security as explained in Subsection 1.1. The proposed strategy is simple and has a clear financial interpretation so that it can be easily applied by every practitioner (no requirement on writing a sophisticated system trading program). Moreover, expert opinions can be naturally integrated to our Bayesian learning framework. Thirdly, as our proposed dynamic Bayesian network having non-standard structure compared to literatures [7, 15], we have successfully derived the new inference formulas by applying the forward-backward methodology, and the new parameter estimation algorithm according to the concept of Expectation-Maximization [7, 15].

Note that in this paper, we focus on investment in individual firm-level securities which are usually preferred by individual investors; in contrast to investment institutions whose investment strategy is usually on portfolio level based on Modern Portfolio Theory [17].

1.1 Background of fundamental investment based on PE ratio

The core idea of the PE ratio valuation method is simply that the value of the firm (and hence the value of its stock) is directly proportional to the annual net income (also called earning) of the company, i.e. for each firm ,


where denotes the value of firm , denotes the firm’s current annual earnings and is the firm’s appropriate PE ratio, usually assumed to be a constant (at least for some period of time). Here, the annual earning is defined by the summation of the latest four quarterly earnings. The earnings information of each firm listed in the stock market is normally available to all investors, i.e., it is observable.

The PE ratio, intuitively, can be thought of as a premium of an individual firm, i.e., given the same earning for two firms, the firm with higher PE ratio is considered to be of higher value. Conceptually, the appropriate PE ratio of each firm is usually determined by experts using business and financial accounting factors such as debt burden, cash flow, growth rate, business risk, etc. There exists an alternative approach to estimate the PE ratio called the relative approach [11] which still requires experts to select a group of similar firms altogether, and the ratio is heuristically calculated from this group. To summarize, the current best practice for PE ratio estimation is to be heuristically calculated by experts or experienced investors.

Once we get the PE ratio, we can simply calculate firm value, often called intrinsic value, by Eq.(1). A simple trading strategy is to compare the firm value with a market price of the firm.

Strategy A: if the firm value is higher than its market price by some threshold, it is considered to be at low price, so that we can buy the firm’s stock. We expect to sell it later when its market price is higher than the firm’s intrinsic value by some threshold.

It is important to note that the philosophy of this trading strategy is that market price is not always equal to the value of the firm. We can observe that the price of firm’s stock changes almost every working day in a stock market. In contrast, by Eq. (1), the firm’s value will not change in a short time period provided that there is no new announcement on annual earnings in that period. There has been long controversy about this “price vs. value” issue [10], but it is beyond the scope of this paper. In any cases, it is a fact that there exists a large group of individual investors namely fundamentalists employing the PE ratio as their main tool. Instead of solely relying on expert opinions, the goal of this paper is to support that group of investors to systematically determine the appropriate PE ratio, by the method of Bayesian statistical analysis which is able to formally combine information from historical data with expert beliefs.

Finally, we emphasize that there is another quantity called an observed PE calculated from firm’s current market price divided by its earnings (note again difference between value and price ), that is,


where is the current market price of a firm . In Bayesian analysis of the PE ratio, it is important to distinguish between the observed (changing everyday due to changes of ) and . Here we will call as the fundamental PE ratio. The reason behind this name is the following: only a group of fundamentalists believe that the quantity , or firm value, is able to calculated by Eq. (1). Therefore, they usually call as the fundamental price or fundamental value, and so as fundamental PE. To them, there exist various kinds of investors in the market: some are rational and some are irrational. The current market price and hence, too, the observed can fluctuate from the fundamental price by actions of those irrational investors. We shall formally model this argument in Section 2.

2 Statistical model of stock price dynamics

2.1 Motivation of statistical modelling: behavioral volatility

In Subsection 1.1 we mentioned about fundamentalists’ belief that market price of a security may not equal to its fundamental value. Why does stock price deviates from its fundamental price? Works on behavioral finance [16] found many evidences for this question. For example, researchers argue that there are noise traders in the market who tend to make irrational actions so the price can move away from its value [18, 19, 20]. One of the works found that some investors cannot process new information correctly and so overreact to new information [21]. What is worse, information which investors overreact is, many times, unconfirmed [22] or unreliable [23, 24] or even unimportant [25, 26]. Also, investors who consult experts may not get much helpful advice since security analysts tend to be overoptimistic [27] and having conflict of interest [28]. Finally, it is well known that even rational investors in the market cannot immediately eliminate this irrational pricing due to limit of arbitrage [29]. All the effects mentioned here are able to temporarily move away a stock price from its value for a period of time. This is what we call behavioral volatility. The effects continue until either they are cancelled out, or rational investors finally eliminate this mispricing. This reversion phenomena is called mean reversion in literatures.

2.2 Dynamic Bayesian Network of stock price movement

Our model simplifies and formalizes the observations described in Subsection 2.1. We divide the temporary effects which cause mispricing into two categories: (1) short-term effects: mispricing effects which last about a few days, e.g. effects causing by noise trading or overreaction to unreliable information and (2) medium-term effects : mispricing effects which last several weeks or months, e.g. effects caused by reaction to unconfirmed information which may take time to confirm, or overoptimistic prediction of analysts which may take time to prove. Mathematically, the relation between market price and its fundamental value can be described as the following equation. To simplify the equation, since we consider only one firm at a time, we now replace the firm-index subscript with a time-index subscript to emphasize the dynamic relationship between price and its fundamental value.



(a) is a random variable modeling the medium-term noisy effects. To make its effects persist for a period of time, we model as a Markov chain.

(b) is a random variable for the short-term noisy effects which is modeled by a Gaussian random noise, .

Assuming as a constant for the period which we observed, and following Eq. (1) of Section 1, we have


and, therefore, we get the relationship between the fundamental PE and the observed PE:


Note that our model is suitable only for a firm with positive earnings . Fortunately, most firms satisfy this criterion. Eq. (5) is central to our idea and can be visualized as shown in Figure 1.

Figure 1: Illustration of our main idea described by Eq. (5). The plot is the observed PE vs. date. Red dashed line shows of the firm, while Green line illustrates the effect of medium-term noisy effect to . Blue line illustrates the observed PE which is affected by both the medium-term and short-term mispricing effects.

We can mathematically simplify Eq. (5) further


Since is usually small, it can be approximated by , and denote , we then have


Note that as explained in Section 1, is an observable quantity, while and are unobservable, i.e. they are hidden state or latent variables. Note that these are two different types of latent variables, i.e. is constant and is time-varying. Thus, Eq. (7) is different from standard state-space and graphical models such as Hidden Markov Models or Linear State Space Model [7]. The graphical model of our proposed stock price dynamic has three layers as represented in Figure 2. In our case, where the model is temporal, the graphical model framework is also called dynamic Bayesian network (DBN). The main advantage of DBN is its ability to encode conditional independent properties, and hence simplifying probabilistic inference [15]. Another advantage of this framework is that expert knowledge can be integrated in the model naturally as shown in the next section.

Figure 2: The proposed model represented by dynamic Bayesian network (DBN). is an observable quantity, while and are unobservable.

To derive mathematical equations for inference and parameter estimation in the DBN framework, we shall assume that all latent random variables are discrete: , . Furthermore, we have to set up the conditional probability distribution function for each node given its parents. We define the conditional probability distribution functions of all nodes as follows:

The transition probability distribution function:

Let ,


Note that . The matrix is called a transition matrix, i.e. is a Markov chain.

The emission probability distribution function:

For all , ,


By Eq. (6), . The matrix is called an emission matrix at period .

The inital probability distribution functions:

For each ,


where and .

For each ,


where and .

The vectors and are called initial vectors.

Therefore, in this Bayesian framework, the set of model parameters is and our parameters space is


If we know all parameters, we can make an inference by deriving inference equations based on the forward-backward algorithm as shown in Subsection 3.1. If the parameters are unknown, we have to estimate them first. In this paper, we derive the estimation procedures based on Maximum a Posteriori (MAP) and Expectation-Maximization (EM) algorithms. In the next section, we show how we derive both the inference and parameter estimation algorithms.

3 Bayesian inference on the DBN of stock price dynamic

As explained in previous sections, our goal is to make an inference on PE* so that we can estimate the fundamental price of a stock. In Section 4, we will show that estimations of is also useful in investment. To infer the values of these two latent variables, similar to Hidden Markov Models (HMM) and Linear State Space Model (LSSM) [7, 15], we need to derive equations in two steps. First, the inference algorithms with known parameters, second, the parameter estimation algorithms given that parameters are unknown. However, because there are two types of latent states as explained in the previous section, our graphical model shown in Figure 2 is more sophisticated than HMM and LSSM. In this section, we show the new equations for both inference tasks. To simplify the notation, we use notation to denote .

3.1 Inference with known parameters

Suppose is known, together with the observed data . Similar to HMM, in order to estimate the latent states of and , we need to find recurrent formulas to calculate two quantities: the filtering probabilities and the smoothing probabilities , . To keep our formulas simple, in this Section, we will omit writing in the probability notations, e.g., we simply write for filtering.

The filtering formula, which estimates conditional joint probabilities of the most recent medium-term effect and given all the observed variables, is given by the following recurrent formula:


In the above derivation, Bayes’s rule, conditional independent properties [15] with respect to DBN shown in Figure 2 and sum rule are applied consecutively to get the above result, similar to the filtering equation of HMM. The initial equation of the recurrent formula can be derived similarly: .

Next, the smoothing formula, which estimates conditional joint probabilities of the any-date medium-term noisy effect and given all the observed variables, is given by the following so-called forward-backward formula in Eq. (14) :

For all , (note that


Note that conditional independent properties of our DBN are applied in the first term. Also note that the second term is in fact a filtering probability. Therefore, we need to concentrate only on the first term, which has the following recurrent relation:


The end condition can be solved similarly

With the derived recurrent formulas, we can get the most probable values of wanted latent variables and each by using marginalization, e.g.

where . To implement both filtering and smoothing in computer program, we also need to solve the formulas for the constants appeared in the above derivations. To fulfil this task, using matrix reformulation of the above recurrent equations is the most convenient and efficient way. Below, we give only the end results because the details exceed space limitation. Derivation details can be found in the full version of this paper [30].

To get matrix formula, first denote a filtering density as . When , define and define . From Eq.(13), we then have . Define . It can be shown that . Denote the matrix , we can show that


where denotes the entrywise (or Hadamard) product of the matrix. and W denote the emission matrix and transtion matrix, respectively, as described in Section 2. For the initial case, we have


where u and v are as defined in Section 2. To get a matrix formula for a smoothing density, we first define


From Eq.(14), we then have the smoothing density for


Denote the matrix , we can show that




3.2 Inference with unknown parameters

In general situations, is unknown, so only the observed data is available. In this case, must be estimated first. Expectation Maximization (EM) is a general method capable of estimating the parameters in Maximum Likelihood and Maximum a Posteriori (MAP) problem settings for probabilistic models with latent variables [31]. Here, we formulate our parameter estimation in the MAP setting so that expert’s prior knowledge can be employed into the model. Formally, we would like to solve the following problem of maximizing the posterior pdf of .


EM find a solution of Eq. (22) by iteratively solving the following two steps with the arbitrary set of initial parameters and a prior . Iterating from , do

E-Step: Calculating smoothing probabilities ,

M-step: Solving the constraint maximization problem,




EM repeats the two steps until converges. Note that EM guarantees to find a local maxima of Eq. (22) [7]. The argument in the expectation of Eq. (24) is simply the log-likelihood of the model:


According to DBN, they are simply the logarithms of the emission pdf, transition pdf and initial pdf, respectively. By equation manipulations, the expectation Eq. (24) can be calculated by employing the smoothing probabilities already done in the E-step. As a result, we get a closed form of Eq. (24). Combining with the term described below, the constraint maximization Eq. (24) is well defined and readily to be solved by using the method of Lagrange multipliers [32]. All derivations details, which have the same mathematical structure for the simpler case of HMM [7], are quite long and can be found in the full version of this paper [30].

Experts can put their knowledge into the parameter estimation procedure via in Eq. (23). Here, we assume that all parameters are independent, . In our experience, investment experts usually have two types of knowledge which are useful to estimate . The first type of knowledge is about . Often, experts may be able to estimate the range of appropriate level by analyzing a firm’s business strategy together with competitions in its industry. The second type of knowledge is about the degree of persistence of the medium-term noisy effect which makes a stock price deviates from its fundamental for a considerable amount of time as explained in Section 2. For some firms, e.g. a firm with non-existent investor relation department, when there exist some unconfirmed rumors, its price can deviate from its fundamental for a long period. In contrast, some firms with both strong public and investor relation departments can clear up unconfirmed rumors rather quickly, so this rumor effect will not stay long. The two types of expert information can be encoded on and , respectively. The prior for the vector can be represented via the Dirichlet distribution:


Intuitively, is a degree of belief for each possible value . Experts can employ their believes that some value of , e.g. is relatively more probable than other values by giving relatively higher value than other . See [33] for more details on the Dirichlet prior. The prior on transition matrix encoding the average persistence degree of the medium-term noisy effect can also be described by a product of Dirichlet priors: , where as defined in Section 2, denotes a vector of a probability , and


The persistence degree of the medium-term effect can be set by relatively increasing the values of compared to other values . The relatively higher of , the more persistence of the medium-term effect. Since medium-term effect appears at random, other values can symmetrically be set: , for .

4 Experiments

In this section, we illustrate benefits of our methodology in real-world applications. To do this, we will conduct comprehensive trading simulations to show consistent superior performances of our method over standard benchmark. In literatures of Finance, according to Efficient Market Hypothesis [34, 35, 10] which is widely accepted by mainstream researchers, the gold standard benchmark is, surprisingly, the simple “buy and hold” method which empirically proves to be efficient in the long run. Astonishingly, many evidences clearly indicate that most mutual fund managers who apply complex active portfolio management techniques cannot beat the simple “buy and hold” of the market portfolio [36, 37]. In this paper, we will test our method against this gold standard “buy and hold” method both on individual stock level and on portfolio level.

4.1 Experiment setting

In this paper, we will make trading simulations in the markets of two different countries where we can access historical data: NYSE (New York Stock Exchange) and NASDAQ in US and SET (Stock Exchange of Thailand) in Thailand. While NYSE and NASDAQ represent matured stock markets, SET represents an emerging market, so that we are able to test our methodology to firms on both market phases. For each country, we collect 10 firms from various industries to ensure that our methodology is not just limited to one specific industry. Each selected firm is well established and has at least 5 year historical trading data. The names of selected companies with their respective sectors for Thai stocks and US stocks are shown in Table 1 and Table 2, respectively.

We collect daily 5-year historical closing-price data for each firm (Jan 1, 2012 to Sep 30, 2016) consisting of 1160 closing prices for stocks in SET and 1195 closing prices for stocks in NYSE and NASDAQ, respectively. The difference in the number of data is due to different working days in the two countries. All data are adjusted for stock splitting and stock dividending if occuring during this 5-year period. To avoid duplicated writing, here, we shall explain only experiment settings for stocks in SET with historical price .The experiment settings for stocks in NYSE and NASDAQ are done similarly.

Symbol Industry    Size
CPALL Retailing-Food and Staples BigCap

Developer-Department Stores BigCap

Utilities-Water Resources MidCap

Utilities-Power Plant BigCap

Retailing-Household Products BigCap

Developer-Housing MidCap

Retailing-General MidCap

Banking BigCap

Electrical Equipments SamllCap

Utilities-Tap Water MidCap

Table 1: Stock symbols of selected firms from Thailand, together with their industries. BigCap, MidCap and SmallCap are defined according to market sizes (in THB) which are greater than 100 billions, 10 billions and 1 billions, respectively.
Symbol Industry    Size
WMT Services-Discount and Variety stores

Services-Home improvement stores

Consumer Good-Beverages soft drinks

Services-Business services

Consumer Goods-Electronic equipment

Consumer Goods-Textile-Apparel Footwear and Accessories

Financial-Asset Management

Basic Materials-Agricultural Chemicals

Technology- Networking and Communication Devices

Services-Entertainment Diversified

Table 2: Stock symbols of selected firms from US, together with their industries. BigCap, MidCap and SmallCap are defined according to market sizes (in USD, Data retrieved on Dec 7, 2016)

For each firm, the corresponding yearly earnings data in those years are also collected. are defined as the summation of the most recent 4 quarterly earnings on each data . The first 3-year historical data (Jan 1,2012 to Dec 31,2014) and will be used as a training data for our Bayesian methodology to learn the appropriate parameters using the EM algorithm as well as estimate the most probable values of and by the method of smoothing as explained in Section 3. The constants and are set by experts. Since the constant determines the size of the transition matrix , we make a constraint so that the model is not over-parameterized and that 3-year historical data is enough to learn W. For all prior distributions, we employ non-informative priors with the exception of where our “security experts” emphasize the prior knowledge of persistency as described in Subsection 3.2.

Each trading simulation is conducted for each individual stock with the remaining 2-year historical data to measure the performance of both our method and the benchmark. The performance measurement metric is, as used by practitioners, a profit generated by each method. The profit calculation is straightforward: for each trading simulation, each method is equally given an initial amount of cash to make a trade (which taken into account a commission fee), and the profit are simply all the asset values at the end of a simulation minus . For simplicity, we assume that each stock can be bought with all the money we have, e.g. supposing we have and a stock’s price is , then we are able to buy stocks.

Using the benchmark “buy and hold" strategy we simply need to buy the stock with all the cash at the beginning and then do nothing until the end. Initially, this method will get shares where represents the value of assets after taking SET’s commission fee into account. At the end of the simulation this asset will have a value of , so the profit can be calculated easily. For a trading strategy employed by our method, there are two possible versions inspired by our model’s main idea (see Figure 1) and Strategy A (buy low, sell high) described in Section 1. The first version called long-term strategy is simply to “buy low, sell high" with respect to the static value of , and the second version called medium-term strategy is to “buy low, sell high" with respect to the dynamic values of where each is dynamically estimated by the method of filtering described in Subsection 3.2. Both versions can be formally described as follows.

Let and be available cash and total shares at date , respectively. Initially, and . Now, both trading versions can be defined simply by the following procedure: for each date , exactly one of the following cases holds:

(i) and (buy-low case) where is a threshold, for the long-term strategy and for the medium-term strategy. In this case, buy the stock with all cash, so that and .

(ii) and (sell-high case). In this case, sell all the holding stock to get cash and .

(iii) If case (i) and case (ii) are not satisfied, do nothing. So, and . At the end of a trading simulation , the total profit is simply , so that we can compare with the "buy and hold" profit.

We give some illustrations of our trading in actions which are shown in Figure 3 and Figure 4. Figure 3 is an example of long-term trading of CPALL with threshold 0.05 and Figure 4 is an example of medium-term trading of CPALL with threshold 0.05.

Figure 3: CPALL example of long-term strategy trading with threshold where our model’s profit is 58.43% while “buy & hold” profit is 44.46%. “Green circle” denotes “buy” and “Black cross” denotes “sell”. Top and bottom figures show the same trading in different perspectives The top figure shows trading with respect to the “PE” perspective where Red line denotes . Here, it is easy to see our strategy in action: when the observed PE is lower or higher than the threshold level, buy or sell is triggered, respectively. The bottom figure shows trading in the “price” perspective when Red line denotes . Since the earnings continue to increase, also increase accordingly.
Figure 4: Example of medium-term strategy trading of CPALL with threshold . In addition to those explained in Figure 3, in the top figure, the purple dashed line denotes , and becomes the base line of this trading strategy. Note that our Bayesian method estimates the purple line by the method of “filtering” which tracks the observed PE movements with some delay. The bottom figure is the “price” perspective where the purple line shows . In this example, “buy & hold” method beats ours by small margin because of the commission fees caused by our frequent trading.

4.2 Experimental results and discussions

4.2.1 Individual-firm level experiments

To ensure that our experimental results are not biased because of a threshold choice, we test 4 different thresholds for each trading strategy. Note that the thresholds in the medium-term trading are relatively smaller than those in the long-term. This is due to the nature of medium-term strategy where has a smaller deviation from its base line compared to the long-term strategy’s base line, not containing the effect of . The experimental results with respect to Thai stocks and US stocks are shown in Table 3 and Table 4, respectively.

Symbol Long-term Thresholds Medium-term Thresholds Buy & Hold
5% 10% 15% 20% 3% 5% 7% 10%
CPALL 58.40% 38.74% 49.74% 56.42% 26.92% 42.59% 32.08% 36.34% 44.46%
CPN 30.67% 30.67% 30.67% 30.67% -1.06% -6.39% -4.32% 14.04% 30.67%
EASTW 9.16% 6.18% 4.29% 4.29% 10.49% 3.93% 15.07% 20.64% 9.16%
GLOW -11.78% -11.78% -11.78% -11.78% -3.24% -14.16% -10.66% -3.13% -11.78%
HMPRO 31.88% 47.93% 58.00% 0% 51.69% 69.87% 86.49% 8.87% 32.28%
QH -24.08% -24.08% -24.08% -9.70% 5.73% 0.49% 4.08% 2.31% -24.08%
ROBINS 36.28% 36.28% 36.28% 36.28% 32.70% 36.77% 45.64% 36.97% 36.28%
SCB -17.46% -17.46% -14.10% -9.08% -11.67% -14.09% -14.74% 4.79% -17.46%
SNC -4.45% -4.45% -7.00% -0.91% 18.46% 8.20% 8.02% 8.20% -4.45%
TTW 0.00% 0.00% 0.00% 0.00% -1.31% -0.50% 3.67% 0% -3.73%
Average 10.86% 10.20% 12.19% 9.62% 12.92% 12.67% 16.55% 12.90% 9.14%
W/D/L 2/7/1 2/6/2 4/4/2 5/3/2 7/0/3 6/0/4 8/0/2 7/0/3
13/20/7 28/0/12
Table 3: Experimental results in profit percentage of our Bayesian trading strategies compared to the benchmark “buy and hold” method on Stock Exchange of Thailand (SET). Bold face numbers indicate a case which our method is superior. On the last row, “W/D/L” summarizes Win/Draw/Lose of our method compared to the benchmark.
Symbol Long-term Thresholds Medium-term Thresholds Buy & Hold
5% 10% 15% 20% 3% 5% 7% 10%
WMT 6.07% 13.00% 23.04% 0.00% 20.47% 5.97% 12.02% 0.00% -11.98%
HD 10.56% 28.71% 28.71% 28.71% 48.35% 40.77% 27.55% 27.48% 28.71%
KO 6.06% 6.06% 6.06% 6.06% 20.61% 17.24% 0.00% 0.00% 6.06%
G 5.33% 26.50% 26.50% 26.50% 37.40% 29.74% 21.22% 1.14% 26.50%
AAPL 5.19% 5.19% 5.19% 5.19% 18.69% 22.83% 41.27% 26.84% 6.77%
NKE 12.72% 12.72% 12.72% 12.72% 22.53% 25.00% 24.50% 32.96% 12.72%
BK 26.36% 23.72% 1.42% 1.42% 5.52% 6.44% -3.68% 4.84% 1.42%
CF 27.16% 15.87% -53.74% -53.74% -17.60% -16.84% -36.21% -41.05% -53.74%
CSCO 12.00% 23.00% 20.48% 20.48% 8.42% 10.98% 14.98% 20.00% 20.48%
DIS 0.82% 0.82% 0.82% 0.82% 14.37% 12.17% -1.45% -8.47% 0.82%
Average 11.23% 15.56% 7.12% 4.82% 17.88% 15.43% 10.02% 6.37% 3.78%
W/D/L 3/3/4 4/5/1 1/8/1 1/8/1 9/0/1 9/0/1 4/0/6 5/0/5
9/24/7 27/0/13
Table 4: Experimental results in profit percentage of our Bayesian trading strategies compared to the benchmark “buy and hold” method on US stock markets: NYSE and NASDAQ.

From the tables, we can see that in the total of 80 trading simulations on SET firms, our method results in greater performance 41 times, while “buy and hold" results in better performance 19 times (the remaining 20 times are draws). Similarly, in the total of 80 trading simulations on NYSE and NASDAQ firms, our method results in greater performance 36 times, while “buy and hold" results in better comparison 20 times (the remaining 24 times are draws). Summing up results of markets in the two countries, our method outperforms the benchmark 77 times, yet underperforms only 39 times. These are promising results where we shall analyze statistically significancy of the results more formally in the next subsection. Here, we shall firstly interpret and discuss about experimental results in Tables 3 and 4 in details.

From Tables 3 and 4, it can be seen that there are 44 draws, which occur only in the cases of the long-term trading strategy. All 44 draws happen because of the exact same reason: our model predicts of undervaluation at the beginning of the testing period. i.e. the first observed PE falls deeply below the base line (exceeding the specified threshold). After that, the observed PE is never once able to overly exceed with respect to the given threshold, i.e. is quite high in the test set so that no selling is possible. Therefore, in this case, our trading behaves exactly just like the benchmark “buy and hold". Note that there is no draw in the results of the medium-term trading strategy. The reason is because the estimated medium-term noisy effect makes the base line move near to the observed PE which results in more frequent trading.

Disregarding the draws, our long-term trading strategy still beats the benchmark with 22 wins versus 14 loses. This is mainly due to the volatility of the observed PE in most stocks so that our strategy of buying in an undervalued price and selling in an overvalued price with respect to is possible. However, it is not the case that trading induced from our model constantly outperforms the benchmark. For the case of the so-called growth stocks [12], i.e. stocks with consistently increasing earnings and price, it is not so easy for our model to beat the benchmark. If the threshold is set too low, our method will lead to buying and selling early, and thus results in less profit. See Figure 5 for example. If the threshold is set too high, our method may lead to buying when the price is already high or lead to doing nothing at all because it is never undervalued with respect to the specified threshold. Another special case where our method fails to beat the benchmark is when there are the so-called non-recurring earnings, i.e. extra incomes which occur only once and should not be taken into account the calculation of fundamental value. In this case, the market knows that these extra earnings are temporary and do not give it credit, i.e. the price does not go up according to this profit. Our method has not taken this information into account and thus is fooled to believe that a stock is undervalued. See Figure 6.

Figure 5: Example of a growth stock [12] where its earnings are consistently increasing. For a growth stock, if the threshold size is non-optimal, we may buy and sell too early (and do not make trading frequently enough) which results in less profit.
Figure 6: Example of non-recurring earnings or non-recurring profit. Since our fundamental price calculation is naive and does not take into account the fact that these earnings are temporary, it estimates a too-high fundamental price due to this extra earnings.

On the other hand, The results of our method equipped with medium-term trading strategy show impressive superiority, 55 wins versus 25 loses to the benchmark. The key factor of success is its tracking ability of the medium-term noisy effect by our filtering algorithm presented in Section 3. When the new base line is predicted accurately, undervalued and overvalued prices are also accurately detected and so the probability of our profitable trading is increasing. Nevertheless, with more frequent trading, commission fees increase substantially and sometimes can significantly reduce our performance as shown in Figure 4.

4.2.2 portfolio level experiments

In this subsection, to more realistically simulate a real-world individual investor, we construct a portfolio of stocks and test its performance against the benchmark. Here, we use a rule-of-thumb commonly employed in practice saying that a good portfolio should consists of around 15 stocks [38, 39] (which contradicts to the mainstream theory [40]). For individual value investors who believe they can beat the market by analyzing each firm carefully, usually, they do not feel comfortable to hold too many stocks (like stocks recommended by academic financial literatures) because investors need time to update and analyze the information of all their holding stocks.

To test the performance of a 15-stock portfolio of our method against the benchmark, we employ the method of boostrap resampling [41]. For each boostrap sample, a set of 15 stocks are selected randomly from Tables 3 and 4 to form an equally-weighted portfolio. We are interested in the difference in performance between our method and the benchmark on each boostrap sample. After all bootsrap samples are drawn, we can also estimate the average difference in performance between the two methods. More precisely, let be a random variable representing difference in % profit between our model and the benchmark (our % profit minus the benchmark’s % profit). By repeating the boostrap resampling 10,000 times, we are able to construct an empirical distribution of . This empirical distribution allows us to calculate , the average % profit difference between the two methods, and , the probability that our method has superior or equal performance to the benchmark. In addition to a portfolio consisting of stocks from the two markets, we also test portfolio performance from SET or US alone. Since the number of stocks considered in this work shown in Tables 3 and 4 is 10, a 7-stock portfolio is constructed for these cases instead of a 15-stock portfolio. The results are shown in Table 5.

Portfolio Long-term Thresholds Medium-term Thresholds
5% 10% 15% 20% 3% 5% 7% 10%
1.70% 1.07% 3.12% 0.45% 3.73% 3.52% 7.46% 3.70%
86.76% 66.72% 84.99% 57.45% 71.16% 69.53% 81.44% 74.28%
7.30% 11.88% 3.35% 1.03% 14.04% 11.75% 6.22% 2.62%
72.25% 97.06% 72.51% 72.29% 99.82% 99.78% 88.48% 70.35%
4.62% 6.42% 3.19% 0.77% 8.89% 7.55% 6.87% 3.18%
80.64% 97.47% 92.78% 66.04% 97.94% 96.30% 92.74% 80.58%
Table 5: Experimental results in portfolio level testing. denotes a random variable representing difference in % profit between our model and the benchmark. The distribution of is estimated using the method of Boostrap Resampling. Bold face denotes a case where there is more than 80% confidence that our method is more superior or equal to the benchmark.

From Table 5, our method beats the benchmark on every case on average (since for all cases). However, on a single-country portfolio, about half of the cases have the confidence levels of superiority less than 80%. Most of them have satisfactory confidence levels greater than 70% though. On the other hand, on a two-country 15-stock portfolio, although is roughly an average of the two single-country portfolios, is significantly increasing so that most cases have the confidence levels of superiority greater than , half of them is greater than . This statistically confirms the superiority of our method over the benchmark on selected stocks. This phenomenon of confidence-level increasing is due to the diversification effect on portfolio with a higher number of stocks. Finally, we note that the empirical distribution of is usually skewed and long-tail as illustrated in Figure 7. In this non-simple probability distribution case, boostrap empirical-distibution estimation employed in the present paper usually provides more accurate result than traditional analytical asymptotic estimations [41].

Figure 7: A histogram illustrated common empirical distributions of with right-skewed and long-tail. In this specfic illustration, our method is equipped with the long-term trading strategy with 10% threshold.

5 Conclusion and Future Directions

In this paper, we propose to apply the advanced Dynamic Bayesian Network (DBN) methodology to model stock price dynamics with two latent variables, namely, the fundamental PE and the medium-term noisy effect, respectively. This model is most suitable for one majority category of practitioners, namely, value investors in a security market (our model is not suitable for technical investors and mainstream academic investors). We have derived both inference and parameter estimation algorithms. The resulted model can be used as a decision support system to investment experts, or used to construct a trading strategy directly as illustrated in Section 4. Experiments in both individual firm-level and portfolio level show statistically significant superiority of our method.

There are many possible future directions for the present work. The first direction is to more formally reformulate the stock price dynamics model to reflect other important economic and financial variables, e.g. interest rate, equity risk premium and return of equity. This modeling process is possible used by the so-called Gordon Growth Model [11] which links to the mentioned variables. Dynamic Gordon Growth Model [42] can be a further future work in this direction. It is also possible to make our DBN model more realistic by allowing time-varying short-term noisy effect, the so-called dynamic volatility [43] or allowing dynamic volume [44]. Another promising direction in Behavioral finance which can be taken into account in our model is the topic of heterogeneous agents [20]. To improve our inference procedure, approximate inference such as Variational Bayes [15], or stochastic inference such as Markov chain Monte Carlo [7] are very promising future directions.



  • [1] C. Yeh, C. Huang, and S. Lee. A multiple-kernel support vector regression approach for stock market price forecasting. Expert System and Applications, 38(3):2177–2186, 2011.
  • [2] C. Lu, T. Lee, and C. Chiu. Financial time series forecasting using independent component analysis and support vector regression. Decision Support Systems, 47(2):115–125, 2009.
  • [3] Q. Wen, Z. Yang, Y. Song, and P. Jia. Automatic stock decision support system based on box theory and svm algorithm. Expert Systems with Applications, 37(2):1015–1022, 2010.
  • [4] R. Hassan. A combination of hidden markov model and fuzzy model for stock market forecasting. Neurocomputing, 72(16):3439–3446, 2009.
  • [5] L. Kao, C. Chiu, and C. Lu. A hybrid approach by integrating wavelet-based feature extraction with mars and svr for stock index forecasting. Decision Support Systems, 54(3):1228–1244, 2013.
  • [6] A. Kazem, E. Shariff, and F. Hussain. Support vector regression with chaos-based firefly algorithm for stock market price forecasting. Applied Soft Computing, 13(2):947–958, 2013.
  • [7] C. M. Bishop. Pattern Recognition and Machine Learning. Springer Science Press, New York, 2006.
  • [8] J. Murphy. Technical analysis of the financial markets: A comprehensive guide to trading methods and applications. Penguin, 1999.
  • [9] B. Shannon. Technical Analysis using Multiple Time Frames. LifeVest Publishing, Inc., 2008.
  • [10] H. Mark. The Most Important Things: Uncommon Sense for the Thoughtful Investor, . Columbia University Press, 2011.
  • [11] A. Damodaran. Investment Valuation, . LifeVest Publishing, Inc., 2012.
  • [12] P. Lynch and J. Rothchild. One Up on Wall Street, Ed. Simon & Schuster, 2000.
  • [13] E. Henry, T. Robinson, J. Stowe, and J. Pinto. Equity Asset Valuation, ed. CFA Institute, 2010.
  • [14] S. A. Carvell, T. Sullivan, and R. Pari. Analysts Forecast and Price/Earning Ratios. School of Hotel Administration Collection, Cornell University, 1989.
  • [15] K. P. Murphy. Machine Learning: A Probabilistic Approach. MIT Press, 2012.
  • [16] A. Szyszka. Behavioral Finance and Capital Markets. Palgrave Mackmillan, New York, 2013.
  • [17] B. M. Barber and T. Odean. The behavior of individual investors. Available at SSRN 1872211, 2011.
  • [18] F. Black. Noise. The Journal of Finance, pages 529–543, 1986.
  • [19] J. B. De Long, A. Shleifer, L. H. Summers, and R. J. Waldmann. Noise trader risk in financial markets. J. Polit. Econ., 98:703–738, 1990.
  • [20] C. Hommes. Behavioral Rationality and Heterogenous Expectation in Complex Economic Systems. Cambridge University Press, 2013.
  • [21] W. De Bondt and R. H. Thaler. Does the stock market overreact? The Journal of Finance, pages 793–807, 1986.
  • [22] R. Bloomfield, R. Libby, and M. Nelson. Underreactions, overreactions and moderated confidence. Journal of Financial Markets, 3(2):113–137, 2000.
  • [23] J. Pound and R. Zeckhauser. Clearly heard on the street: The effect of takeover rumors on stock prices. The Journal of Business, 63(3):291–308, 1990.
  • [24] R. Tumarkin and R. F. Whitelaw. News or noise? internet postings and stock prices. Financial Analysts Journal, 57(3):41–51, 2001.
  • [25] M. Rashes. Massively confused investors making conspicuously ignorant choices. The Journal of Finance, 56(5):1911–1927, 2001.
  • [26] M. J. Cooper, O. Dimitrov, and P. R. Rau. A by any other name. The Journal of Finance, 56(6):2371–2388, 2001.
  • [27] P. M. Dechow, A. Hutton, and R. Sloan. The relation between analysts’ forecasts of long-term earnings growth and stock price performance following equity offering. Journal of Contemporary Accounting Research, 17(1):1–32, 2000.
  • [28] A. Cowen, B. Groysberg, and P. Healy. Which types of analysts firms are more optimistic? Journal of Accounting and Economics, 41(1–2):119–146, 2006.
  • [29] A. Shleifer and R. Vishny. The limits of arbitrage. Journal of Finance, 52(1):35–55, 1997.
  • [30] W. Haizhen. Bayesian Probabilistic Inference on Firm-Level Stock Price Dynamics. Suranaree University of Techonology, Ph.D. Dissertation (available upon request), 2017.
  • [31] N. M. Laird A. P. Dempster and D. B. Rublin. Maximum likelihood from incomplete data via the EM algorithm. Journal of the royal statistical society. Series B (methodological), pages 1–38, 1977.
  • [32] L. Vandenberghe S. Boyd, S. J. Kim and A. Hassibi. A tutorial on geometric programming. Optimization and engineering, 8(1):67–127, 2007.
  • [33] A. Gelman, J. B. Carlin, H. S. Stern, and D. B. Rubin. Bayesian Data Analysis. CRC Press, New York, 2003.
  • [34] E. Fama. Foundation of Finance. Basic Books, 1976.
  • [35] E. Fama. Efficient capital markets: II. The Journal of Finance, pages 1575–1634, 1991.
  • [36] B. Malkiel. A Random Walk Down Wall Street: The Time-tested Strategy for Successful Investing, . W.W. Norton and Company, 2016.
  • [37] M. Carhart. On persistence in mutual fund performance. The Journal of Finance, pages 57–82, 1997.
  • [38] Investopedia: What is the ideal number of stocks to have in a portfolio? Accessed: 2016-12-31.
  • [39] Efficient frontier: The 15-stock diversification myth. Accessed: 2016-12-31.
  • [40] M. Racine D. Domian, D. Louton. Diversification in portfolios of individual stocks: 100 stocks are not enough. The Financial Review, 42(4):557–570, 2007.
  • [41] J. L. Horowitz. Bootstrap methods in econometrics: theory and numerical performance. Econometric Society Monographs, 28:188–222, 1997.
  • [42] J. Y. Campbell and R. J. Shiller. The dividend-price ratio and expectations of future dividends and discount factors. Review of financial studies, 1(3):195–228, 1988.
  • [43] Y. Wu, J. Hernández-Lobato, and Z. Ghahramani. Dynamic covariance models for multivariate financial time series. ICML (3), pages 558–566, 2013.
  • [44] G. Llorente, R. Michaely, G. Saar, and J. Wang. Dynamic volume-return relation of individual stocks. Review of Financial studies, 15(4):1005–1047, 2002.
Comments 0
Request Comment
You are adding the first comment!
How to quickly get a good reply:
  • Give credit where it’s due by listing out the positive aspects of a paper before getting into which changes should be made.
  • Be specific in your critique, and provide supporting evidence with appropriate references to substantiate general statements.
  • Your comment should inspire ideas to flow and help the author improves the paper.

The better we are at sharing our knowledge with each other, the faster we move forward.
The feedback must be of minimum 40 characters and the title a minimum of 5 characters
Add comment
Loading ...
This is a comment super asjknd jkasnjk adsnkj
The feedback must be of minumum 40 characters
The feedback must be of minumum 40 characters

You are asking your first question!
How to quickly get a good answer:
  • Keep your question short and to the point
  • Check for grammar or spelling errors.
  • Phrase it like a question
Test description