Financial Instrument Pricing Using C++

Daniel J. Duffy

  • 出版商: Wiley
  • 出版日期: 2004-07-30
  • 售價: $5,040
  • 貴賓價: 9.5$4,788
  • 語言: 英文
  • 頁數: 432
  • 裝訂: Hardcover
  • ISBN: 0470855096
  • ISBN-13: 9780470855096
  • 相關分類: C++ 程式語言
  • 已過版

買這商品的人也買了...

相關主題

商品描述

Description:

One of the best languages for the development of financial engineering and instrument pricing applications is C++. It has several features that allow developers to write robust, flexible and extensible software systems. It is an ANSI/ISO standard, fully object-oriented and interfaces with many third-party applications. It has support for templates and generic programming, massive reusability using templates (‘write once’) and support for legacy C applications.

In this book we bring C++ to the next level by applying it to the design and implementation of classes, libraries and applications for option and derivative pricing models. We employ modern software engineering techniques to produce industrial-strength applications: -

  • Using the Standard Template Library (STL) in finance
  • Creating your own template classes and functions
  • Reusable data structures for vectors, matrices and tensors
  • Classes for numerical analysis (numerical linear algebra …)
  • Solving the Black Scholes equations, exact and approximate solutions
  • Implementing the Finite Difference Method in C++
  • Integration with the ‘Gang of Four’ Design Patterns
  • Interfacing with Excel (output and Add-Ins)
  • Financial engineering and XML
  • Cash flow and yield curves

Included with the book is a CD containing the source code in the Datasim Financial Toolkit that you can use directly. This will get you up to speed with your C++ applications by reusing existing classes and libraries.

'Unique... Let's all give a warm welcome to modern pricing tools.' Paul Wilmott, mathematician, author and fund manager

Table of Contents:

1 Executive Overview of this Book.

1.1 What is this book?

1.2 What’s special about this book?

1.3 Who is this book for?

1.4 Software requirements.

1.5 The structure of this book.

1.6 Pedagogical approach.

1.7 What this book is not.

1.8 Source code on the CD.

PART I TEMPLATE PROGRAMMING IN C++.

2 A Gentle Introduction to Templates in C++.

2.1 Introduction and objectives.

2.2 Motivation and background.

2.3 Defining a template.

2.3.1 An example.

2.4 Template instantiation.

2.5 Function templates.

2.5.1 An example.

2.6 Default values and typedefs.

2.7 Guidelines when implementing templates.

2.8 Conclusions and summary.

3 An Introduction to the Standard Template Library.

3.1 Introduction and objectives.

3.1.1 Why use STL?

3.2 A Bird’s-eye view of STL.

3.3 Sequence containers.

3.3.1 Programming lists.

3.3.2 Vectors and arrays in STL.

3.4 Associative containers.

3.4.1 Sets in STL.

3.4.2 Maps in STL.

3.5 Iterators in STL.

3.5.1 What kinds of iterators?

3.6 Algorithms.

3.7 Using STL for financial instruments.

3.8 Conclusions and summary.

4 STL for Financial Engineering Applications.

4.1 Introduction and objectives.

4.2 Clever data structures.

4.2.1 A simple output mechanism.

4.3 Set theory and STL.

4.4 Useful algorithms.

4.5 STL adaptor containers.

4.6 Conclusions and summary.

5 The Property Pattern in Financial Engineering.

5.1 Introduction and objectives.

5.2 The Property pattern.

5.2.1 Requirements for a Property pattern.

5.3 An example.

5.4 Extending the Property pattern: property sets and property lists.

5.4.1 An example.

5.5 Properties and exotic options.

5.5.1 Example: Executive options.

5.6 Conclusions and summary.

PART II BUILDING BLOCK CLASSES.

6 Arrays, Vectors and Matrices.

6.1 Introduction and objectives.

6.2 Motivation and background.

6.3 A layered approach.

6.4 The Array and Matrix classes in detail.

6.4.1 Simple print functions.

6.4.2 Array example.

6.4.3 Matrix example.

6.5 The Vector and NumericMatrix classes in detail.

6.5.1 Vector example.

6.5.2 NumericMatrix example.

6.6 Associative arrays and matrices.

6.7 Conclusions and summary.

7 Arrays and Matrix Properties.

7.1 Introduction and objectives.

7.2 An overview of the functionality.

7.3 Software requirements.

