Numerical Methods in Finance and Economics - Hörbücher · Numerical Methods in Finance and...

15
Numerical Methods in Finance and Economics A MATLAB-Based Introduction Second Edition Paolo Brandimarte Politecnico di Torino Torino, Italy @XEliciENCE A JOHN WILEY & SONS, INC., PUBLICATION

Transcript of Numerical Methods in Finance and Economics - Hörbücher · Numerical Methods in Finance and...

Page 1: Numerical Methods in Finance and Economics - Hörbücher · Numerical Methods in Finance and Economics ... Numerical methods in finance. 2002. ... 5.3 Solving the heat equation by

Numerical Methods in Finance and Economics

A MATLAB-Based Introduction

Second Edition

Paolo Brandimarte Politecnico di Torino

Torino, Italy

@XEl ic iENCE A JOHN WILEY & SONS, INC., PUBLICATION

Page 2: Numerical Methods in Finance and Economics - Hörbücher · Numerical Methods in Finance and Economics ... Numerical methods in finance. 2002. ... 5.3 Solving the heat equation by

This Page Intentionally Left Blank

Page 3: Numerical Methods in Finance and Economics - Hörbücher · Numerical Methods in Finance and Economics ... Numerical methods in finance. 2002. ... 5.3 Solving the heat equation by

Numerical Methods in Finance and Economics

Page 4: Numerical Methods in Finance and Economics - Hörbücher · Numerical Methods in Finance and Economics ... Numerical methods in finance. 2002. ... 5.3 Solving the heat equation by

STATISTICS IN PRACTICE

Advisory Editor

Peter Bloomfield North Carolina State University, USA

Founding Editor

Vic Barnett Nottingham Trent University, UK

Statistics in Practice is an important international series of texts which provide detailed cov- erage of statistical concepts, methods and worked case studies in specific fields of investiga- tion and study.

With sound motivation and many worked practical examples, the books show in down-to- earth terms how to select and use an appropriate range of statistical techniques in a particular practical field within each title’s special topic area.

The books provide statistical support for professionals and research workers across a range of employment fields and research environments. Subject areas covered include medi- cine and pharmaceutics; industry, finance and commerce; public services; the earth and envi- ronmental sciences, and so on.

The books also provide support to students studying statistical courses applied to the above areas. The demand for graduates to be equipped for the work environment has led to such courses becoming increasingly prevalent at universities and colleges.

It is our aim to present judiciously chosen and well-written workbooks to meet everyday practical needs. Feedback of views from readers will be most valuable to monitor the success of this aim.

A complete list of titles in this series appears at the end of the volume.

Page 5: Numerical Methods in Finance and Economics - Hörbücher · Numerical Methods in Finance and Economics ... Numerical methods in finance. 2002. ... 5.3 Solving the heat equation by

Numerical Methods in Finance and Economics

A MATLAB-Based Introduction

Second Edition

Paolo Brandimarte Politecnico di Torino

Torino, Italy

@XEl ic iENCE A JOHN WILEY & SONS, INC., PUBLICATION

Page 6: Numerical Methods in Finance and Economics - Hörbücher · Numerical Methods in Finance and Economics ... Numerical methods in finance. 2002. ... 5.3 Solving the heat equation by

Copyright 0 2006 by John Wiley & Sons, Inc. All rights reserved.

Published by John Wiley & Sons, Inc., Hoboken, New Jersey. Published simultaneously in Canada.

No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4470, or on the web at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 11 1 River Street, Hoboken, NJ 07030, (201) 748-601 1, fax (201) 748-6008, or online at http:l/www.wiley.com/go/permission.

Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.

For general information on our other products and services or for technical support, please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.

Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic format. For information about Wiley products, visit our web site at www.wiley.com.

Library of Congress Cataloging-in-Publication Data:

Brandimarte, Paolo.

Brandimarte.-2nd ed. Numerical methods in finance and economics : a MATLAB-based introduction / Paolo

