18
International Journal of Contemporary Mathematical Sciences Vol. 11, 2016, no. 9, 437 - 454 HIKARI Ltd, www.m-hikari.com https://doi.org/10.12988/ijcms.2016.6953 New Frame for Financial Risk Management by Using Hidden Markov Models Mona N. Abdel Bary Faculty of Commerce, Department of Statistics and Insurance Suez Canal University, Al Esmalia, Egypt Copyright c 2016 Mona N. Abdel Bary. This article is distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduc- tion in any medium, provided the original work is properly cited. Abstract Traditional time series analysis methods such as Autoregressive Mov- ing Average Models or known as ARMA Family Models are limited by the requirement of stationary of the time series and normality and in- dependence of the residuals. Moreover, traditional time series analysis methods are unable to identify complex (no periodic, nonlinear, irreg- ular, and chaotic) characteristics because they attempt to characterize and predict all-time series observations. There are three major difficul- ties about accurate forecast of financial time series; (1) The patterns of financial time series are dynamic, i.e. there are no single fixed models that work all the time; (2) An efficient system must be able to adjust its sensitivity as time goes by; (3) Misleading information must be iden- tified and eliminated. Thus, a Hidden Markov Model (HMM) aims to solve these problems. In HMM, instead of combining each state with an output (transition matrix), each state is associated with a proba- bilistic function. At time t, an observation is generated by probabilistic function, which is associated with state j , with the probability. Unlike the Markov chain, the HMM has different strategies depending on ex- pertise. The model picks the best overall sequence of strategies based on an observation sequence. The main objective of this study is to im- prove the portfolio management process by incorporating technique to rotating the stocks of optimal portfolio by using HMM. Keywords: Financial Time Series, Markov Model, Hidden Marov Model, Risk Management, Egyptian Stock Market

New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

International Journal of Contemporary Mathematical SciencesVol. 11, 2016, no. 9, 437 - 454

HIKARI Ltd, www.m-hikari.comhttps://doi.org/10.12988/ijcms.2016.6953

New Frame for Financial Risk Management

by Using Hidden Markov Models

Mona N. Abdel Bary

Faculty of Commerce, Department of Statistics and InsuranceSuez Canal University, Al Esmalia, Egypt

Copyright c© 2016 Mona N. Abdel Bary. This article is distributed under the Creative

Commons Attribution License, which permits unrestricted use, distribution, and reproduc-

tion in any medium, provided the original work is properly cited.

Abstract

Traditional time series analysis methods such as Autoregressive Mov-ing Average Models or known as ARMA Family Models are limited bythe requirement of stationary of the time series and normality and in-dependence of the residuals. Moreover, traditional time series analysismethods are unable to identify complex (no periodic, nonlinear, irreg-ular, and chaotic) characteristics because they attempt to characterizeand predict all-time series observations. There are three major difficul-ties about accurate forecast of financial time series; (1) The patterns offinancial time series are dynamic, i.e. there are no single fixed modelsthat work all the time; (2) An efficient system must be able to adjustits sensitivity as time goes by; (3) Misleading information must be iden-tified and eliminated. Thus, a Hidden Markov Model (HMM) aims tosolve these problems. In HMM, instead of combining each state withan output (transition matrix), each state is associated with a proba-bilistic function. At time t, an observation is generated by probabilisticfunction, which is associated with state j, with the probability. Unlikethe Markov chain, the HMM has different strategies depending on ex-pertise. The model picks the best overall sequence of strategies basedon an observation sequence. The main objective of this study is to im-prove the portfolio management process by incorporating technique torotating the stocks of optimal portfolio by using HMM.

Keywords: Financial Time Series, Markov Model, Hidden Marov Model, RiskManagement, Egyptian Stock Market

Page 2: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

438 Mona N. Abdel Bary

1 Introduction

Time series forecasting, which analyzes and predicts a variable changing overtime, has received much attention to its use for forecasting stock prices. Timeseries analysis is also useful for pattern recognition and data mining. Stockmarkets in the recent past have become an integral part of the global economy.Any fluctuation in the market influences our personal and corporate financiallives and also the economic health of the country. The stock market has alwaysbeen one of the most popular investments due to its high returns. However,there is always some risk associated with the investment in the stock marketdue to its unpredictable behavior.

There are three major difficulties about accurate forecast of financial timeseries. First, the patterns of financial time series are dynamic, i.e. there areno single fixed models that work all the time. Second, an efficient system mustbe able to adjust its sensitivity as time goes by. Third, misleading informationmust be identified and eliminated. Thus, HMM aims to solve these problems.HMM is an extension of the Markov Model (MM). The basic HMM was pub-lished by Baum and his colleagues in late 1960s and early 1970s (see; (4), (5))and has been implemented in speech recognition (see; (23), (15)).