7.3.1 Accuracy.

7.3.2 Efficiency.

7.3.3 Reliability.

7.3.4 Understandability.

7.4 The core processes.

7.4.1 Interactions between matrices and vectors.

7.4.2 Some examples.

7.5 Other function categories.

7.5.1 Measures of central tendency.

7.5.2 Measures of dispersion.

7.5.3 Moments, skewness, kurtosis.

7.5.4 Inequalities.

7.6 Using the functions.

7.6.1 Calculating historical volatility.

7.6.2 Variance of return of a portfolio.

7.7 An introduction to exception handling.

7.7.1 Try, throw and catch: A bit like tennis.

7.8 Conclusions and summary.

8 Numerical Linear Algebra.

8.1 Introduction and objectives.

8.2 An introduction to numerical linear algebra.

8.2.1 Direct methods.

8.2.2 Iterative methods.

8.3 Tridiagonal systems.

8.3.1 LU decomposition.

8.3.2 Godunov’s Double Sweep method.

8.3.3 Designing and implementing tridiagonal schemes.

8.4 Block tridiagonal systems.

8.5 What requirements should our matrix satisfy?

8.5.1 Positive-definite matrices and diagonal dominance.

8.5.2 M-Matrices.

8.6 Conclusions and summary.

9 Modelling Functions in C++.

9.1 Introduction and objectives.

9.2 Function pointers in C++.

9.3 Function objects in STL.

9.3.1 Comparison functions.

9.3.2 STL and financial engineering.

9.4 Some function types.

9.4.1 Applications in numerical analysis and financial engineering.

9.4.2 An example: Functions in option pricing.

9.5 Creating your own function classes.

9.6 Arrays of functions.

9.7 Vector functions.

9.8 Real-valued functions.

9.9 Vector-valued functions.

9.10 Conclusions and summary.

10 C++ Classes for Statistical Distributions.

10.1 Introduction and objectives.

10.2 Discrete and continuous probability distribution functions.

10.3 Continuous distributions.

10.3.1 Uniform (rectangular) distribution.

10.3.2 Normal distribution.

10.3.3 Lognormal distribution.

10.3.4 Gamma distribution and its specializations.

10.4 Discrete distributions.

10.4.1 Poisson distribution

10.4.2 Binomial and Bernoulli distributions.

10.4.3 Pascal and geometric distributions.

10.5 Tests.

10.5.1 Continuous distributions.

10.5.2 Discrete distributions.

10.6 Conclusions and summary.

PART III ORDINARY AND STOCHASTIC DIFFERENTIAL EQUATIONS.

11 Numerical Solution of Initial Value Problems: Fundamentals.

11.1 Introduction and objectives.

11.2 A model problem.

11.2.1 Qualitative properties of the solution.

11.3 Discretisation.

11.4 Common schemes.

11.5 Some theoretical issues.

11.6 Fitting: Special schemes for difficult problems.

11.7 Non-linear scalar problems and predictor–corrector methods.

11.8 Extrapolation techniques.

11.9 C++ design and implementation.

11.10 Generalisations.

11.11 Conclusions and summary.

12 Stochastic Processes and Stochastic Differential Equations.

12.1 Introduction and objectives.

12.2 Random variables and random processes.

12.2.1 Random variables.

12.2.2 Generating random variables.

12.2.3 Random (stochastic) processes.

12.3 An introduction to stochastic differential equations.

12.4 Some finite difference schemes.

12.4.1 Improving the accuracy: Richardson extrapolation.

12.5 Which scheme to use?

12.6 Systems of SDEs.

12.7 Conclusions and summary.

13 Two-Point Boundary Value Problems.

13.1 Introduction and objectives.

13.2 Description of problem.

13.3 (Traditional) centred-difference schemes.

13.3.1 Does the discrete system have a solution?

13.3.2 Extrapolation.

13.4 Approximation of the boundary conditions.

13.4.1 Linearity boundary condition.

13.5 Exponentially fitted schemes and convection–diffusion.

13.6 Approximating the derivatives.

13.7 Design issues.

13.8 Conclusions and summary.

14 Matrix Iterative Methods.

14.1 Introduction and objectives.

14.2 Iterative methods.

14.3 The Jacobi method.

14.4 Gauss–Seidel method.

14.5 Successive overrelaxation (SOR).

14.6 Other methods.

14.6.1 The conjugate gradient method.

