I was recently given the opportunity to review the book F# for Quantitative Finance by Johan Astborg.

## Disclaimer:

I work in the finance industry, but I don’t do “Quant stuff” for a living. I’m not going to review the correctness of the book as I have to trust the author and the proof readers.

## Book structure

The book has 3 distinct sections – an Introduction to F#, required maths knowledge, and then application of the previous 2 in the context of Black-Scholes and Monte Carlo, following through into volatility, options and a full trading app.

It’s hard to fault the structure – if theres anything I’m not sure I agree with is the F# briefing – Quantitative finance doesn’t seem like a great “Hello World” app so I’d expect most readers to already be familiar with the language before starting this book. That being said, a target audience of people who already know the techniques described in this book may find it handy to have a short (it’s about 75 pages) run through of the language to help them get through the later chapters where they may be more familiar with the subject, but less so with F#.

The next sections go through some basic maths (Averages, Variance, Standard Deviations) in F# and then introduces Math.NET for some of the more complex maths. Personally I think this is a wise choice – Math.NET is incredibly powerful and integrates well with F# and allows the author to spend more time on (at this stage) explaining what the methods mean (and plotting them using FsChart). Once a brief detour of using charts to display data from Yahoo Finance is made (which really showcases the power of F#) its into the options pricing and Black-Scholes formula (by this point around the halfway mark in the book).

At this point you are really going to want to read this near a PC (if you’ve not already). The algorithms are best understood by using a tactile approach in my opinion – in other words typing out the code and playing with it. It’s incredibly satisfying to see charts based of an algorithm you have just typed (but may barely understand at this point) and provides an excellent way to try to further understand. A description of Monte-Carlo method and the theory is over.

Next up is where it gets hairy. Exploring volatility is a really dense chapter and will probably require several re-reads to understand if you’re not already familiar with the subject. Luckily the author has a clear writing style – but the subject matter is just tricky to digest in 1 go. It doesn’t take long to move past and then we get back into more of F# strengths in domain modelling.

A nice detour into using QuickFIX/N for setting up a trading system (I’ve heard people moan about FIX, but certainly it doesn’t seem *so* scary with this library) and it’s back into trading options and strategies for trading options. This chapter is quite long and contains detailed explanations of some of the options strategies (such as long/short straddle and long/short butterfly) along with charts to show the payoff. It’s a code heavy chapter, and once again I’d recommend having Visual Studio handy to play with the code.

Finally a trading screen is built up using the information from the previous 6 chapters, which really helps solidify some of the concepts previously described. It’s worth spending some time to at least have a basic understanding of whats come before as this chapter does reference a lot of the previous techniques without heavily retreading it. The book is then finished off with an appendix.

## Content

The F# code is neatly laid out and most samples weigh in at under 1 page. One thing I especially appreciate is type annotations in the book – without the benefit of intellisense this is a godsend for helping digest an already tricky topic.

The samples make nice use of FSChart for visualisation, which helps keep the noise ratio down when charting, although a couple of samples do seem to go the extra mile to show how to do a full WinForms app in place of just FSChart – I’m not sure if there’s a reasoning behind this.

The writing style does vary a little – the more intense chapters are a little terser in terms of explanation, but the code is usually sufficient to provide a starting point for self-discovery. In the “lighter” chapters, the writer covers the topics swiftly, but with plenty of detail.

The book weighs in at just under 300 pages, which means it’s not especially heavyweight, but it does cover a lot of ground. Personally, I’d ditch the F# tutorial at the beginning, but then I already know F#.

## Summary

F# for Quantitative Finance is a handy book to read if you’ve an interest in quantitative finance. It’s well written and utilises key strengths of F# to make the topic less scary (although by no means easy). I’m not hugely qualified to say how complete a book it is, but what it does cover is clearly written and understandable.

F# for Quantitative Finance is available here.

Pingback: F# Weekly #8, 2014 | Sergey Tihon's Blog