In HMM, instead of combining each state with an output (transition ma-trix), each state is associated with a probabilistic function. At time t, anobservation ot is generated by probabilistic function, which is associated withstate j, with the probability bj(ot) = P (ot/Xt = j). Unlike the Markov chain,the HMM has different strategies depending on expertise. The model picks thebest overall sequence of strategies based on an observation sequence. In HMM,the transition probabilities as well as the observation generation probabilitydensity function are both adjustable.

The function bj(ot) is a continuous probability density function or a mixtureof pdfs. The most generally used form of the continuous pdf is the Gaussianmixture, which they can model series that does not fall into the single Gaussiandistribution. The parameters of HMM are updated each iteration with an add-drop Expectation-Maximization (EM) algorithm (38). Furthermore HMM,which is a doubly embedded stochastic process with an underlying stochasticprocess that is not observable (hidden), but can be only observed throughanother set of stochastic processes that produce the sequence of observations.

The paper is arranged as follows: Section 2 gives a brief literature review,Section 3 sheds light on assumptions of the study, objective of the study is givein Section 4. contribution of the study introduced in Section 5, the Proposalframe described in Section 6. A summary and concluding remarks are give inSection 7.

Page 3: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

New frame for financial risk management 439

2 Literature Review

A large amount of research has been and continues to be published in recentyears with the purpose of finding an optimal prediction model for the financialtime series, (20). Most of the forecasting research has employed the statisticaltime series analysis techniques, such as Auto-Regression Integrated MovingAverage (ARIMA) (see; (17), and (21)) as well as the multiple regressionmodels.

In recent years, numerous stock prediction systems based on artificial in-telligence techniques have been proposed including Artificial Neural Networks(ANN) (see; (33), (16)), and (21)), fuzzy logic (26), hybridization of ANN andfuzzy system (see; (28), and (1)), support vector machines (6). The studies ofspeech recognition by using HMM still continues (2). Many recent works ineconomics are based on Hamilton’s time series model with changes in regimewhich is essentially a class of HMM (see; (10), (11), (12), and (13)). The fluc-tuating economic numbers such as stock index is very much influenced by thebusiness cycle which can be seen as the hidden states with seasonal changes(36). Additionally, they are used in many other applications such as model-ing general audio (9), protein sequences and genetic sequence alignment andanalysis (18), studying vegetation dynamics (see; (29), and (30)), study ofthe climate (see; (36) and (34)), psychological data and bio-informatics (see;(14), and (7)). Study (38) uses HMM for predicting the financial time series.Study (37) compares the applicability of Hidden Markov Model (HMM) withGARCH(1,1) model. The results of this study indicates that HMM outper-forms GARCH(1,1), (3) introduces a study about modeling portfolio defaultsusing HMM with covariances, volatility estimation, price prediction, additionalto forecasting the change directions of financial time series (see; (25), (35), (37),and (27)).

3 Assumptions of the Study

There are two assumptions for the structure of HMM:

1. Markov Assumption: Markov assumption means that the probabilityof generating the next state depends only on the current state,

P (xt+1|xt, xt−1, . . . , x0) = P (xt+1|xt), ∀t. (1)

2. Independence Assumption: The independence assumption indicatesthat the probability distribution of generating the current observationsymbol depends only on the current state,

P (Yt+1|Xt, λ) =T∏t=1

P (Yt|Xt, λ). (2)

Page 4: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

440 Mona N. Abdel Bary

4 Objective of the Study

Financial time series data is a sequence of prices of some financial assets overa specific period of time. Financial time series consists of multi-dimensionaland complex nonlinear data that give rise to difficulties in accurate prediction.Traditional studies use various forms of statistical models to predict volatilefinancial time series. Sometimes stocks move without any news, as the DawJones Industrial Index did on Monday, October 19, 1987. It fell by 22.6%without any obvious reason. We have to identify whether an irrational pricemovement is noise or it is part of a pattern. So that, there is a need to amodern models for studying the financial time series. There are three majordifficulties about accurate forecast of financial time series.

1. The patterns of financial time series are dynamic, i.e., there is no singlemodel that works all the time.

2. An efficient system must be able to adjust its sensitivity as time goes by.

3. Misleading information must be identified and eliminated.

The main objective of this study is to improve the risk management processby incorporating technique to rotating the stocks and rotating the optimalportfolios by using HMM. So the study aims to answer the following questions:

• What is the expected performance of the investors about each stock?

• What is the expected stock movements?

• What is the expected adequate time for buying or keeping and selling ?

5 Contribution of the Study

In this paper we address the following problem:

1. Offering trading rules: There is an obvious lack of trading rules forrisk management to determine the adequate time for buying and sellingthe stock. We introduce such trading rules in this study.