p. cm. Rev. ed. of: Numerical methods in finance. 2002. Includes bibliographical references and index.

ISBN-10: 0-471-74503-0 (cloth) 1. Finance-Statistical methods. 2. Economics-Statistical methods. I. Brandimarte, Paolo.

HG176.5.B73 2006 332.0 1'5 1 d c 2 2 2006045787

ISBN-13: 978-0-47 1-74503-7 (Cloth)

Numerical methods in finance. 11. Title.

Printed in the United States of America.

10 9 8 7 6 5 4 3 2 1

Page 7: Numerical Methods in Finance and Economics - Hörbücher · Numerical Methods in Finance and Economics ... Numerical methods in finance. 2002. ... 5.3 Solving the heat equation by

This book is dedicated to Commander Straker, Lieutenant Ellis, and all S H A D 0 operatives. Thirty-five years ago they introduced m e t o the art of using both computers a n d gut feelings to make decisions.

Page 8: Numerical Methods in Finance and Economics - Hörbücher · Numerical Methods in Finance and Economics ... Numerical methods in finance. 2002. ... 5.3 Solving the heat equation by

This Page Intentionally Left Blank

Page 9: Numerical Methods in Finance and Economics - Hörbücher · Numerical Methods in Finance and Economics ... Numerical methods in finance. 2002. ... 5.3 Solving the heat equation by

Preface to the Second Edition

From the Preface to the First Edition

Part I Background

Contents

1 Motivation 1.1 Need for numerical methods 1.2 Need for numerical computing environments:

why MATLAB? 1.3 Need for theory

For further reading References

2 Financial Theory 2.1 Modeling uncertainty 2.2 Basic financial assets and related issues

2.2.1 Bonds 2.2.2 Stocks

xvii

xxiii

3 4

9 13 20 21

23 25 30 30 31

V i i

Page 10: Numerical Methods in Finance and Economics - Hörbücher · Numerical Methods in Finance and Economics ... Numerical methods in finance. 2002. ... 5.3 Solving the heat equation by

viii CONTENTS

2.2.3 Derivatives 2.2.4

Fixed-income securities: analysis and portfolio immunization 2.3.1

2.3.2 2.3.3

2.3.4

2.3.5 Critique

2.4.1 Utility theory 2.4.2 Mean-variance portfolio Optimization 2.4.3 M A T L A B functions to deal with mean-

variance portfolio optimization 2.4.4 Critical remarks 2.4.5 Alternative risk measures: Value at Risk

Modeling the dynamics of asset prices 2.5.1 2.5.2 Standard Wiener process 2.5.3 Stochastic integrals and stochastic

2.5.4 Ito’s lemma 2.5.5 Generalizations

2.6 Derivatives pricing 2.6.1 2.6.2 Black-Scholes model 2.6.3 Risk-neutral expectation and Feynman-

KaE formula 2.6.4 Black-Scholes model in M A T L A B 2.6.5 A f ew remarks o n Black-Scholes formula 2.6.6 Pricing American options Introduction to exotic and path-dependent options 2.7.1 Barrier options 2.7.2 Asian options 2.7.3 Lookback options

Asset pricing, portfolio optimization, and risk management

2.3

Basic theory of interest rates: compounding and present value Basic pricing of fixed-income securities Interest rate sensitivity and bond portfolio immunization M A T L A B functions to deal with fixed- income securities

2.4 Stock portfolio optimization

and quantile- based measures

From discrete t o continuous t ime 2.5

diflerential equations

Simple binomial model f o r option pricing

2.7

33

37

42

42 49

57

60 64 65 66 73

74 81

83 88 88 91

93 96

100 102 105 108

111 113 116 117 118 119 123 123

Page 11: Numerical Methods in Finance and Economics - Hörbücher · Numerical Methods in Finance and Economics ... Numerical methods in finance. 2002. ... 5.3 Solving the heat equation by

CONTENTS ix