14.6.2 Block SOR.

14.6.3 Solving sparse systems of equations.

14.7 The linear complementarity problem.

14.8 Implementation.

14.9 Conclusions and summary.

PART IV PROGRAMMING THE BLACK–SCHOLES ENVIRONMENT.

15 An Overview of Computational Finance.

15.1 Introduction and objectives.

15.2 The development life cycle.

15.3 Partial differential equations.

15.4 Numerical approximation of PDEs.

15.5 The class of finite difference schemes.

15.6 Special schemes for special problems.

15.7 Implementation issues and the choice of programming language.

15.8 Origins and application areas.

15.9 Conclusions and summary.

16 Finite Difference Schemes for Black–Scholes.

16.1 Introduction and objectives.

16.2 Model problem: The one-dimensional heat equation.

16.3 The Black–Scholes equation.

16.4 Initial conditions and exotic options payoffs.

16.4.1 Payoff functions in options modelling.

16.5 Implementation.

16.6 Method of lines: A whirlwind introduction.

16.7 Conclusions and summary.

17 Implicit Finite Difference Schemes for Black–Scholes.

17.1 Introduction and objectives.

17.2 Fully implicit method.

17.3 An introduction to the Crank–Nicolson method.

17.4 A critique of Crank–Nicolson.

17.4.1 How are derivatives approximated?

17.4.2 Boundary conditions.

17.4.3 Initial conditions.

17.4.4 Proving stability.

17.5 Is there hope? the Keller scheme.

17.5.1 The advantages of the Box scheme.

17.6 Conclusions and summary.

18 Special Schemes for Plain and Exotic Options.

18.1 Introduction and objectives.

18.2 Motivating exponentially fitted schemes.

18.2.1 A new class of robust difference schemes.

18.3 Exponentially fitted schemes for parabolic problems.

18.3.1 The fitted scheme in more detail: Main results.

18.4 What happens when the volatility goes to zero?

18.4.1 Graceful degradation.

18.5 Exponential fitting with explicit time.

18.5.1 An explicit time-marching scheme.

18.6 Exponential fitting and exotic options.

18.7 Some final remarks.

19 My First Finite Difference Solver.

19.1 Introduction and objectives.

19.2 Modelling partial differential equations in C++.

19.2.1 Function classes in C++.

19.2.2 Function classes for partial differential equations.

19.3 Finite difference schemes as C++ classes, Part I.

19.4 Finite difference schemes as C++ classes, Part II.

19.5 Initialisation issues.

19.5.1 Functions and parameters.

19.5.2 The main program.

19.6 Interfacing with Excel.

19.7 Conclusions and summary.

20 An Introduction to ADI and Splitting Schemes.

20.1 Introduction and objectives.

20.2 A model problem.

20.3 Motivation and history.

20.4 Basic ADI scheme for the heat equation.

20.4.1 Three-dimensional heat equation.

20.5 Basic splitting scheme for the heat equation.

20.5.1 Three-dimensional heat equation.

20.6 Approximating cross-derivatives.

20.7 Handling boundary conditions.

20.8 Algorithms and design issues.

20.9 Conclusions and summary.

21 Numerical Approximation of Two-Factor Derivative Models.

21.1 Introduction and objectives.

21.2 Two-factor models in financial engineering.

21.2.1 Asian options.

21.2.2 Convertible bonds with random interest rates.

21.2.3 Options with two underlying assets.

21.2.4 Basket options.

21.2.5 Fixed-income applications.

21.3 Finite difference approximations.

21.4 ADI schemes for Asian options.

21.4.1 Upwinding.

21.5 Splitting schemes.

21.6 Conclusions and summary.

PART V DESIGN PATTERNS.

22 A C++ Application for Displaying Numeric Data.

22.1 Introduction and objectives.

22.2 Input mechanisms.

22.3 Conversion and processing mechanisms.

22.4 Output and display mechanisms.

22.4.1 Ensuring that Excel is started only once.

22.5 Putting it all together.

22.6 Output.

22.7 Other functionality.

22.7.1 Accessing cell data.

22.7.2 Cell data for functions.

22.7.3 Using Excel with finite difference schemes.

22.8 Using Excel and property sets.

22.9 Extensions and the road to design patterns.

22.10 Conclusions and summary.

23 Object Creational Patterns.

23.1 Introduction and objectives.