2. Introducing Hidden Markov Model: The study offers a new framethat takes into account the problems associated with the traditional for-mulation of financial time series.

3. Application on Egyptian Stock Market: The study applied theintroduction frame on Egyptian Stock Market.

Page 5: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

New frame for financial risk management 441

6 The Proposal Frame

The study introduces the frame for risk management to determine the adequatetime for buying and selling the stock. So we aim to answer the following threequestions:

• What is the expected performance of the investors about each stock?

• What is the expected stock movements?

• What is the expected adequate time for buying or keeping and selling ?

The proposed frame in Section 6 for learning from time series data con-sists of detecting patterns within the data, describing the detected patterns,clustering the patterns, and creating a model to describe the data. It uses achange-point detection method to partition a time series into segments, eachof the segments is then described by Hidden Markov Model (HMM). Then,it partitions all the segments into clusters, each of the clusters is consideredas a state for the HMM. It then creates the transitions between states in theMarkov model based on the transitions between segments as the time seriesprogresses. The proposed frame for using the learned model for forecasting con-sists of identifying current state, forecasting trends, and adapting to changes.It uses a moving window to monitor real time data and creates an HiddenMarkov model for the recently observed data, which is then matched to astate of the learned Hidden Markov model.

The study suggests the following steps for constructing a frame for tradingthe stocks by HMM as shown in Figure 1.

Figure 1: Study’s Trading Model.

Page 6: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

442 Mona N. Abdel Bary

1. Determine the states; we introduce two states; the first state is buyingstate, the second state is selling state, {Buy, Sell}; N = 2.

2. Determine the number of distinct observation symbols in each state;the return time series includes five movements symbols {large increase,small increase, no change, small decrease, large decrease}; M = 5.

3. Transform the observation sequence Y = {y1, y2, . . . , yT} into the statesequence S = {s1, s2, . . . , sT}.

4. Calculate the initial parameters λ = (A,B, π) of HMM:

• The initial state distribution; πi = Probability of being at state iat time t− 1.

• Transition matrix:

aij =expected number of transitions from state i to j

expected number of transitions from state i(3)

• Emission Matrix.

bi(m) =expected no. of times in state i and observing symbol m

expected no. of times in state i.(4)

5. Find the new optimal state sequence S based on the initial parametersλ = (A,B, π) through solving the three basic HMM problems:

• Find the probability of an observation. Given an observation se-quence Y = {y1, y2, . . . , yT} and HMM parameters λ = (A,B, π) byusing forward-backward algorithm (see; (22), and (23)).

• Find the best state sequence. Given an observation sequence Y ={y1, y2, . . . , yT} and HMM parameters λ = (A,B, π) by using theViterbi algorithm (see; (8), and (23)).

• Parameters re-estimations, Given an observation sequence. Thisproblem can be solved by the Baum Welch algorithm as mentionedin (32).

Section 6.1 proposes a way for risk management of the stocks. Section 6.3proposes applying the proposed trading rule to the Egyptian Stock Market.

Page 7: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

New frame for financial risk management 443

6.1 Trading Rule by Financial HMM

The hidden Markov model (HMM) is a class of probabilistic models which isable to capture the dynamic properties of ordered observations. An HMM re-lates the observations sequence Y = {y1, y2, . . . , yT} to a hidden state sequenceS = {s1, s2, . . . , sN}. The sequence of hidden states is assumed to be a Markovprocess. The initial distribution π gives the (prior) probability of a sequencestarting in each of the hidden states. The transitions from state to state arethen determined by a transition matrix A, with aij = p(st+1 = j|st = i). Theparameter set {π, A, B} defining an HMM is collectively denoted by λ.

Figure 2: Pictorial Representation of the HMM.Source: (20)

Figure 2 indicates that the nodes are Markov states, corresponding to valuesof the hidden variable st. The vertices are state transitions, labeled withtheir probabilities from the transition matrix A. The dashed lines are outputs,defined by the probability distribution B.

A trained HMM represents a distribution of sequences within a determinateoutput space. It allows every possible sequence of observations in that space tobe assigned a likelihood, which is just the posterior probability of the sequencebeing randomly generated by the model (in practice, the likelihood of mostarbitrary sequences may be extraordinarily close to zero). This is equal to thesum of the joint probabilities with all possible state sequences:

P (Y |λ) =∑S

p(Y |S, λ)p(S|λ). (5)

Since the number of sequences grows exponentially with T, and the numberof steps required to process each sequence grows linearly, computing this sum

Page 8: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

444 Mona N. Abdel Bary

directly requires 2TNT operations. Fortunately, by summing the state prob-abilities of all paths at each time step, it is possible to find the posterior inN2T (23).

