Book Image

Advanced Quantitative Finance with C++

By : Alonso Peña, Ph.D.
Book Image

Advanced Quantitative Finance with C++

By: Alonso Peña, Ph.D.

Overview of this book

<p>This book will introduce you to the key mathematical models used to price financial derivatives, as well as the implementation of main numerical models used to solve them. In particular, equity, currency, interest rates, and credit derivatives are discussed. In the first part of the book, the main mathematical models used in the world of financial derivatives are discussed. Next, the numerical methods used to solve the mathematical models are presented. Finally, both the mathematical models and the numerical methods are used to solve some concrete problems in equity, forex, interest rate, and credit derivatives.</p> <p>The models used include the Black-Scholes and Garman-Kohlhagen models, the LIBOR market model, structural and intensity credit models. The numerical methods described are Monte Carlo simulation (for single and multiple assets), Binomial Trees, and Finite Difference Methods. You will find implementation of concrete problems including European Call, Equity Basket, Currency European Call, FX Barrier Option, Interest Rate Swap, Bankruptcy, and Credit Default Swap in C++.</p>
Table of Contents (17 chapters)
Advanced Quantitative Finance with C++
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface
Index

Advanced example – IRS with Cap (IR2)


In this second example, we consider the pricing of an IRS with a cap The details of the approach are shown in the following Bento Box template advanced example:

Bento Box template for advanced example (IR2)

Our target is to compute the net present value of the swap as we did earlier.

An IRS cap is just like a standard IRS but with one key difference—at each payment date, we compute the maximum between (a) the difference between the floating rate and the strike and (b) zero. With this difference, we compute the value of a caplet; the cap is simply the sum of the caplets contained in the IRS.

The algorithm is shown in box 4 of the Bento Box template. The implementation of the algorithm in C++ is shown in code snippets 19 and 20. Code snippet 19 is the main code block, while code snippet 20 is its associated source.

Code 19 – IR2_main.cpp (cap with Monte Carlo LMM)

The following is the code snippet for IR2_main.cpp file:

// IR2_main.cpp
// requires random.cpp...