Financial Instrument Pricing Using C++
暫譯: 使用 C++ 進行金融工具定價

Daniel J. Duffy

  • 出版商: Wiley
  • 出版日期: 2004-07-30
  • 售價: $5,080
  • 貴賓價: 9.5$4,826
  • 語言: 英文
  • 頁數: 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.

商品描述(中文翻譯)

描述:
在金融工程和工具定價應用的開發中,C++ 是最佳語言之一。它擁有多種特性,使開發者能夠編寫穩健、靈活且可擴展的軟體系統。它是 ANSI/ISO 標準,完全物件導向,並能與許多第三方應用程式介面相連。它支援模板和泛型編程,透過模板實現大量重用(「一次編寫」)並支援舊有的 C 應用程式。

在本書中,我們將 C++ 提升到一個新層次,應用於選擇權和衍生品定價模型的類別、庫和應用程式的設計與實現。我們採用現代軟體工程技術來製作工業級應用程式:
- 在金融中使用標準模板庫(STL)
- 創建自己的模板類別和函數
- 可重用的數據結構,用於向量、矩陣和張量
- 用於數值分析的類別(數值線性代數等)
- 解決 Black Scholes 方程,精確和近似解
- 在 C++ 中實現有限差分法
- 與「四人幫」設計模式的整合
- 與 Excel 介面(輸出和附加元件)
- 金融工程與 XML
- 現金流和收益曲線

本書附帶一張 CD,包含 Datasim Financial Toolkit 中的源代碼,您可以直接使用。這將幫助您通過重用現有的類別和庫來快速上手 C++ 應用程式。

「獨特……讓我們熱烈歡迎現代定價工具。」— Paul Wilmott,數學家、作者及基金經理

目錄:
1 本書的執行概述。
1.1 本書是什麼?
1.2 本書有何特別之處?
1.3 本書的讀者是誰?
1.4 軟體需求。
1.5 本書的結構。
1.6 教學方法。
1.7 本書不是什麼。
1.8 CD 上的源代碼。
第一部分 C++ 中的模板編程。
2 C++ 中模板的簡介。
2.1 介紹和目標。
2.2 動機和背景。
2.3 定義模板。
2.3.1 一個範例。
2.4 模板實例化。
2.5 函數模板。
2.5.1 一個範例。
2.6 預設值和 typedefs。
2.7 實現模板時的指導方針。
2.8 結論和總結。
3 標準模板庫的介紹。
3.1 介紹和目標。
3.1.1 為什麼使用 STL?
3.2 STL 的鳥瞰圖。
3.3 序列容器。
3.3.1 編程列表。
3.3.2 STL 中的向量和數組。
3.4 關聯容器。
3.4.1 STL 中的集合。
3.4.2 STL 中的映射。
3.5 STL 中的迭代器。
3.5.1 迭代器的種類?
3.6 算法。
3.7 在金融工具中使用 STL。
3.8 結論和總結。
4 用於金融工程應用的 STL。
4.1 介紹和目標。
4.2 聰明的數據結構。
4.2.1 一個簡單的輸出機制。
4.3 集合論和 STL。
4.4 有用的算法。
4.5 STL 適配器容器。
4.6 結論和總結。
5 金融工程中的屬性模式。
5.1 介紹和目標。
5.2 屬性模式。
5.2.1 屬性模式的要求。
5.3 一個範例。
5.4 擴展屬性模式:屬性集合和屬性列表。
5.4.1 一個範例。
5.5 屬性和奇異選項。
5.5.1 範例:高管選項。
5.6 結論和總結。
第二部分 建構塊類別。
6 數組、向量和矩陣。
6.1 介紹和目標。
6.2 動機和背景。
6.3 分層方法。
6.4 數組和矩陣類別的詳細介紹。
6.4.1 簡單的打印函數。
6.4.2 數組範例。
6.4.3 矩陣範例。
6.5 向量和數值矩陣類別的詳細介紹。
6.5.1 向量範例。
6.5.2 數值矩陣範例。
6.6 關聯數組和矩陣。
6.7 結論和總結。
7 數組和矩陣屬性。
7.1 介紹和目標。
7.2 功能概述。
7.3 軟體需求。
7.3.1 準確性。
7.3.2 效率。
7.3.3 可靠性。
7.3.4 可理解性。
7.4 核心過程。
7.4.1 矩陣和向量之間的互動。
7.4.2 一些範例。
7.5 其他函數類別。
7.5.1 集中趨勢的測量。
7.5.2 離散的測量。
7.5.3 矩、偏度、峰度。
7.5.4 不等式。
7.6 使用這些函數。
7.6.1 計算歷史波動率。
7.6.2 投資組合的回報方差。
7.7 異常處理的介紹。
7.7.1 嘗試、拋出和捕獲:有點像網球。
7.8 結論和總結。
8 數值線性代數。
8.1 介紹和目標。
8.2 數值線性代數的介紹。
8.2.1 直接方法。
8.2.2 迭代方法。
8.3 三對角系統。
8.3.1 LU 分解。
8.3.2 Godunov 的雙掃描法。
8.3.3 設計和實現三對角方案。
8.4 區塊三對角系統。
8.5 我們的矩陣應滿足什麼要求?
8.5.1 正定矩陣和對角優勢。
8.5.2 M-矩陣。
8.6 結論和總結。
9 在 C++ 中建模函數。
9.1 介紹和目標。
9.2 C++ 中的函數指針。
9.3 STL 中的函數對象。
9.3.1 比較函數。
9.3.2 STL 和金融工程。
9.4 一些函數類型。
9.4.1 在數值分析和金融工程中的應用。
9.4.2 一個範例:選擇權定價中的函數。
9.5 創建自己的函數類別。
9.6 函數數組。
9.7 向量函數。
9.8 實值函數。
9.9 向量值函數。
9.10 結論和總結。
10 C++ 中的統計分佈類別。
10.1 介紹和目標。
10.2 離散和連續概率分佈函數。