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)

Preface

Welcome to Haskell Financial Data Modeling and Predictive Analytics. You will start with the most distinctive features of the language, then go through the data collection process with parsing, cleansing and archiving, and then come directly to data analysis and manipulation. You will learn a set of basic financial models that are commonly used in the industry and how they can be implemented in Haskell. At the end of the book you will learn deterministic parallelism and compiler-driven stream fusion optimization.

What this book covers

Chapter 1, Getting Started with the Haskell Platform, discusses a little bit of Haskell history, how to get the Haskell platform installed, and walks through a quick tour of the main features of the language.

Chapter 2, Getting your Hands Dirty, covers the first step of any data analytics project; that is, getting an input data into an appropriate database. You will learn how to write parsers in combinator style, how to work with databases by means of Persistent ORM, and how to establish outlier detection procedures to cut off erroneous data.

Chapter 3, Measuring Tick Intervals, is the most mathematical chapter, as you will learn point processes that are models of orders arriving from exchanges. It also covers the property-based test framework, QuickCheck.

Chapter 4, Going Autoregressive, covers a classical autoregressive model of intertick duration, and finds out how to use Haskell stream fusion to achieve near-C performance of the calibration code.

Chapter 5, Volatility, covers one of the most successful volatility model of financial mathematics–Generalized Autoregressive Conditional Heteroskedasticity. Haskell's approach to parallel computations is explained, and a divide-and-conquer metaalgorithm is shown in practice.

Chapter 6, Advanced Cabal, explains the main approach to packaging, building, and maintaining dependencies of Haskell projects.

Appendix, References, contains references for the topics in the book, and explains them in greater details.

What you need for this book

In order to run most of the examples in this book you will need only Windows, Linux, or Mac OS X installed. All the needed software will be installed with the Haskell platform installer.

For Chapter 2, Getting your Hands Dirty, you will need an installation of one of the RDBMS: Sqlite, MySql, PostgreSQL, MongoDB, or CouchDB.

Who this book is for

Developers who are working in finance and would like to know how functional programming might be applied in the area will find this book of great use. Preliminary knowledge of Haskell is welcomed but is not required.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "The trace of the program is written into the .tix files."

A block of code is set as follows:

parProduct :: Num a => [a] -> a
parProduct [] = 1
parProduct [x] = x
parProduct xs = (right `using` rpar) * left
    where
        n = length xs `div` 2
        (leftL, rightL) = splitAt n xs
        left = product leftL
        right = product rightL

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

[default]
exten => s,1,Dial(Zap/1|30)
exten => s,2,Voicemail(u100)
exten => s,102,Voicemail(b100)
exten => i,1,Voicemail(s0)

Any command-line input or output is written as follows:

$ ./QuickTestsFull
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "clicking on the Next button moves you to the next screen".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.