HMM allows for timing investment decision prediction about the stocks.We have two investment decisions; each of them gives a distinctive predictionabout the return stock movements on a certain time. Each of the two decisionsis a hidden state in the HMM. The return stock movements set has all themovement symbols and each symbol is associated with one state. Each decisionhas a different probability distribution for all the return stock movements.Each state (decision) is connected to all the other states with a transitionprobability matrix. The function at each state is called a discrete probabilitydensity function. We model the direction of the return movements as follows:Large Increase, Small Increase, No Change, Small Decrease, Large Decrease.But if the stocks don’t have movements that include these degree; we canreduce the number of symbols into three symbols only: Increase, No Change,Decrease. The number of the symbols depends on the natural of the stockmovements. The process of risk management of the investment is the majorinvestor problem. The proposed trading rule is used to determine the adequatetime for buying and selling the stock.

6.2 Data Set

We use the general index of Egyptian Stock Market (GI) data set, which iscomposed mainly of 45 stocks highest transaction volume. The return of themonthly closing values are used as the monthly return value of each stock. Thedata from January 2004 to April 2008 are freely available on www.efsa.gov.eg.

6.3 Applications to the Egyptian Stock Market

We illustrate the suggested steps with all details for constructing financialHMM for trading rule using stock1 as example by using (19).

• Number of the states N = 2, we have two states; the first state isbuying state and the second state is selling state; S = {buying, selling}.