23.2 The Singleton pattern.

23.2.1 The templated Singleton solution.

23.2.2 An extended example.

23.2.3 Applications to financial engineering.

23.3 The Prototype pattern.

23.3.1 The Prototype pattern: Solution.

23.3.2 Applications to financial engineering.

23.4 Factory Method pattern (virtual constructor).

23.4.1 An extended example.

23.5 Abstract Factory pattern.

23.5.1 The abstract factory: solution.

23.5.2 An extended example.

23.6 Applications to financial engineering.

23.7 Conclusions and summary.

24 Object Structural Patterns.

24.1 Introduction and objectives.

24.2 Kinds of structural relationships between classes.

24.2.1 Aggregation.

24.2.2 Association.

24.2.3 Generalisation/specialization.

24.3 Whole–Part pattern.

24.4 The Composite pattern.

24.5 The Fa¸cade pattern.

24.6 The Bridge pattern.

24.6.1 An example of the Bridge pattern.

24.7 Conclusions and summary.

25 Object Behavioural Patterns.

25.1 Introduction and objectives.

25.2 Kinds of behavioural patterns.

25.3 Iterator pattern.

25.3.1 Iterating in composites.

25.3.2 Iterating in property sets.

25.4 The Visitor pattern.

25.4.1 Visitors and the Extensible Markup Language (XML).

25.5 Notification patterns.

25.6 Conclusions and summary.

PART VI DESIGN AND DEPLOYMENT ISSUES.

26 An Introduction to the Extensible Markup Language.

26.1 Introduction and objectives.

26.1.1 What’s the big deal with XML?

26.2 A short history of XML.

26.3 The XML structure.

26.3.1 XML files.

26.3.2 XML syntax.

26.3.3 Attributes in XML.

26.4 Document Type Definition.

26.4.1 DTD syntax.

26.4.2 Validation issues.

26.4.3 Limitations of DTDs.

26.5 Extensible Stylesheet Language Transformation (XSLT).

26.5.1 Namespaces in XML.

26.5.2 Main concepts in XSL.

26.6 An application of XML: Financial products Markup Language.

26.6.1 Product architecture overview.

26.6.2 Example: Equity derivative options product architecture.

26.7 Conclusions and summary.

27 Advanced XML and Programming Interface.

27.1 Introduction and objectives.

27.2 XML Schema.

27.2.1 Element declaration.

27.2.2 User-defined simple and complex types.

27.2.3 Multiplicity issues.

27.2.4 An example.

27.2.5 Comparing DTDs and the XML Schema.

27.2.6 XML Schemas and FpML.

27.3 Accessing XML data: The Document Object Model.

27.3.1 DOM in a programming environment.

27.4 DOM and C++: The essentials.

27.5 DOM, entities and property sets.

27.5.1 XML readers and writers.

27.5.2 Examples and applications.

27.6 XML structures for plain and barrier options.

27.7 Conclusions and summary.

28 Interfacing C++ and Excel.

28.1 Introduction and objectives.

28.2 Object model in Excel: An overview.

28.3 Under the bonnet: Technical details of C++ interfacing to Excel.

28.3.1 Startup.

28.3.2 Creating charts and cell values.

28.3.3 Interoperability with the SimplePropertySet.

28.4 Implementing the core process.

28.4.1 Registration: Getting basic input.

28.4.2 Calculations.

28.4.3 Displaying the results of the calculations.

28.4.4 The application (main program).

28.5 Extensions.

28.6 Application areas.

28.7 Conclusions and summary.

29 Advanced Excel Interfacing.

29.1 Introduction and objectives.

29.2 Status report and new requirements.

29.3 A gentle introduction to Excel add-ins.

29.3.1 What kinds of add-ins are there?

29.4 Automation add-in in detail.

29.4.1 Functions with two parameters.

29.4.2 Functions that accept a range.

29.4.3 Using the Vector template class.

29.5 Creating a COM add-in.

29.6 Future trends.

29.7 Conclusions and summary.

30 An Extended Application: Option Strategies and Portfolios.

30.1 Introduction and objectives.

30.2 Spreads.

30.3 Combinations: Straddles and strangles.

30.4 Designing and implementing spreads.

30.5 Delta hedging.

30.6 An example.

30.7 Tips and guidelines.

Appendices.

A1 My C++ refresher.

A2 Dates and other temporal types.

References.

Index.