2.8 An outlook on interest-rate derivatives 2.8.1 Modeling interest-rate dynamics 2.8.2

For further reading References

Incomplete markets and the market price of risk

Part 11 Numerical Methods

3 Basics of Numerical Analysis 3.1 Nature of numerical computation

3.1.1 Number representation, rounding, and

3.1.2 Error propagation, conditioning, and

3.1.3

Solving systems of linear equations 145 3.2.1 Vector and matrix norms 1463.2.2 3.2.3

3.2.4 Tridiagonal matrices 3.2.5

truncation

instability 141Order of convergence and computational complexity 143

3.2

Condition number for a matrix 149 Direct methods for solving systems of linear equations

Iterative methods for solving systems of linear equations

3.3.1 Ad hoc approximation 3.3.2 Elementary polynomial interpolation 3.3.3 Interpolation by cubic splines 3.3.4

3.3 Function approximation and interpolation

Theory of function approximation by least squares

3.4 Solving non-linear equations 3.4.1 Bisection method 3.4.2 Newton’s method 3.4.3 Optimization- based solution of non-linear

equations 3.4.4 Putting two things together: solving

a functional equation by a collocation method

124 126

127 130 131

137 138

138

154 159

160 173 177

183 1 79

188 191 192 195

198

204

Page 12: Numerical Methods in Finance and Economics - Hörbücher · Numerical Methods in Finance and Economics ... Numerical methods in finance. 2002. ... 5.3 Solving the heat equation by

x CONTENTS

3.4.5 Homotopy continuation methods 204 For further reading 206 References 207

4 Numerical Integration: Deterministic and Monte Carlo Methods 4.1 Deterministic quadrature

4.1.1 Classical interpolatory formulas 4.1.2 Gaussian quadrature 4.1.3 Extensions and product rules 4.1.4 Numerical integration in M A T L A B

4.2 Monte Carlo integration 4.3 Generating pseudorandom variates

4.3.1 Generating pseudorandom numbers 4.3.2 Inverse transform method 4.3.3 Acceptance-rejection method 4.3.4

Setting the number of replications

4.5.1 Antithetic sampling 4.5.2 Common random numbers 4.5.3 Control variates 4.5.4 Variance reduction b y conditioning 4.5.5 Stratified sampling 4.5.6 Importance sampling

4.6 Quasi-Monte Carlo simulation 4.6.1 Generating Halton low-discrepancy

sequences 4.6.2 Generating Sobol low-discrepancy

sequences For further reading References

Generating normal variates by the polar approach

4.4 4.5 Variance reduction techniques

5 Finite Diflerence Methods for Partial Digerential Equations 5.1 Introduction and classification of PDEs 5.2 Numerical solution by finite diflerence methods

5.2.1 Bad example of a finite diflerence scheme 295

209 21 1 21 2 214 21 9 220 221 225 226 230 233

235 24 0 244 244 251 252 255 260 261 267

269

281 286 287

289 290 293

Page 13: Numerical Methods in Finance and Economics - Hörbücher · Numerical Methods in Finance and Economics ... Numerical methods in finance. 2002. ... 5.3 Solving the heat equation by

CONTENTS xi

5.2.2 Explicit and implicit methods for the heat equation 5.3.1

5.3.2

5.3.3

5.4 Solving the bidimensional heat equation 5.5 Convergence, consistency, and stability

For further reading References

Instability in a finite diflerence scheme 5.3

Solving the heat equation by an explicit method Solving the heat equation by a fu l ly implicit method Solving the heat equation by the Crank- Nicolson method

297

303

304

309

31 3

320 314

324 324

6 Convex Optimization 327 6.1 Classification of optimization problems 328

6.1.1 Finite- us. infinite-dimensional problems 328 6.1.2 Unconstrained us. constrained problems 333 6.1.3 Convex us. non-convex problems 333 6.1.4 Linear us. non-linear problems 335 6.1.5 Continuous us. discrete problems 337 6.1.6 Deterministic us. stochastic problems 337

