Wednesday, October 30, 2013

Quantology: Coupled Hidden Markov Models--USD/CHF and Gold, for example

From Futures Magazine:
The profitable, hidden and Markovian couple of Swiss and gold
Ask anyone on Wall Street, “What is the state of the market?” and chances are you’ll get one of three answers: Bull, bear or sideways. To the casual trader, these terms paint a rough picture of where the market is moving. But to a certain concept in mathematics, these terms precisely describe where prices are heading.

This concept is hidden Markov models (HMM). It was developed by Harvard Ph.D. mathematician Leonard E. Baum and his co-workers. The premise of the model is that the market is in one of five states — super bear, bear, sideways, bull or super bull — at any given time and transitions between states obey the Markov property. That is, transitions are dependent only on what the market’s state was one time interval before and not any earlier. How the market switches between the five states is indicated by transition probabilities that tell us the probabilities of one state transitioning to another.

The assumption that the market obeyed the Markov property occasionally was thought of as a good one because it removes the problem of lag. This occurs when a current calculation holds little value because it is based on price action much further in the past. The further back you go, the less of an effect price action should have on current trading decisions.

Just as how we know a bear and a bull market behave differently, each state is given a different probabilistic distribution of the observations it can output. Observations are any form of physical quantity we can measure from the market, namely price and indicators. Their uses are two-fold. One, if we know that the market is in a certain state, we can infer from that state’s distribution what the next observation could be. Two, a sequence of observations can be used to figure out the state of the market (see “State transitions,” below).
Over the last decade, HMMs have been creeping into the arsenals of some hedge funds. Because of their logically sound modeling process and subtle application of the Markov property, quants have found good use of HMMs in generating profitable trading signals.

However, HMMs showed their limitations when the time came to incorporate the next wave of trading techniques. Hedge funds experienced a gradual realization that more than one dimension of data was needed to outwit the market. Multi-time frame trading techniques in which two time frames were studied together were explored. Pairs trading in which prices of two assets were analyzed at the same time was the emphasis. Intermarket analysis in which the forecasting of an asset in one market considering the dynamics of another asset in another market was developed. The early form of HMMs weren’t conducive to integrating these new ideas and needed to be extended to allow for this possibility. Thus, the coupled hidden Markov model (CHMM) was born.

Unlike Baum’s original HMM, which is standard literature in applied mathematics, the CHMM is new research starting around the mid-2000s and doesn’t have a canonical formulation. While the CHMMs developed by researchers from different universities vary in their specifications, all of them share a common underlying theme: To take two HMMs and couple them by way of their transition probabilities.

Let’s start by giving our two HMMs names. HMM1 will model the currency market, and HMM2 will model the commodity market. Both of them make up our CHMM. Just as before, as time progresses, the state of each market will switch to another state with certain probabilities. Unlike before, this probability now depends on that market’s and the other market’s current states. Therein lies the coupling between both markets (see “Two HMMs coupled,” below).
With the two markets represented in our model, we also need two observations to track, namely the price or indicators of our currency and of our commodity. We feed both observation sequences into our CHMM to have it reconfigure itself to best represent each market.

The result is a model with the predictive power to forecast the next observation for both the currency and the commodity markets. Throughout coupling the two HMMs, we have not removed the Markov property when switching between states. The positives of HMMs are retained, the problem of lag kept buried and the possibility of incorporating another dimension of data made available. Quants were quick to explore pairs of assets to couple for the CHMM....MORE