Introduction"

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "fHMM-"
)

Welcome to {fHMM}, an R package for modeling financial time series data with hidden Markov models (HMMs). This introduction motivates the approach, gives an overview of the package functionality and the included vignettes, and places the approach in the existing literature.

Motivation

Earning money with stock trading is simple: one only needs to buy and sell stocks at the right moment. In general, stock traders seek to invest at the beginning of upward trends (hereon termed as bullish markets) and repel their stocks just in time before the prices fall again (hereon termed as bearish markets). As stock prices depend on a variety of environmental factors [@hum09; @coh13], chance certainly plays a fundamental role in hitting those exact moments. However, investigating market behavior can lead to a better understanding of how trends alternate and thereby increases the chance of making profitable investment decisions.

The {fHMM} package aims at contributing to those investigations by applying HMMs to detect bearish and bullish markets in financial time series. It also implemented the hierarchical model extension presented in @oel21, which improves the model's capability for distinguishing between short- and long-term trends and allows to interpret market dynamics at multiple time scales.

Package and vignettes overview

The functionality of the {fHMM} package can be classified into functions for data preparation, model estimation, and model evaluation. The following flowchart visualizes their dependencies:

A flowchart of the {fHMM} package: Functions are boxed and classes displayed as circles.{width=80%}

The tasks data preparation, model estimation, and model evaluation as well as their corresponding functions and classes are explained in detail in separate vignettes:

Placement in the literature

Over the last decades, various HMM-type models have emerged as popular tools for modeling financial time series that are subject to state-switching over time [@sch97; @dia09; @ang12; @dea17]. @ryd98, @bul06, and @nys15a, e.g., used HMMs to derive stylized facts of stock returns, while @has05 and @nys17 demonstrated that HMMs can prove useful for economic forecasting. More recently, @lih17 applied HMMs to the Standard and Poor's 500, where HMMs were used to identify different levels of market volatility, aiming at providing evidence for the conjecture that returns exhibit negative correlation with volatility. Another application to the S\&P 500 can be found in @ngu18, where HMMs were used to predict monthly closing prices to derive an optimal trading strategy, which was shown to outperform the conventional buy-and-hold strategy. Further applications, which involve HMM-type models for asset allocation and portfolio optimization, can be found in @ang02, @bul11, @nys15a and @nys18, to name but a few examples. All these applications demonstrate that HMMs constitute a versatile class of time series models that naturally accounts for the dynamics typically exhibited by financial time series.

References



Try the fHMM package in your browser

Any scripts or data that you put into this service are public.

fHMM documentation built on Oct. 12, 2023, 5:10 p.m.