Leanpub Header

Skip to main content

Implementing QuantLib

Quantitative finance in C++: an inside look at the architecture of the QuantLib library.

Minimum price

Free!

$29.99

You pay

$29.99

Author earns

$23.99
$

...Or Buy With Credits!

You can get credits monthly with a Reader Membership

Buying multiple copies for your team? See below for a discount!

PDF
EPUB
WEB
1,687
Readers
326
Pages
About

About

About the Book

This book is a report on the design and implementation of QuantLib, alike in spirit—but, hopefully, with less frightening results—to the How I did it book prominently featured in Mel Brooks' Young Frankenstein (in this case, of course, it would be "how we did it"). If you are, or want to be, a QuantLib user, you will find here useful information on the design of the library that might not be readily apparent when reading the code. If you're working in quantitative finance, even if not using QuantLib, you can still read it as a field report on the design of a financial library. You will find that it covers issues that you might also face, as well as some possible solutions and their rationale. Based on your constraints, it is possible—even likely—that you will choose other solutions; but you might profit from this discussion just the same.

The book is primarily aimed at users wanting to extend the library with their own instruments or models; if you desire to do so, the description of the available class hierarchies and frameworks will provide you with information about the hooks you need to integrate your code with QuantLib and take advantage of its facilities. If you're not this kind of user, don't give up on the book yet; you can find useful information too. However, you might want to look at A QuantLib Guide and QuantLib Python Cookbook instead.

Implementing QuantLib is also available as a paperback from your local Amazon store.

Share this book

Team Discounts

Team Discounts

Get a team discount on this book!

  • Up to 25 members

    Minimum price
    $9.99
    Suggested price
    $49.99

Author

About the Author

Luigi Ballabio

The co-founder and current maintainer of the open-source QuantLib project. Also husband, father of four, ex-physicist, and amateur musician.

Subscribe to Luigi's newsletter at https://implementingquantlib.substack.com for more QuantLib-related content.

Translations

Translations

Contents

Table of Contents

1.Introduction

2.Financial instruments and pricing engines

  1. 2.1The Instrument class
  2. 2.1.1Interface and requirements
  3. 2.1.2Implementation
  4. Aside: const or not const?
  5. 2.1.3Example: interest-rate swap
  6. Aside: handles and shared pointers.
  7. 2.1.4Further developments
  8. 2.2Pricing engines
  9. Aside: impure virtual methods.
  10. 2.2.1Example: plain-vanilla option

3.Term structures

  1. 3.1The TermStructure class
  2. 3.1.1Interface and requirements
  3. 3.1.2Implementation
  4. Aside: evaluation date tricks.
  5. 3.2Interest-rate term structures
  6. 3.2.1Interface and implementation
  7. 3.2.2Discount, forward-rate, and zero-rate curves
  8. Aside: symmetry break.
  9. Aside: twin classes.
  10. 3.2.3Example: bootstrapping an interpolated curve
  11. Aside: a friend in need.
  12. 3.2.4Example: adding z-spread to an interest-rate curve
  13. 3.3Other term structures
  14. 3.3.1Default-probability term structures
  15. Aside: Cinderella method.
  16. 3.3.2Inflation term structures
  17. 3.3.3Volatility term structures
  18. 3.3.4Equity volatility structures
  19. Aside: interpolations and extrapolations.
  20. 3.3.5Interest-rate volatility structures

4.Cash flows and coupons

  1. 4.1The CashFlow class
  2. Aside: late payments.
  3. 4.2Interest-rate coupons
  4. 4.2.1Fixed-rate coupons
  5. 4.2.2Floating-rate coupons
  6. Aside: keeping one’s balance.
  7. 4.2.3Example: LIBOR coupons
  8. Aside: breach of contract.
  9. 4.2.4Example: capped/floored coupons
  10. 4.2.5Generating cash-flow sequences
  11. 4.2.6Other coupons and further developments
  12. 4.3Cash-flow analysis
  13. 4.3.1Example: fixed-rate bonds

5.Parameterized models and calibration

  1. 5.1The CalibrationHelper class
  2. 5.1.1Example: the Heston model
  3. Aside: breaking assumptions
  4. 5.2Parameters
  5. 5.3The CalibratedModel class
  6. 5.3.1Example: the Heston model, continued

6.The Monte Carlo framework

  1. 6.1Path generation
  2. 6.1.1Random-number generation
  3. Aside: the road more traveled.
  4. 6.1.2Stochastic processes
  5. 6.1.3Random path generators
  6. Aside: access patterns.
  7. Aside: stepping on one’s own toes.
  8. 6.2Pricing on a path
  9. 6.3Putting it all together
  10. 6.3.1Monte Carlo traits
  11. 6.3.2The Monte Carlo model
  12. 6.3.3Monte Carlo simulations
  13. Aside: synchronized walking.
  14. 6.3.4Example: basket option
  15. Aside: need-to-know basis.

7.The tree framework

  1. 7.1The Lattice and DiscretizedAsset classes
  2. 7.1.1Example: discretized bonds
  3. 7.1.2Example: discretized option
  4. 7.2Trees and tree-based lattices
  5. 7.2.1The Tree class template
  6. Aside: curiouser and curiouser.
  7. 7.2.2Binomial and trinomial trees
  8. 7.2.3The TreeLattice class template
  9. 7.3Tree-based engines
  10. 7.3.1Example: callable fixed-rate bonds

8.The finite-difference framework

  1. 8.1The old framework
  2. 8.1.1Differential operators
  3. 8.1.2Evolution schemes
  4. 8.1.3Boundary conditions
  5. 8.1.4Step conditions
  6. Aside: look, Ma, no hands.
  7. 8.1.5The FiniteDifferenceModel class
  8. 8.1.6Example: American option
  9. 8.1.7Time-dependent operators
  10. 8.2The new framework
  11. 8.2.1Meshers
  12. 8.2.2Operators
  13. 8.2.3Examples: Black-Scholes operators
  14. 8.2.4Initial, boundary, and step conditions
  15. Aside: dispelling magic.
  16. 8.2.5Schemes and solvers

9.Conclusion

A. Odds and ends

  1. Basic types
  2. Date calculations
  3. Dates and periods
  4. Calendars
  5. Day-count conventions
  6. Schedules
  7. Finance-related classes
  8. Market quotes
  9. Interest rates
  10. Indexes
  11. Aside: how much generalization?
  12. Exercises and payoffs
  13. Math-related classes
  14. Interpolations
  15. Aside: gordian knots
  16. One-dimensional solvers
  17. Optimizers
  18. Statistics
  19. Aside: extreme expectations.
  20. Linear algebra
  21. Global settings
  22. Aside: more mutations than in a B-movie.
  23. Utilities
  24. Smart pointers and handles
  25. Aside: pointer semantics.
  26. Error reporting
  27. Disposable objects
  28. Design patterns
  29. The Observer pattern
  30. The Singleton pattern
  31. The Visitor pattern

B. Code conventions

QuantLib license

Bibliography

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub