Book Image

Haskell Financial Data Modeling and Predictive Analytics

By : Pavel Ryzhov
Book Image

Haskell Financial Data Modeling and Predictive Analytics

By: Pavel Ryzhov

Overview of this book

<p>Haskell is one of the three most influential functional programming languages available today along with Lisp and Standard ML. When used for financial analysis, you can achieve a much-improved level of prediction and clear problem descriptions.</p> <p>Haskell Financial Data Modeling and Predictive Analytics is a hands-on guide that employs a mix of theory and practice. Starting with the basics of Haskell, this book walks you through the mathematics involved and how this is implemented in Haskell.</p> <p>The book starts with an introduction to the Haskell platform and the Glasgow Haskell Compiler (GHC). You will then learn about the basics of high frequency financial data mathematics as well as how to implement these mathematical algorithms in Haskell.</p> <p>You will also learn about the most popular Haskell libraries and frameworks like Attoparsec, QuickCheck, and HMatrix. You will also become familiar with database access using Yesod’s Persistence library, allowing you to keep your data organized. The book then moves on to discuss the mathematics of counting processes and autoregressive conditional duration models, which are quite common modeling tools for high frequency tick data. At the end of the book, you will also learn about the volatility prediction technique.</p> <p>With Haskell Financial Data Modeling and Predictive Analytics, you will learn everything you need to know about financial data modeling and predictive analytics using functional programming in Haskell.</p>
Table of Contents (14 chapters)

Volatility estimator framework


So, let's define the estimation task in terms of type classes and datatypes. At first, in this chapter we are going to work with bars. They have open, low, high, and close prices. We should define timestamps and time intervals. A conversion to day duration is quite useful for further volatility annualizing, that is, casting to volatility in one year interval. This is found in BarTypes.hs.

Also we add the derivations of common instances Eq, Show, and Enum. Please note that we did not define duration _, because if function is not defined on some of BarType, the compiler running with the -Wall option will produce the warning. For example, if the line with Bar4Hours is commented, then the compiler will warn you:

$ ghc BarTypes.hs -Wall
[1 of 1] Compiling BarType          ( BarTypes.hs, BarTypes.o )

BarTypes.hs:16:1: Warning:
    Pattern match(es) are non-exhaustive
    In an equation for `duration': Patterns not matched: Bar4Hours

This allows us to be sure that all...