A book on QuantLib - have a look at code snippets

Which Quantitative Finance journal shows the most skin? Which book has the prettiest illustrations?
Post Reply
User avatar
finanzmaster
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

A book on QuantLib - have a look at code snippets

Post by finanzmaster »

Hello together,



I am writing a book on QuantLib.

The main goal is to provide the necessary basis, so that the readers can further learn QuantLib on their own.

How? First of all by means of a thorough explanation of some practically oriented code snippets, I publish them at

at QuantNet
www.yetanotherquant.de - Yet another, yet very reader-friendly, introduction to the measure theory
User avatar
finanzmaster
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

A book on QuantLib - have a look at code snippets

Post by finanzmaster »

An approximate book plan (deviations are possible and there are no fixed deadlines :))



0) How to build Boost + QuantLib (I have already wrote it here: https://nuclearphynance.com/Show%20Post.aspx?PostIDKey=152032)

DONE



1) (optional) brief review of OOP fundamentals

DONE



2) Boost-based components of QuantLib, in particular smart pointers. How to visualize them in VS-debugger.

Partially DONE



Design patterns (Dimitri Reiswich has already done an excellent job, but still...). UnitTests. Creating and reading Doxygen-Doku.

ToDo



3) Interest rate modeling from very beginning and very concretely (as Quant I am mostly experienced with fixed income):

Date arithmetic (daycounters, business day conventions, etc).

DONE



Bonds. Fitting yield curves: NSS, Cubic Spilnes, etc.

In Process



3a) Interest rate models (equilibrium vs. no arbitrage, short rate vs. Libor, calibrated models, affine models, term structure consistent models, etc)

4) Relation of financial instruments, pricing engines and models in QuantLib

5) Pricing [simple] instruments

6) [Discrete] Hedging revisited (specially for graduates: why it is important to hedge, not just to calculate the price as risk-neutral expectation of the discounted payoff).

7) (optional) some modern/advanced topics: CVA/DVA adjustment, multicurve framework, etc.

(optional) integrating QuantLib and CUDA/GPU for ad-hoc tasks.
www.yetanotherquant.de - Yet another, yet very reader-friendly, introduction to the measure theory
mmport80
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

A book on QuantLib - have a look at code snippets

Post by mmport80 »

Really interesting.



How about using the Python bindings?



Python's becoming more popular in the world of finance.



I wrote a few blog posts here,



http://johnorford.blogspot.sg/2014/04/quantlib-and-python-introduction.html



might give you a few ideas.
--- http://johnorford.blogspot.com
User avatar
silverside
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

A book on QuantLib - have a look at code snippets

Post by silverside »

thanks for sharing this



I didn't see the poll link for "how much would I be willing to pay"



but for sure an easy-to-read guide to setting up Quantlib and using it for basic and not-so-basic bond and swap math (pricing, bootstrapping, etc) would be very interesting to me.



I had a look at the teaser C++ code example; it seems vastly easier than I thought when I looked a year or two ago at the quantlib documentation, at that time I couldn't even get it to compile and was scared off by the use of boost.
Let's jet out, we'll cruise at hyperspeed, I've got the beat, I've got the beat and that's all we need
User avatar
yanko
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

A book on QuantLib - have a look at code snippets

Post by yanko »

Sorry to thread-jack, Vasily,



but I took a look at your "Knowledge rathern than hope"-book, and specifically at the excerpt from the first two chapters.



I could not help noticing the Kelly criterion example on pages 24, 25 is wrong. A stock yielding $2.70 or -$0.30 with equal probability will make a profit of 50*$2.40, if it goes up and down 50 times each. Now, if you meant 2.70% and -0.30%, you really shouldn't be calculating (2.7*0.3)^50=0.



Just mentioning,



yanko



edit: put in a minus infront of $0.30, 0.30% resp.
User avatar
finanzmaster
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

A book on QuantLib - have a look at code snippets

Post by finanzmaster »

@mmport80

>How about using the Python bindings?

>Python's becoming more popular in the world of finance.

Yes! And since Bruce Eckel praises Python it is definitely a good language. However, I never programmed it (so far), so cannot write about it.

In either case, one of the primary goals is to help readers to understand the QuantLib core, which is in C++. I do not mean to explain how to extend the library (Luigi can do it much better than me) but I do show the libraries guts and how to hack them (likely dirty, but quick and efficient - just like I brought the QuantLib::Date class to a legible view in VS-Debugger).



@silverside

The Poll is at the head of the topic on QN, probably you need to be a registered user in order to see it.

Yes, several years ago I was also scared by QuantLib documentation (or, better to say, lack of it). And my first attempts to build boost were also unsuccessful. But actually QuantLib uses very little of boost (shared_ptr, unittests). There are also some patterns like Observer/Observable, Handle, etc that are hard, but once understood, everything gets much easier. In my book I try to address these issues and I start from compiling the library.



@yanko

The stock yields from $1 invested either $1.70 or -$0.70, respectively you have either $1 + $1.7 = $2.7 or $1 - $0.7 = $0.3 at the end, both with probability 0.5.

In relative terms: either 170% profit of 70% loss and thus (1+1.7)(1-0.7)^n=(0.81)^n -> 0 as n gets large.

BTW, this is Samuelson's example, which I copied one-to-one (though made a little bit different conclusion than the Nobel Prize winner did:))
www.yetanotherquant.de - Yet another, yet very reader-friendly, introduction to the measure theory
User avatar
yanko
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

A book on QuantLib - have a look at code snippets

Post by yanko »

Fair enough, Vasily - it seems in my mind I "automatically" scaled returns down by a factor 100.



Thank you for the clarification!



yanko
User avatar
finanzmaster
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

A book on QuantLib - have a look at code snippets

Post by finanzmaster »

I have posted the next teaser on QuantNet.

1) Calibration of the HullWhite and LIBOR models

2) An overview of the IR Models in QL1.4.1 (quiz for junior quants: what T stands for? ;))
www.yetanotherquant.de - Yet another, yet very reader-friendly, introduction to the measure theory
User avatar
finanzmaster
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

A book on QuantLib - have a look at code snippets

Post by finanzmaster »

Hi there again,



unfortunately, there was not too much [ready-to-pay] interest in the book and secondly I have little time to write it. So I decided to put the notes on my webpage (http://www.yetanotherquant.com)



Source code is available too, except the debugger-friendly version of QuantLib::Date.

Those, who wanna get is as well, should spend me 10 USD ;)

(NP Gurus and QuantLib contributors can get it for free, of course)
www.yetanotherquant.de - Yet another, yet very reader-friendly, introduction to the measure theory
Post Reply