
Derivatives Analytics with Python
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
More details
Other editions
Additional editions


Person
Content
List of Tables xi
List of Figures xiii
Preface xvii
Chapter 1 A Quick Tour 1
1.1 Market-Based Valuation 1
1.2 Structure of the Book 2
1.3 Why Python? 3
1.4 Further Reading 4
Part One The Market
Chapter 2 What is Market-Based Valuation? 9
2.1 Options and their Value 9
2.2 Vanilla vs. Exotic Instruments 13
2.3 Risks Affecting Equity Derivatives 14
2.3.1 Market Risks 14
2.3.2 Other Risks 15
2.4 Hedging 16
2.5 Market-Based Valuation as a Process 17
Chapter 3 Market Stylized Facts 19
3.1 Introduction 19
3.2 Volatility, Correlation and Co. 19
3.3 Normal Returns as the Benchmark Case 21
3.4 Indices and Stocks 25
3.4.1 Stylized Facts 25
3.4.2 DAX Index Returns 26
3.5 Option Markets 30
3.5.1 Bid/Ask Spreads 31
3.5.2 Implied Volatility Surface 31
3.6 Short Rates 33
3.7 Conclusions 36
3.8 Python Scripts 37
3.8.1 GBM Analysis 37
3.8.2 DAX Analysis 40
3.8.3 BSM Implied Volatilities 41
3.8.4 EURO STOXX 50 Implied Volatilities 43
3.8.5 Euribor Analysis 45
Part Two Theoretical Valuation
Chapter 4 Risk-Neutral Valuation 49
4.1 Introduction 49
4.2 Discrete-Time Uncertainty 50
4.3 Discrete Market Model 54
4.3.1 Primitives 54
4.3.2 Basic Definitions 55
4.4 Central Results in Discrete Time 57
4.5 Continuous-Time Case 61
4.6 Conclusions 66
4.7 Proofs 66
4.7.1 Proof of Lemma 1 66
4.7.2 Proof of Proposition 1 67
4.7.3 Proof of Theorem 1 68
Chapter 5 Complete Market Models 71
5.1 Introduction 71
5.2 Black-Scholes-Merton Model 72
5.2.1 Market Model 72
5.2.2 The Fundamental PDE 72
5.2.3 European Options 74
5.3 Greeks in the BSM Model 76
5.4 Cox-Ross-Rubinstein Model 81
5.5 Conclustions 84
5.6 Proofs and Python Scripts 84
5.6.1 Itô's Lemma 84
5.6.2 Script for BSM Option Valuation 85
5.6.3 Script for BSM Call Greeks 88
5.6.4 Script for CRR Option Valuation 92
Chapter 6 Fourier-Based Option Pricing 95
6.1 Introduction 95
6.2 The Pricing Problem 96
6.3 Fourier Transforms 97
6.4 Fourier-Based Option Pricing 98
6.4.1 Lewis (2001) Approach 98
6.4.2 Carr-Madan (1999) Approach 101
6.5 Numerical Evaluation 103
6.5.1 Fourier Series 103
6.5.2 Fast Fourier Transform 105
6.6 Applications 107
6.6.1 Black-Scholes-Merton (1973) Model 107
6.6.2 Merton (1976) Model 108
6.6.3 Discrete Market Model 110
6.7 Conclusions 114
6.8 Python Scripts 114
6.8.1 BSM Call Valuation via Fourier Approach 114
6.8.2 Fourier Series 119
6.8.3 Roots of Unity 120
6.8.4 Convolution 121
6.8.5 Module with Parameters 122
6.8.6 Call Value by Convolution 123
6.8.7 Option Pricing by Convolution 123
6.8.8 Option Pricing by DFT 124
6.8.9 Speed Test of DFT 125
Chapter 7 Valuation of American Options by Simulation 127
7.1 Introduction 127
7.2 Financial Model 128
7.3 American Option Valuation 128
7.3.1 Problem Formulations 128
7.3.2 Valuation Algorithms 130
7.4 Numerical Results 132
7.4.1 American Put Option 132
7.4.2 American Short Condor Spread 135
7.5 Conclusions 136
7.6 Python Scripts 137
7.6.1 Binomial Valuation 137
7.6.2 Monte Carlo Valuation with LSM 139
7.6.3 Primal and Dual LSM Algorithms 140
Part Three Market-Based Valuation
Chapter 8 A First Example of Market-Based Valuation 147
8.1 Introduction 147
8.2 Market Model 147
8.3 Valuation 148
8.4 Calibration 149
8.5 Simulation 149
8.6 Conclusions 155
8.7 Python Scripts 155
8.7.1 Valuation by Numerical Integration 155
8.7.2 Valuation by FFT 157
8.7.3 Calibration to Three Maturities 160
8.7.4 Calibration to Short Maturity 163
8.7.5 Valuation by MCS 165
Chapter 9 General Model Framework 169
9.1 Introduction 169
9.2 The Framework 169
9.3 Features of the Framework 170
9.4 Zero-Coupon Bond Valuation 172
9.5 European Option Valuation 173
9.5.1 PDE Approach 173
9.5.2 Transform Methods 175
9.5.3 Monte Carlo Simulation 176
9.6 Conclusions 177
9.7 Proofs and Python Scripts 177
9.7.1 Itô's Lemma 177
9.7.2 Python Script for Bond Valuation 178
9.7.3 Python Script for European Call Valuation 180
Chapter 10 Monte Carlo Simulation 187
10.1 Introduction 187
10.2 Valuation of Zero-Coupon Bonds 188
10.3 Valuation of European Options 192
10.4 Valuation of American Options 196
10.4.1 Numerical Results 198
10.4.2 Higher Accuracy vs. Lower Speed 201
10.5 Conclusions 203
10.6 Python Scripts 204
10.6.1 General Zero-Coupon Bond Valuation 204
10.6.2 CIR85 Simulation and Valuation 205
10.6.3 Automated Valuation of European Options by Monte Carlo Simulation 209
10.6.4 Automated Valuation of American Put Options by Monte Carlo Simulation 215
Chapter 11 Model Calibration 223
11.1 Introduction 223
11.2 General Considerations 223
11.2.1 Why Calibration at All? 224
11.2.2 Which Role Do Different Model Components Play? 226
11.2.3 What Objective Function? 227
11.2.4 What Market Data? 228
11.2.5 What Optimization Algorithm? 229
11.3 Calibration of Short Rate Component 230
11.3.1 Theoretical Foundations 230
11.3.2 Calibration to Euribor Rates 231
11.4 Calibration of Equity Component 233
11.4.1 Valuation via Fourier Transform Method 235
11.4.2 Calibration to EURO STOXX 50 Option Quotes 236
11.4.3 Calibration of H93 Model 236
11.4.4 Calibration of Jump Component 237
11.4.5 Complete Calibration of BCC97 Model 239
11.4.6 Calibration to Implied Volatilities 240
11.5 Conclusions 243
11.6 Python Scripts for Cox-Ingersoll-Ross Model 243
11.6.1 Calibration of CIR85 243
11.6.2 Calibration of H93 Stochastic Volatility Model 248
11.6.3 Comparison of Implied Volatilities 251
11.6.4 Calibration of Jump-Diffusion Part of BCC97 252
11.6.5 Calibration of Complete Model of BCC97 256
11.6.6 Calibration of BCC97 Model to Implied Volatilities 258
Chapter 12 Simulation and Valuation in the General Model Framework 263
12.1 Introduction 263
12.2 Simulation of BCC97 Model 263
12.3 Valuation of Equity Options 266
12.3.1 European Options 266
12.3.2 American Options 268
12.4 Conclusions 268
12.5 Python Scripts 269
12.5.1 Simulating the BCC97 Model 269
12.5.2 Valuation of European Call Options by MCS 274
12.5.3 Valuation of American Call Options by MCS 275
Chapter 13 Dynamic Hedging 279
13.1 Introduction 279
13.2 Hedging Study for BSM Model 280
13.3 Hedging Study for BCC97 Model 285
13.4 Conclusions 289
13.5 Python Scripts 289
13.5.1 LSM Delta Hedging in BSM (Single Path) 289
13.5.2 LSM Delta Hedging in BSM (Multiple Paths) 293
13.5.3 LSM Algorithm for American Put in BCC97 295
13.5.4 LSM Delta Hedging in BCC97 (Single Path) 300
Chapter 14 Executive Summary 303
Appendix A Python in a Nutshell 305
A.1 Python Fundamentals 305
A.1.1 Installing Python Packages 305
A.1.2 First Steps with Python 306
A.1.3 Array Operations 310
A.1.4 Random Numbers 313
A.1.5 Plotting 314
A.2 European Option Pricing 316
A.2.1 Black-Scholes-Merton Approach 316
A.2.2 Cox-Ross-Rubinstein Approach 318
A.2.3 Monte Carlo Approach 323
A.3 Selected Financial Topics 325
A.3.1 Approximation 325
A.3.2 Optimization 328
A.3.3 Numerical Integration 329
A.4 Advanced Python Topics 330
A.4.1 Classes and Objects 330
A.4.2 Basic Input-Output Operations 332
A.4.3 Interacting with Spreadsheets 334
A.5 Rapid Financial Engineering 336
Bibliography 341
Index 347
CHAPTER 1
A Quick Tour
1.1 Market-Based Valuation
This book is about the market-based valuation of (stock) index options. In the domain of derivatives analytics this is an important task which every major investment bank and buy-side decision maker in the financial market is concerned with on a daily basis. While theoretical valuation approaches develop a model, parametrize it and then derive values for options, the market-based approach works the other way round. Prices from liquidly traded options are taken as given (i.e. they are inputs instead of outputs) and one tries to parametrize a market model in a way that replicates the observed option prices as well as possible. This activity is generally referred to as model calibration. Being equipped with a calibrated model, one then proceeds with the task at hand, be it valuation, trading, investing, hedging or risk management. A bit more specifically, one might be interested in pricing and hedging an exotic derivative instrument with such a model-hoping that the results are in line with the overall market (i.e. arbitrage-free and even "fair") due to the previous calibration to more simple, vanilla instruments.
To accomplish a market-based valuation, four areas have to be covered:
- market: knowledge about market realities is a conditio sine qua non for any sincere attempt to develop market-consistent models and to accomplish market-based valuation
- theory: every valuation must be grounded on a sound market model, ensuring, for example, the absence of arbitrage opportunities and providing means to derive option values from observed quantities
- numerics: one cannot hope to work with analytical results only; numerical techniques, like Monte Carlo simulation, are generally required in different steps of a market-based valuation process
- technology: to implement numerical techniques efficiently, one is dependent on appropriate technology (hard- and software)
This book covers all of these areas in an integrated manner. It uses equity index options as the prime example for derivative instruments throughout. This, among others, allows to abstract from dividend related issues.
1.2 Structure of the Book
The book is divided into three parts. The first part is concerned with market-based valuation as a process and empirical findings about market realities. The second part covers a number of topics for the theoretical valuation of options and derivatives. It also develops tools much needed during a market-based valuation. The third part finally covers the major aspects related to a market-based valuation and also hedging strategies in such a context.
Part I "The Market" comprises two chapters:
- Chapter 2: this chapter contains a discussion of topics related to market-based valuation, like risks affecting the value of equity index options
- Chapter 3: this chapter documents empirical and anecdotal facts about stocks, stock indices and in particular volatility (e.g. stochasticity, clustering, smiles) as well as about interest rates
Part II "Theoretical Valuation" comprises four chapters:
- Chapter 4: this chapter covers arbitrage pricing theory and risk-neutral valuation in discrete time (in some detail) and continuous time (on a higher level) according to the Harrison-Kreps-Pliska paradigm (cf. Harrison and Kreps (1979) and Harrison and Pliska (1981))
- Chapter 5: the topic of this chapter is the complete market models of Black-Scholes-Merton (BSM, cf. Black and Scholes (1973), Merton (1973)) and Cox-Ross-Rubinstein (CRR, cf. Cox et al. (1979)) that are generally considered benchmarks for option valuation
- Chapter 6: Fourier-based approaches allow us to derive semi-analytical valuation formulas for European options in market models more complex and realistic than the BSM/CRR models; this chapter introduces the two popular methods of Carr-Madan (cf. Carr and Madan (1999)) and Lewis (cf. Lewis (2001))
- Chapter 7: the valuation of American options is more involved than with European options; this chapter analyzes the respective problem and introduces algorithms for American option valution via binomial trees and Monte Carlo simulation; at the center stands the Least-Squares Monte Carlo algorithm of Longstaff-Schwartz (cf. Longstaff and Schwartz (2001))
Finally, Part III "Market-Based Valuation" has seven chapters:
- Chapter 8: before going into details, this chapter illustrates the whole process of a market-based valuation effort in the simple, but nevertheless still useful, setting of Merton's jump-diffusion model (cf. Merton (1976))
- Chapter 9: this chapter introduces the general market model used henceforth, which is from Bakshi-Cao-Chen (cf. Bakshi et al. (1997)) and which accounts for stochastic volatility, jumps and stochastic short rates
- Chapter 10: Monte Carlo simulation is generally the method of choice for the valuation of exotic/complex index options and derivatives; this chapter therefore discusses in some detail the discretization and simulation of the stochastic volatility model by Heston (cf. Heston (1993)) with constant as well as stochastic short rates according to Cox-Ingersoll-Ross (cf. Cox et al. (1985))
- Chapter 11: model calibration stays at the center of market-based valuation; the chapter considers several general aspects associated with this topic and then proceeds with the numerical calibration of the general market model to real market data
- Chapter 12: this chapter combines the results from the previous two to value European and American index options via Monte Carlo simulation in the calibrated general market model
- Chapter 13: this chapter analyzes dynamic delta hedging strategies for American options by Monte Carlo simulation in different settings, from a simple one to the calibrated market model
- Chapter 14: this brief chapter provides a concise summary of central aspects related to the market-based valuation of index options
In addition, the book has an Appendix with one chapter:
- Appendix A: the appendix introduces some of the most important Python concepts and libraries in a nutshell; the selection of topics is clearly influenced by the requirements of the rest of the book; those not familiar with Python or looking for details should consult the more comprehensive treatment of all relevant topics by the same author (cf. Hilpisch (2014))
1.3 Why Python?
Although Python has established itself in the financial industry as a powerful programming language with an elaborate ecosystem of tools and libraries, it is still not often used for financial, derivatives or risk analytics purposes. Languages like C++, C, C#, VBA or Java and toolboxes like Matlab or domain-specific languages like R often dominate this area. However, we see a number of good reasons to choose Python even for computationally demanding analytics tasks; the following are the most important ones we want to mention, in no particular order, (see also chapter 1 in Hilpisch (2014)):
- open source: Python and the majority of available libraries are completely open source; this allows an entry to this technology at no cost, something particularly important for students, academics or other individuals
- syntax: Python programming is easy to learn, the code is quite compact and in general highly readable; at universities it is increasingly used as an introduction to programming in general; when it comes to numerical or financial algorithm implementation, the syntax is pretty close to the mathematics in general (e.g. due to code vectorization approaches)
- multi-paradigm: Python is as good for procedural programming (which suffices for the purposes of this book) as well as at object-oriented programming (which is necessary in more complex/professional contexts); it also has some functional programming features to offer
- interpreted: Python is an interpreted language which makes rapid prototyping and development in general a bit more convenient, especially for beginners; tools like IPython Notebook and libraries like pandas for time series analysis allow for efficient and productive interactive analytics workflows
- libraries: nowadays, there is a wealth of powerful libraries available and the supply grows steadily; there is hardly a problem that cannot be easily tackled with an existing library, be it a numerical problem, a graphical one or a data-related problem
- speed: a common prejudice with regard to interpreted languages-compared to compiled ones like C++ or C-is the slow speed of code execution; however, financial applications are more or less all about matrix and array manipulations and operations which can be done at the speed of C code with the essential Python library NumPy for array-based computing; other performance libraries, like Numba for dynamic code compiling, can also be used to improve performance
- market: in the London area (mainly financial services) the number of Python developer contract offerings was 485 in the third quarter of 2012;...
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.