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)

The secant root-finding algorithm


All of the previous methods require a root finding function. We're going to implement a secant method for MLE purposes. This method is quite universal in the sense that it doesn't require anything more than a function. Other methods might require existence and analytic form of the first derivative or might put some restrictions on the function class. As most of the root finding methods, the secant method is a recurrent method, that is, the one which should repeat a step until some convergence criteria is met.

This recurrence relation defines the secant method:

As you can see the method requires two initial values and that should ideally lie close to the root. The implementation of this root finding method is pretty straightforward as in Secant.hs.

Here we define a data structure, Secant that might be either a converged version (ConvergedSecant) or an in-progress structure (Secant). At first, we define two utility methods, isZero and invDerivative. The isZero...