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)

Parsing files in applicative style


To describe the applicative style, first we need to understand functors, or instances of the Functor type class. Typically, they are the structures that can be mapped over. The Functor type class defined in Functor.hs.

Thus fmap defines how to map a function to another function defined on the instances of this type class. It is illustrated with the Maybe functor in MaybeFunctor.hs.

Here we defined that if Maybe has a value, then the function must be applied to that value, otherwise Nothing should be returned. Thus we can promote a function over primitive types to another function between the two Maybe values.

Applicative functor is a functor with additional property: you can apply function inside a functor to values that can be either outside or inside the functor. This is defined in Applicative.hs.

So this definition introduces a class constraint. It says that each instance of the Applicative type class must also be an instance of Functor. Thus it has the...