St ={

1 if Yt > 0, t = 1, . . . , T,2 otherwise. (6)

Yt =Pt − Pt−1

Pt−1

(7)

where Yt is the stock return at time t, Pt is the stock price at time t, andPt−1 is the stock price at time t− 1.

Page 9: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

New frame for financial risk management 445

• Transform the observation sequence Y = {y1, y2, . . . , yT} into the statesequence S = {s1, s2, . . . , sT} as in Table 1.

• The return time series includes five movements or symbols (M = 5).The movements of the return stock as follows: (1) Large Increase (LI),(2) Small Increase (SI), (3) No Change (NC), (4)Small Decrease (SD),(5) Large Decrease (LD).

Mt =

1 if Yt > 0.5,2 if 0.01 < Yt < 0.5,3 if 0.00 < Yt < 0.01,4 if − 0.05 < Yt < 0.00,5 if Yt < −0.05.

(8)

• Calculate the initial parameters:

– The starting state probabilities: {π1, π2, . . . , πN}.πi is the probability of being at state i at time t−1. The probabilityof being at state 1 (i.e. buy) at the first time = 1.

– The Initial state transition probabilities matrix is calculated as fol-lows :

aij =Number of transitions from state i to j

Number of transitions from state i. (9)

a11 =39

62= 0.63, a12 =

23

62= 0.37,

a21 =22

37= 0.60, a22 =

15

37= 0.40.

The Initial state transition probabilities matrix A is present in Table2, with aij.

– The Initial emission matrix is calculated as follows :

bi(m) =No. of times in state i and observing symbol m

No. of times in state i. (10)

Page 10: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

446 Mona N. Abdel Bary

Table 1: State Sequence and Emission Sequence; The Stock Prices ApplicationData (Jan 2000–April 2008).

t Yt St Mt t Yt St Mt t Yt St Mt01 –0.049 2 4 34 0.131 1 1 67 –0.016 2 402 –0.019 2 4 35 –0.075 2 5 68 0.243 1 103 –0.084 2 5 36 0.413 1 1 69 0.141 1 104 –0.084 2 5 37 –0.124 2 5 70 –0.012 2 405 –0.157 2 5 38 0.132 1 1 71 0.084 1 106 –0.168 2 5 39 0.028 1 2 72 0.079 1 107 0.159 1 1 40 0.091 1 1 73 –0.176 2 508 0.304 1 1 41 –0.012 2 4 74 –0.138 2 509 –0.078 2 5 42 0.085 1 1 75 0.008 1 310 –0.053 2 5 43 0.088 1 1 76 –0.167 2 511 –0.169 2 5 44 0.024 1 2 77 –0.108 2 512 –0.004 2 4 45 –0.020 2 4 78 0.180 1 113 –0.118 2 5 46 0.075 1 1 79 0.049 1 214 –0.088 2 5 47 –0.116 2 5 80 0.061 1 115 0.064 1 1 48 0.011 1 2 81 0.069 1 116 –0.004 2 4 49 –0.053 2 5 82 0.055 1 117 0.007 1 3 50 0.001 1 3 83 0.113 1 118 –0.055 2 5 51 0.189 1 1 84 –0.097 2 519 0.019 1 2 52 –0.045 2 4 85 0.116 1 120 –0.167 2 5 53 –0.015 2 4 86 0.019 1 221 0.062 1 1 54 0.060 1 1 87 0.156 1 122 –0.028 2 4 55 –0.004 2 4 88 –0.006 2 423 –0.101 2 5 56 0.099 1 1 89 0.016 1 224 –0.135 2 5 57 0.008 1 3 90 –0.006 2 425 0.040 1 2 58 0.048 1 2 91 0.056 1 126 –0.004 2 4 59 –0.073 2 5 92 –0.013 2 427 0.124 1 1 60 0.055 1 1 93 0.040 1 228 0.153 1 1 61 0.071 1 1 94 0.007 1 329 –0.019 2 4 62 –0.035 2 4 95 –0.091 2 530 0.054 1 1 63 –0.029 2 4 96 0.029 1 231 0.002 1 3 64 –0.171 2 5 97 0.083 1 132 –0.011 2 4 65 0.046 1 2 98 0.224 1 133 0.059 1 1 66 0.053 1 1 99 –0.012 2 4

Table 2: Initial Transition Matrix of Stock1.

Current State Buy SellBuy 0.63 0.37Sell 0.60 0.40

b1(1) =35

53= 0.66, b2(1) =

0

46= 0.00,

b1(2) =12

53= 0.23, b2(2) =

0

46= 0.00,

b1(3) =6

53= 0.11, b2(3) =

0

46= 0.00,

b1(4) =0

53= 0.00, b2(4) =

21

46= 0.46,

b1(5) =0

53= 0.00, b2(5) =

25

46= 0.54.

Page 11: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

New frame for financial risk management 447

Table 3 shows the initial emission matrix B, with bi(m).

Table 3: Initial Emission Matrix of Stock1.

The Stock MovementsStates LI SI NC SD LDBuy 0.66 0.23 0.11 0 0Sell 0 0 0 0.46 0.54

• Parameters re-estimations can be solved by the Baum Welch algo-rithm.

– Transition matrix: Table 4 shows that Stock1 will continue inbuying state for %63 of the next month and there are transitionfrom selling state to buying state for %63 of the time.

Table 4: Re-Estimation Transition Matrix of Stock1.

Current Next StateState Buy SellBuy 0.63 0.37Sell 0.63 0.37

– Emission matrix: Table 5 shows that buying state leads to in-creasing the rate of the return for %87 (%49 + %38) of the buyingtime and %13 of the buying time is in a non change of the rate ofthe return. Selling state leads to decrease in the rate of the return%38 of the selling state time.

Table 5: Re-Estimation Emission Matrix of Stock1.

The Stock MovementsStates LI SI NC SD LDBuy 0.49 0.38 0.13 0 0Sell 0 0 0 0.61 0.39

• The decision: Referring to the transition matrix in Table 4 and emissionmatrix in Table 5, the decision is to keep Stock 1 in the portfolio if it is inthe portfolio. This stock is a good investment for short time investments.Similar calculation can be performed for all high return stocks that aresimilar to Stock1. The transition and emission matrices all other stockscan be obtained in a similar way as for stock1. These are shown in Tables6 and 7, respectively.

Page 12: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

448 Mona N. Abdel Bary

Table 6: Emission Matrix for Stocks Movements.

Buy SellStock LI SI NC SD LD

1 0.4921 0.3810 0.1270 0.6126 0.38742 0.5175 0.3427 0.1399 0.6115 0.38853 0.5356 0.3038 0.1507 0.5372 0.46284 0.5736 0.3299 0.0964 0.3495 0.65055 0.4969 0.2099 0.2932 0.6377 0.36236 0.5350 0.1683 0.2967 0.6110 0.38907 0.5965 0.3026 0.1009 0.6420 0.35808 0.4813 0.3688 0.1500 0.5214 0.47869 0.6536 0.2288 0.1176 0.4490 0.551010 0.6905 0.3054 0.0041 0.4845 0.515511 0.6306 0.2675 0.1019 0.3497 0.650312 0.5031 0.2303 0.2665 0.5482 0.451813 0.5131 0.2364 0.2505 0.4425 0.557514 0.3673 0.5000 0.1327 0.5962 0.403815 0.6423 0.2555 0.1022 0.3681 0.631916 0.5183 0.3841 0.0976 0.4632 0.536817 0.4096 0.4202 0.1702 0.6250 0.375018 0.6319 0.2945 0.0736 0.4672 0.532819 0.8000 0.1143 0.0857 0.1625 0.837520 0.6111 0.1894 0.1995 0.7207 0.279321 0.8397 0.1263 0.0340 0.5003 0.499722 0.6178 0.2461 0.1361 0.6156 0.384423 0.6178 0.2461 0.1361 0.3303 0.669724 0.5886 0.3797 0.0318 0.4507 0.549325 0.3333 0.5497 0.1170 0.7054 0.294626 0.7353 0.1882 0.0765 0.4231 0.576927 0.6747 0.2470 0.0783 0.5896 0.410428 0.6746 0.2899 0.0355 0.3969 0.603129 0.6170 0.3219 0.0611 0.5295 0.470530 0.6685 0.2155 0.1160 0.4454 0.554631 0.8013 0.1854 0.0132 0.1678 0.832232 0.7647 0.1895 0.0458 0.4830 0.517033 0.6318 0.1848 0.1834 0.5311 0.468934 0.7170 0.2075 0.0755 0.3901 0.609935 0.4494 0.3596 0.1910 0.5000 0.500036 0.3801 0.4297 0.1102 0.5824 0.417637 0.2920 0.2824 0.4256 0.2204 0.779638 0.6188 0.3125 0.0688 0.4429 0.557139 0.6211 0.3168 0.0621 0.4604 0.539640 0.4699 0.3976 0.1325 0.3955 0.604541 0.4768 0.4570 0.0662 0.4027 0.597342 0.7108 0.1928 0.0964 0.3881 0.611943 0.8074 0.0667 0.1259 0.2970 0.703044 0.5793 0.3034 0.1172 0.5355 0.464545 0.4432 0.3523 0.2045 0.6532 0.3468

The decision: Referring to the transition matrix in Table 4 and emissionmatrix in Table 5, the decision is to keep Stock1 in the portfolio if it is in theportfolio. This stock is a good investment for short time investments. Similarcalculation can be performed for all high return stocks that are similar toStock1. The transition matrices and the emission matrices for all other stocksare obtained in Table 6 and Table7.

Page 13: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

New frame for financial risk management 449

Table 7: Transition Matrix for Stocks.

Next State Next State Next StateStock Buy Sell Stock Buy Sell Stock Buy Sell

1 0.6296 0.3704 16 0.5333 0.4667 31 0.5359 0.46410.6306 0.3694 0.5630 0.4370 0.4694 0.5306

2 0.5517 0.4483 17 0.6368 0.3632 32 0.5294 0.47060.4065 0.5935 0.6091 0.3909 0.4898 0.5102

3 0.2650 0.7350 18 0.5671 0.4329 33 0.5649 0.43510.4392 0.5608 0.5147 0.4853 0.5520 0.4480

4 0.6231 0.3769 19 0.5106 0.4894 34 0.5342 0.46580.7228 0.2772 0.4277 0.5723 0.5252 0.4748

5 0.4969 0.5031 20 0.6078 0.3922 35 0.6180 0.38200.5912 0.4088 0.4486 0.5514 0.5574 0.4426

6 0.5104 0.4896 21 0.5133 0.4867 36 0.6620 0.33800.6101 0.3899 0.3137 0.6863 0.5157 0.4843

7 0.5135 0.4865 22 0.5907 0.4093 37 0.7339 0.26610.3030 0.6970 0.7196 0.2804 0.6091 0.3909

8 0.5528 0.4472 23 0.5717 0.4283 38 0.6149 0.38510.5108 0.4892 0.7296 0.2704 0.4388 0.5612

9 0.5556 0.4444 24 0.5031 0.4969 39 0.5149 0.48510.4626 0.5374 0.5532 0.4468 0.5388 0.4612

10 0.4722 0.5278 25 0.6821 0.3179 40 0.5689 0.43110.5326 0.4674 0.4173 0.5827 0.5338 0.4662

11 0.5796 0.4204 26 0.5118 0.4882 41 0.5526 0.44740.4615 0.5385 0.6385 0.3615 0.4527 0.5473

12 0.5722 0.4278 27 0.5357 0.4643 42 0.5964 0.40360.5223 0.4777 0.5758 0.4242 0.5000 0.5000

13 0.6000 0.4000 28 0.5118 0.4882 43 0.3971 0.60290.5473 0.4527 0.6308 0.3692 0.4939 0.5061

14 0.7259 0.2741 29 0.4698 0.5302 44 0.4490 0.55100.5146 0.4854 0.5239 0.4761 0.5163 0.4837

15 0.5580 0.4420 30 0.6593 0.3407 45 0.6250 0.37500.3704 0.6296 0.5169 0.4831 0.5323 0.4677

7 Conclusion and Remark

The study introduces trading rule for determining the timing of exchange ofstocks. This trading rule reflects the effective of using HMM instead of MM.Figure 3 shows that instead of combining each state with deterministic outputas in Markov Model (MM), each state of HMM is associated with probabilityfunction. Moreover, each state is connected to all the other states with thetransition probability distribution.

The proposal trading model don’t only determine the adequate decision foreach stock but also allowed to determine the rate of return of timing of eachdecision. So, we can determining the best time for this decision, see Table 8.

The proposal trading rule for timing of exchange of the stocks includes theseadvantages:

• Portfolio investors; trading rule can be used for rotating the portfolioor risk management.

Page 14: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

450 Mona N. Abdel Bary

Figure 3: From left to right: (1) Each State with Deterministic Output as inMM, (2) Each State of HMM is Associated with Probability Function.

Table 8: Proposal Trading Rule.

Probability TradingState Buy SellBuy XSell X

Probability TimingReturn Buy Sell

LI XSI XNC XSD XLD X

• Individual stocks investors; determining the best stocks for both ofconservative and aggressive investors.

• Transaction for short time; determining the best time for buying andselling the stocks.

Page 15: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

New frame for financial risk management 451

References

[1] A. Abraham, B. Nath and P. K. Mahanti, Hybrid Intelligent Systems forStock Market Analysis, Chapter in Computational Science-ICCS 2001,Springer, 2001, 337–345. https://doi.org/10.1007/3-540-45718-6 38

[2] T. Asghar, R. T. Mohammad, A. Hassan and B. Hassan, Fuzzy HiddenMarkov Models for Speech Recognition on Based on FEM Algorithm,World Academy of Science, Engineering and Technology, 4 (2005), 59–61.

[3] K. Banachewicz, A. Lucas and A. Vaart, Stock Returns and Volatility,Econometrics Journal, 10 (2007), 1–18.

[4] L.E. Baum and J.A. Eagon, An inequality with applications to sta-tistical estimation for probabilistic functions of Markov processes andto a model for ecology, Bull. Amer. Math. Soc., 73 (1967), 360–363.https://doi.org/10.1090/s0002-9904-1967-11751-8

[5] L.E. Baum, T. Petrie, G. Soules and N. Weiss, A Maximization Tech-nique Occuring in the Statistical Analysis of Probabistic Functions ofMarkov Chains, Annals of Mathematical Statistics, 41 (1970), 164–171.https://doi.org/10.1214/aoms/1177697196

[6] L. Cao and F.E.H. Tay, Financial Forecasting Using Support Vec-tor Machines, Neural Computing and Application, 10 (2001), 184–192.https://doi.org/10.1007/s005210170010

[7] V. De Fonzo, F. Aluffi-Pentini, V. Parisi, Hidden Markov Models in Bioin-formatics, Current Bioninformatics, 2 (2007), no. 1, 49–61.https://doi.org/10.2174/157489307779314348

[8] D. Forney, The Viterbi Algorithm, Proc. IEEE, 61 (1973), no. 3, 268–278.https://doi.org/10.1109/proc.1973.9030

[9] M.J.R. Gomez and P.W. Daniel, Selection, Parameter Estimation and Dis-criminative Training of Hidden Markov Models for General Audio Mod-elling, 2003 International Conference on Multimedia and Expo. ICME ’03,(2003). https://doi.org/10.1109/icme.2003.1220857

[10] J.D. Hamilton, Rational Expectations Econoetrics Analysis of Changesin Regimes: An Investigation of the Term Structure of Interest Rates,Journal of Economic Dynamics and Control, 12 (1988), 385–423.https://doi.org/10.1016/0165-1889(88)90047-4

Page 16: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

452 Mona N. Abdel Bary

[11] J.D. Hamilton, A New Approach to the Economic Analysis of Nonsta-tionary Time Series and the Business Cycle, Econometrica, 57 (1989),357–384. https://doi.org/10.2307/1912559

[12] J.D. Hamilton, Analysis of Time Series Subject to Change in Regime,Journal of Econometrics, 45 (1990), 39–70.https://doi.org/10.1016/0304-4076(90)90093-9

[13] J.D. Hamilton and P.Q. Gabriel, What Do the Leading Indicators Lead?,The Journal of Business, 69 (1996), no. 1, 27–49.https://doi.org/10.1086/209678

[14] Ingmar Visser, Maartje E.J. Raijmakers, Peter C.M. Molenaar FittingHidden Markov Models to Psychological Data, Scientific Programming,10 (2002), 185–199. https://doi.org/10.1155/2002/874560

[15] B.H. Juang and L.R. Rabiner, Hidden Markov Models for Speech Recog-nition, Technometrics, 33 (1991), no. 3, 251–272.https://doi.org/10.1080/00401706.1991.10484833

[16] S.H. Kim and S.H. Chun, Graded forecasting using an array of bipo-lar predictions: application of probabilistic neural networks to a stockmarket index, International Journal of Forecasting, 14 (1998), 323–337.https://doi.org/10.1016/s0169-2070(98)00003-x

[17] T. Kimoto, K. Asaka, M. Yoda and M. Takeoka, Stock Market PredictionSystem with Modular Neural Networks, International Joint Conferenceon Neural Networks, San Diego, 1 (1990), 1–6.https://doi.org/10.1109/ijcnn.1990.137535

[18] R.J. Mackay, Estimating the order of a hidden Markov model, The Cana-dian Journal of Statistics, 30 (2002), no. 4, 573–589.https://doi.org/10.2307/3316097

[19] MATLAB (2007), c©1984-2007, Version 7.5, the Mathworks Inc.www.mathworks.com

[20] Md. Rafiul Hassan and N. Baikunth, Stock Market Forecasting UsingHidden Markov Model: A New Approach, Proceedings of the 5th Interna-tional Conference on Intelligent Systems Design and Applications, (2005).https://doi.org/10.1109/isda.2005.85

[21] N. A. Mona, Use of Time Series Models and neural networks in the pre-diction of Stocks’ prices in the Egyptian Stock Market, The 39th Annual

Page 17: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

New frame for financial risk management 453

Conference of Statistics, Computer Science and Operations Research, Sec-ond Part, Applied Statistics, Institute of Mathematical Statistics, CairoUniversity, (2004), 1–24.

[22] B. Phil, Hidden Markov Models, (2004).

[23] L.R. Rabiner, A Tutorial on Hidden Markov Models and Selected Appli-cations in Speech Recognition, Proceedings of the IEEE, 77 (1989), no. 2,257–286. https://doi.org/10.1109/5.18626

[24] L.H. Robert and E.K. Han, Capital Asset Pricing with Price LevelChanges, Journal of Financial and Qualitative Analysis, 11 (1976), 381–391. https://doi.org/10.2307/2330414

[25] J.E. Robert, C.H. William and M.J. Barbara, Drift and Volatility Esti-mation in Discrete Time, Journal of Economic Dynamics and Control, 22(1998), 209–218. https://doi.org/10.1016/s0165-1889(97)00052-3

[26] Y. Romahi and Q. Shen, Dynamic Financial Forecasting with Automat-ically Induced Fuzzy Associations, Proceedings of the 9th InternationalConference on Fuzzy Systems, (2000), 381–391.https://doi.org/10.1109/fuzzy.2000.838709

[27] Sang-Ho Park, Ju-Hong Lee, Jae-Won Song and Tae-Su Park, ForecastingChange Directions for Financial Time Series Using Hidden Markov Model,Chapter in Rough Sets and Knowledge Technology, Springer Berlin Hei-delberg, 2009, 184–191. https://doi.org/10.1007/978-3-642-02962-2 23

[28] A. Thammano, Neuro-fuzzy Model for Stock Market Prediction, Proceed-ings of the Artificial Neural Networks in Engineering Conference, ASMEPress, New York, (1999), 587–591.

[29] B.C. Tucker, Application of Hidden Markov Models in Ecology, M.Sc,Laurentian University, Sudbury, Ontario, Canada, 2003.

[30] B.C. Tucker and M. Anad, The Use of Matrix Models to Detect Naturaland Pollution-Induced Forest Gradients, Community Ecology, 4 (2003),89–100. https://doi.org/10.1556/comec.4.2003.1.13

[31] B.C. Tucker, Application of Hidden Markov Models in Terrestrial Ecology,Oral Paper, Laurentian University, Sudbury, Ontario, Canada, (2004).

[32] L.R. Welch, Hidden Markov Models and the Baum Welch Algorithm,IEEE Information Theory Society Newsletter, 53 (2003), no. 4, 1–24.

Page 18: New Frame for Financial Risk Management by Using Hidden ...€¦ · 12.09.2016  · risk management to determine the adequate time for buying and selling the stock. We introduce such

454 Mona N. Abdel Bary

[33] H. White, Economic Prediction Using Neural Networks: The Case of IBMDaily Stock Returns, IEEE International Conference on Neural Networks,(1988). https://doi.org/10.1109/icnn.1988.23959

[34] J. P. Whiting, Identification and Modeling of Hydrological Persistence withHidden Markov Models, Ph.D Thesis, University of Adelaide, Australia,2006.

[35] B. Wilfling, Volatility Regime-Switching in European Exchange RatesPrior to Monetary Unification, Journal of International Money and Fi-nance, 28 (2009), 240–270.https://doi.org/10.1016/j.jimonfin.2008.08.005

[36] T. Xuan, Autoregressive Hidden Markov Model with Application in an ElNino Study, Master Thesis, University of Saskatchewan Saskatoon, 2004.

[37] P. Yin, Volatility Estimation and Price Prediction using A HiddenMarkov Model with Empirical Study, Ph.D Thesis, University of MissouriColumbia, 2007.

[38] Y. Zhang, Prediction of Financial Time Series with Hidden Markov Mod-els, M.Sc, Simon Fraser University, China, 2004.

Received: September 29, 2016; Published: November 7, 2016