6.2.1 Steepest descent method 339 6.2.2 The subgradient method 34 0 6.2.3 Newton and the trust region methods 34 1

method and simplex search 342

6.3 Methods for constrained optimization 34 6 6.3.1 Penalty function approach 34 6

6.3.3 Duality theory 357

6.2 Numerical methods for unconstrained optimization 338

6.2.4 No-derivatives algorithms: quasi-Newton

6.2.5 Unconstrained optimization in MATLAB 343

6.3.2 Kuhn-Tucker conditions 351

6.3.4 Kelley 's cutting plane algorithm 363 6.3.5 Active set method 365

6.4 Linear programming 366 6.4.1 Geometric and algebraic features of linear

programming 368 6.4.2 Simplex method 370

Page 14: Numerical Methods in Finance and Economics - Hörbücher · Numerical Methods in Finance and Economics ... Numerical methods in finance. 2002. ... 5.3 Solving the heat equation by

xi; CONTENTS

6.4.3 Duality in linear programming 6.4.4 Interior point methods

6.5.1 Linear programming in MATLAB 6.5.2 A trivial L P model for bond portfolio

management 6.5.3 Using quadratic programming to trace

evgicient portfolio frontier 6.5.4 Non-linear programming in MATLAB

6.5 Constrained optimization in MATLAB

6.6 Integrating simulation and optimization S6.1 Elements of convex analysis

S6.1.1 Convexity in optimization S6.1.2 Convex polyhedra and polytopes For further reading References

Part 111 Pricing Equity Options

7 Option Pricing by Binomial and Thnomial Lattices 7.1 Pricing by binomial lattices

7.1.1 Calibrating a binomial lattice 7.1.2

7.1.3

Pricing American options by binomial lattices

Putting two things together: pricing a pay-later option An improved implementation of binomial lattices

7.2

372 375 377 378

380

383 385 387 389 389 393 396 397

4 01 4 02 4 03

410

411 414

7.3 Pricing bidimensional options by binomial lattices 41 7 7.4 Pricing by trinomial lattices 422 7.5 Summary 425

For further reading 426 References 426

8 Option Pricing by Monte Carlo Methods 429 8.1 Path generation 430

8.1.2 Simulating hedging strategies 435 8.1.3 Brownian bridge 439

8.2 Pricing an exchange option 443

8.1.1 Simulating geometric Brownian motion 431

Page 15: Numerical Methods in Finance and Economics - Hörbücher · Numerical Methods in Finance and Economics ... Numerical methods in finance. 2002. ... 5.3 Solving the heat equation by

CONTENTS xiii

8.3 Pricing a down-and-out put option 8.3.1 Crude Monte Carlo 8.3.2 Conditional Monte Carlo 8.3.3 Importance sampling Pricing an arithmetic average Asian option 8.4.1 Control variates 8.4.2 Using Halton sequences Estimating Greeks by Monte Carlo sampling For further reading References

8.4

8.5

9 Option Pricing by Finite Diflerence Methods 9.1

9.2

Applying finite diflerence methods to the Black- Scholes equation Pricing a vanilla European option by an explicit method 9.2.1 Financial interpretation of the instability

of the explicit method 481 Pricing a vanilla European option by a fully implicit method Pricing a barrier option by the Crank-Nicolson method

For further reading References

9.3

9.4

9.5 Dealing with American options

Part I V Advanced Optimization Models and Methods

10 Dynamic Programming 10-1 The shortest path problem 10.2 Sequential decision processes

10.2.1 The optimality principle and solving the functional equation

10.3 Solving stochastic decision problems by dynamic programming

10.4 American option pricing by Monte Carlo simulation 10.4.1 A M A T L A B implementation of the least

squares approach

44 6 44 6 44 7 450 4 54 4 55 458 468 4 72 4 73

4 75

4 75

4 78

482

485 486 4 91 4 91

4 95 496 500

501

504

51 1

51 7