Financial Instrument Pricing Using C++

Standards Information Network (Verlag)
  • 2. Auflage
  • |
  • erschienen am 5. September 2018
  • |
  • 1168 Seiten
E-Book | ePUB mit Adobe-DRM | Systemvoraussetzungen
978-1-119-17048-8 (ISBN)
An integrated guide to C++ and computational finance This complete guide to C++ and computational finance is a follow-up and major extension to Daniel J. Duffy's 2004 edition of Financial Instrument Pricing Using C++. Both C++ and computational finance have evolved and changed dramatically in the last ten years and this book documents these improvements. Duffy focuses on these developments and the advantages for the quant developer by:

Delving into a detailed account of the new C++11 standard and its applicability to computational finance.
Using de-facto standard libraries, such as Boost and Eigen to improve developer productivity.
Developing multiparadigm software using the object-oriented, generic, and functional programming styles.
Designing flexible numerical algorithms: modern numerical methods and multiparadigm design patterns.
Providing a detailed explanation of the Finite Difference Methods through six chapters, including new developments such as ADE, Method of Lines (MOL), and Uncertain Volatility Models.
Developing applications, from financial model to algorithmic design and code, through a coherent approach.
Generating interoperability with Excel add-ins, C#, and C++/CLI.
Using random number generation in C++11 and Monte Carlo simulation.

Duffy adopted a spiral model approach while writing each chapter of Financial Instrument Pricing Using C++ 2e: analyse a little, design a little, and code a little. Each cycle ends with a working prototype in C++ and shows how a given algorithm or numerical method works. Additionally, each chapter contains non-trivial exercises and projects that discuss improvements and extensions to the material.

This book is for designers and application developers in computational finance, and assumes the reader has some fundamental experience of C++ and derivatives pricing.


Once you have purchased a copy of the book please send an email to the author requesting your personal and non-transferable copy of the source code. Proof of purchase is needed. The subject of the mail should be "C++ Book Source Code Request". You will receive a reply with a zip file attachment.
2nd Revised edition
  • Englisch
  • USA
John Wiley & Sons Inc
  • Für Beruf und Forschung
  • Überarbeitete Ausgabe
  • Reflowable
  • 4,41 MB
978-1-119-17048-8 (9781119170488)

weitere Ausgaben werden ermittelt
DANIEL J. DUFFY started the company Datasim in 1987 to promote C++ as a new object-oriented language for developing applications in the roles of developer, architect and requirements analyst to help clients design and analyse software systems for Computer Aided Design (CAD), process control and hardware- software systems, logistics, holography (optical technology) and computational finance. He used a combination of top-down functional decomposition and bottom-up object-oriented programming techniques to create stable and extendible applications. Prior to Datasim, he worked on engineering and financial applications in oil and gas and semiconductor industries using a range of numerical methods (for example, the finite element method [FEM]) on mainframe and mini-computers.

Duffy has BA (Mod), MSc and PhD degrees in pure, numerical and applied mathematics and has been active in promoting partial differential equation (PDE) and finite difference methods (FDM) to applications in computational finance. He was responsible for the introduction of the Fractional Step ("Soviet Splitting") method and the Alternating Direction Explicit (ADE) method in computational finance.

He is the originator of two very popular and leading C++ online courses (both C++98 and C++11/14/17) on in cooperation with Quantnet LLC and Baruch College (CUNY), NYC. He also trains quants, developers and designers around the world. Duffy can be contacted at In his spare time, he tries to keep in shape by workouts in the dojo.
CHAPTER 1 A Tour of C++ and Environs 1

1.1 Introduction and Objectives 1

1.2 What is C++? 1

1.3 C++ as a Multiparadigm Programming Language 2

1.4 The Structure and Contents of this Book: Overview 4

1.5 A Tour of C++11: Black-Scholes and Environs 6

1.6 Parallel Programming in C++ and Parallel C++ Libraries 12

1.7 Writing C++ Applications; Where and How to Start? 14

1.8 For whom is this Book Intended? 16

1.9 Next-Generation Design and Design Patterns in C++ 16

1.10 Some Useful Guidelines and Developer Folklore 17

1.11 About the Author 18

1.12 The Source Code and Getting the Source Code 19

CHAPTER 2 New and Improved C++ Fundamentals 21

2.1 Introduction and Objectives 21

2.2 The C++ Smart Pointers 21

2.3 Using Smart Pointers in Code 23

2.4 Extended Examples of Smart Pointers Usage 30

2.5 Move Semantics and Rvalue References 34

2.6 Other Bits and Pieces: Usability Enhancements 39

2.7 Summary and Conclusions 52

2.8 Exercises and Projects 52

CHAPTER 3 Modelling Functions in C++ 59

3.1 Introduction and Objectives 59

3.2 Analysing and Classifying Functions 60

3.3 New Functionality in C++: std::function<> 64

3.4 New Functionality in C++: Lambda Functions and Lambda Expressions 65

3.5 Callable Objects 69

3.6 Function Adapters and Binders 70

3.7 Application Areas 75

3.8 An Example: Strategy Pattern New Style 75

3.9 Migrating from Traditional Object-Oriented Solutions: Numerical Quadrature 78

3.10 Summary and Conclusions 81

3.11 Exercises and Projects 82

CHAPTER 4 Advanced C++ Template Programming 89

4.1 Introduction and Objectives 89

4.2 Preliminaries 91

4.3 decltype Specifier 94

4.4 Life Before and After decltype 101

4.5 std::result_of and SFINAE 106

4.6 std::enable_if 108

4.7 Boost enable_if 112

4.8 std::decay()Trait 114

4.9 A Small Application: Quantities and Units 115

4.10 Conclusions and Summary 118

4.11 Exercises and Projects 118

CHAPTER 5 Tuples in C++ and their Applications 123

5.1 Introduction and Objectives 123

5.2 An std:pair Refresher and New Extensions 123

5.3 Mathematical and Computer Science Background 128

5.4 Tuple Fundamentals and Simple Examples 130

5.5 Advanced Tuples 130

5.6 Using Tuples in Code 133

5.7 Other Related Libraries 138

5.8 Tuples and Run-Time Efficiency 140

5.9 Advantages and Applications of Tuples 142

5.10 Summary and Conclusions 143

5.11 Exercises and Projects 143

CHAPTER 6 Type Traits, Advanced Lambdas and Multiparadigm Design in C++ 147

6.1 Introduction and Objectives 147

6.2 Some Building Blocks 149

6.3 C++ Type Traits 150

6.4 Initial Examples of Type Traits 158

6.5 Generic Lambdas 161

6.6 How Useful will Generic Lambda Functions be in the Future? 164

6.7 Generalised Lambda Capture 171

6.7.1 Living Without Generalised Lambda Capture 173

6.8 Application to Stochastic Differential Equations 174

6.9 Emerging Multiparadigm Design Patterns: Summary 178

6.10 Summary and Conclusions 179

6.11 Exercises and Projects 179

CHAPTER 7 Multiparadigm Design in C++ 185

7.1 Introduction and Objectives 185

7.2 Modelling and Design 185

7.3 Low-Level C++ Design of Classes 190

7.4 Shades of Polymorphism 199

7.5 Is there More to Life than Inheritance? 206

7.6 An Introduction to Object-Oriented Software Metrics 207

7.7 Summary and Conclusions 210

7.8 Exercises and Projects 210

CHAPTER 8 C++ Numerics, IEEE 754 and Boost C++ Multiprecision 215

8.1 Introduction and Objectives 215

8.2 Floating-Point Decomposition Functions in C++ 219

8.3 A Tour of std::numeric_limits 221

8.4 An Introduction to Error Analysis 223

8.5 Example: Numerical Quadrature 224

8.6 Other Useful Mathematical Functions in C++ 228

8.7 Creating C++ Libraries 231

8.8 Summary and Conclusions 239

8.9 Exercises and Projects 239

CHAPTER 9 An Introduction to Unified Software Design 245

9.1 Introduction and Objectives 245

9.1.1 Future Predictions and Expectations 246

9.2 Background 247

9.3 System Scoping and Initial Decomposition 251

9.4 Checklist and Looking Back 259

9.5 Variants of the Software Process: Policy-Based Design 260

9.6 Using Policy-Based Design for the DVM Problem 268

9.7 Advantages of Uniform Design Approach 273

9.8 Summary and Conclusions 274

9.9 Exercises and Projects 275

CHAPTER 10 New Data Types, Containers and Algorithms in C++ and Boost C++ Libraries 283

10.1 Introduction and Objectives 283

10.2 Overview of New Features 283

10.3 C++ std::bitset and Boost Dynamic Bitset Library 284

10.4 Chrono Library 288

10.5 Boost Date and Time 301

10.6 Forwards Lists and Compile-Time Arrays 306

10.7 Applications of Boost.Array 311

10.8 Boost uBLAS (Matrix Library) 313

10.9 Vectors 316

10.10 Matrices 318

10.11 Applying uBLAS: Solving Linear Systems of Equations 322

10.12 Summary and Conclusions 330

10.13 Exercises and Projects 331

CHAPTER 11 Lattice Models Fundamental Data Structures and Algorithms 333

11.1 Introduction and Objectives 333

11.2 Background and Current Approaches to Lattice Modelling 334

11.3 New Requirements and Use Cases 335

11.4 A New Design Approach: A Layered Approach 335

11.5 Initial '101' Examples of Option Pricing 347

11.6 Advantages of Software Layering 349

11.7 Improving Efficiency and Reliability 352

11.8 Merging Lattices 355

11.9 Summary and Conclusions 357

11.10 Exercises and Projects 357

CHAPTER 12 Lattice Models Applications to Computational Finance 367

12.1 Introduction and Objectives 367

12.2 Stress Testing the Lattice Data Structures 368

12.3 Option Pricing Using Bernoulli Paths 372

12.4 Binomial Model for Assets with Dividends 374

12.5 Computing Option Sensitivities 377

12.6 (Quick) Numerical Analysis of the Binomial Method 379

12.7 Richardson Extrapolation with Binomial Lattices 382

12.8 Two-Dimensional Binomial Method 382

12.9 Trinomial Model of the Asset Price 384

12.10 Stability and Convergence of the Trinomial Method 385

12.11 Explicit Finite Difference Method 386

12.12 Summary and Conclusions 389

12.13 Exercises and Projects 389

CHAPTER 13 Numerical Linear Algebra: Tridiagonal Systems and Applications 395

13.1 Introduction and Objectives 395

13.2 Solving Tridiagonal Matrix Systems 395

13.3 The Crank-Nicolson and Theta Methods 406

13.4 The ADE Method for the Impatient 411

13.5 Cubic Spline Interpolation 415

13.6 Some Handy Utilities 427

13.7 Summary and Conclusions 428

13.8 Exercises and Projects 429

CHAPTER 14 Data Visualisation in Excel 433

14.1 Introduction and Objectives 433

14.2 The Structure of Excel-Related Objects 433

14.3 Sanity Check: Is the Excel Infrastructure Up and Running? 435

14.4 ExcelDriver and Matrices 437

14.5 ExcelDriver and Vectors 444

14.6 Path Generation for Stochastic Differential Equations 448

14.7 Summary and Conclusions 459

14.8 Exercises and Projects 459

14.9 Appendix: COM Architecture Overview 463

14.10 An Example 468

14.11 Virtual Function Tables 471

14.12 Differences between COM and Object-Oriented Paradigm 473

14.13 Initialising the COM Library 474

CHAPTER 15 Univariate Statistical Distributions 475

15.1 Introduction, Goals and Objectives 475

15.2 The Error Function and Its Universality 475

15.3 One-Factor Plain Options 478

15.4 Option Sensitivities and Surfaces 488

15.5 Automating Data Generation 491

15.6 Introduction to Statistical Distributions and Functions 499

15.7 Advanced Distributions 504

15.8 Summary and Conclusions 511

15.9 Exercises and Projects 511

CHAPTER 16 Bivariate Statistical Distributions and Two-Asset Option Pricing 515

16.1 Introduction and Objectives 515

16.2 Computing Integrals Using PDEs 516

16.3 The Drezner Algorithm 521

16.4 The Genz Algorithm and the West/Quantlib Implementations 521

16.5 Abramowitz and Stegun Approximation 525

16.6 Performance Testing 528

16.7 Gauss-Legendre Integration 529

16.8 Applications to Two-Asset Pricing 531

16.9 Trivariate Normal Distribution 536

16.10 Chooser Options 543

16.11 Conclusions and Summary 545

16.12 Exercises and Projects 546

CHAPTER 17 STL Algorithms in Detail 551

17.1 Introduction and Objectives 551

17.2 Binders and std::bind 554

17.3 Non-modifying Algorithms 557

17.4 Modifying Algorithms 567

17.5 Compile-Time Arrays 575

17.6 Summary and Conclusions 576

17.7 Exercises and Projects 576

17.8 Appendix: Review of STL Containers and Complexity Analysis 583

CHAPTER 18 STL Algorithms Part II 589

18.1 Introduction and Objectives 589

18.2 Mutating Algorithms 589

18.3 Numeric Algorithms 597

18.4 Sorting Algorithms 601

18.5 Sorted-Range Algorithms 604

18.5.5 Merging 608

18.6 Auxiliary Iterator Functions 609

18.7 Needle in a Haystack: Finding the Right STL Algorithm 612

18.8 Applications to Computational Finance 613

18.9 Advantages of STL Algorithms 613

18.10 Summary and Conclusions 614

18.11 Exercises and Projects 614

CHAPTER 19 An Introduction to Optimisation and the Solution of Nonlinear Equations 617

19.1 Introduction and Objectives 617

19.2 Mathematical and Numerical Background 618

19.3 Sequential Search Methods 619

19.4 Solutions of Nonlinear Equations 620

19.5 Fixed-Point Iteration 622

19.6 Aitken's Acceleration Process 623

19.7 Software Framework 623

19.8 Implied Volatility 632

19.9 Solvers in the Boost C++ Libraries 632

19.10 Summary and Conclusions 633

19.11 Exercises and Projects 633

19.12 Appendix: The Banach Fixed-Point Theorem 636

CHAPTER 20 The Finite Difference Method for PDEs: Mathematical Background 641

20.1 Introduction and Objectives 641

20.2 General Convection-Diffusion-Reaction Equations and Black-Scholes PDE 641

20.3 PDE Preprocessing 64520.3.2 Reduction of PDE to Conservative Form 646

20.4 Maximum Principles for Parabolic PDEs 649

20.5 The Fichera Theory 650

20.6 Finite Difference Schemes: Properties and Requirements 654

20.7 Example: A Linear Two-Point Boundary Value Problem 655

20.8 Exponentially Fitted Schemes for Time-Dependent PDEs 659

20.9 Richardson Extrapolation 663

20.10 Summary and Conclusions 665

20.11 Exercises and Projects 666

CHAPTER 21 Software Framework for One-Factor Option Models 669

21.1 Introduction and Objectives 669

21.2 A Software Framework: Architecture and Context 669

21.3 Modelling PDEs and Finite Difference Schemes: What is Supported? 670

21.4 Several Versions of Alternating Direction Explicit 671

21.5 A Software Framework: Detailed Design and Implementation 673

21.6 C++ Code for PDE Classes 674

21.7 C++ Code for FDM Classes 679

21.8 Examples and Test Cases 690

21.9 Summary and Conclusions 693

21.10 Exercises and Projects 694

CHAPTER 22 Extending the Software Framework 701

22.1 Introduction and Objectives 701

22.2 Spline Interpolation of Option Values 701

22.3 Numerical Differentiation Foundations 704

22.4 Numerical Greeks 710

22.5 Constant Elasticity of Variance Model 715

22.6 Using Software Design (GOF) Patterns 715

22.7 Multiparadigm Design Patterns 720

22.8 Summary and Conclusions 721

22.9 Exercises and Projects 721

CHAPTER 23A PDE Software Framework in C++11 for a Class of Path-Dependent Options 727

23.1 Introduction and Objectives 727

23.2 Modelling PDEs and Initial Boundary Value Problems in the Functional Programming Style 728

23.3 PDE Preprocessing 731

23.4 The Anchoring PDE 732

23.5 ADE for Anchoring PDE 739

23.6 Useful Utilities 746

23.7 Accuracy and Performance 748

23.8 Summary and Conclusions 750

23.9 Exercises and Projects 751

CHAPTER 24 Ordinary Differential Equations and their Numerical Approximation 755

24.1 Introduction and Objectives 755

24.2 What is an ODE? 755

24.3 Classifying ODEs 756

24.4 A Palette of Model ODEs 757

24.5 Existence and Uniqueness Results 760

24.6 Overview of Numerical Methods for ODEs: The Big Picture 763

24.7 Creating ODE Solvers in C++ 770

24.8 Summary and Conclusions 776

24.9 Exercises and Projects 776

24.10 Appendix 778

CHAPTER 25 Advanced Ordinary Differential Equations and Method of Lines 781

25.1 Introduction and Objectives 781

25.2 An Introduction to the Boost Odeint Library 782

25.3 Systems of Stiff and Non-stiff Equations 791

25.4 Matrix Differential Equations 796

25.5 The Method of Lines: What is it and what are its Advantages? 799

25.6 Initial Foray in Computational Finance: MOL for One-Factor Black-Scholes PDE 801

25.7 Barrier Options 806

25.8 Using Exponential Fitting of Barrier Options 808

25.9 Summary and Conclusions 808

25.10 Exercises and Projects 809

CHAPTER 26 Random Number Generation and Distributions 819

26.1 Introduction and Objectives 819

26.2 What is a Random Number Generator? 820

26.3 What is a Distribution? 821

26.4 Some Initial Examples 825

26.5 Engines in Detail 827

26.6 Distributions in C++: The List 830

26.7 Back to the Future: C-Style Pseudo-Random Number Generation 831

26.8 Cryptographic Generators 833

26.9 Matrix Decomposition Methods 833

26.10 Generating Random Numbers 845

26.11 Summary and Conclusions 848

26.12 Exercises and Projects 849

CHAPTER 27 Microsoft .Net, C# and C++11 Interoperability 853

27.1 Introduction and Objectives 853

27.2 The Big Picture 854

27.3 Types 858

27.4 Memory Management 859

27.5 An Introduction to Native Classes 861

27.6 Interfaces and Abstract Classes 861

27.7 Use Case: C++/CLI as 'Main Language' 862

27.8 Use Case: Creating Proxies, Adapters and Wrappers for Legacy C++ Applications 864

27.8.1 Alternative: SWIG (Simplified Wrapper and Interface Generator) 871

27.9 'Back to the Future' Use Case: Calling C# Code from C++11 872

27.10 Modelling Event-Driven Applications with Delegates 876

27.11 Use Case: Interfacing with Legacy Code 886

27.12 Assemblies and Namespaces for C++/CLI 889

27.13 Summary and Conclusions 895

27.14 Exercises and Projects 896

CHAPTER 28 C++ Concurrency, Part I Threads 899

28.1 Introduction and Objectives 899

28.2 Thread Fundamentals 900

28.3 Six Ways to Create a Thread 903

28.4 Intermezzo: Parallelising the Binomial Method 909

28.5 Atomics 916

28.6 Smart Pointers and the Thread-Safe Pointer Interface 924

28.7 Thread Synchronisation 926

28.8 When should we use Threads? 929

28.9 Summary and Conclusions 929

28.10 Exercises and Projects 930

CHAPTER 29 C++ Concurrency, Part II Tasks 935

29.1 Introduction and Objectives 935

29.2 Finding Concurrency: Motivation 936

29.3 Tasks and Task Decomposition 937

29.4 Futures and Promises 941

29.5 Shared Futures 945

29.6 Waiting on Tasks to Complete 948

29.7 Continuations and Futures in Boost 950

29.8 Pure Functions 952

29.9 Tasks versus Threads 953

29.10 Parallel Design Patterns 953

29.11 Summary and Conclusions 955

29.12 Quizzes, Exercises and Projects 955

CHAPTER 30 Parallel Patterns Language (PPL) 961

30.1 Introduction and Objectives 961

30.2 Parallel Algorithms 962

30.3 Partitioning Work 967

30.4 The Aggregation/Reduction Pattern in PPL 971

30.5 Concurrent Containers 977

30.6 An Introduction to the Asynchronous Agents Library and Event-Based Systems 978

30.7 A Design Plan to Implement a Framework Using Message Passing and Other Approaches 986

30.8 Summary and Conclusions 989

30.9 Exercises and Projects 990

CHAPTER 31 Monte Carlo Simulation, Part I 993

31.1 Introduction and Objectives 993

31.2 The Boost Parameters Library for the Impatient 995

31.3 Monte Carlo Version 1: The Monolith Program ('Ball of Mud') 1000

31.4 Policy-Based Design: Dynamic Polymorphism 1003

31.5 Policy-Based Design Approach: CRTP and Static Polymorphism 1011

31.6 Builders and their Subcontractors (Factory Method Pattern) 1013

31.7 Practical Issue: Structuring the Project Directory and File Contents 1014

31.8 Summary and Conclusions 1016

31.9 Exercises and Projects 1017

CHAPTER 32 Monte Carlo Simulation, Part II 1023

32.1 Introduction and Objectives 1023

32.2 Parallel Processing and Monte Carlo Simulation 1023

32.3 A Family of Predictor-Corrector Schemes 1033

32.4 An Example (CEV Model) 1038

32.5 Implementing the Monte Carlo Method Using the Asynchronous Agents Library 1041

32.6 Summary and Conclusions 1047

32.7 Exercises and Projects 1050

Appendix 1: Multiple-Precision Arithmetic 1053

Appendix 2: Computing Implied Volatility 1075

References 1109

Index 1117

A Tour of C++ and Environs

riverrun, past Eve and Adam's, from swerve of shore to bend of bay, brings us by a commodius vicus of recirculation back to Howth Castle and Environs

-Joyce (1939)

1.1 Introduction and Objectives

This book is the second edition of Financial Instrument Pricing Using C++, also written by the author (Duffy, 2004B). The most important reason for writing this hands-on book is to reflect the many changes and improvements to the C++ language, in particular due to the announcement of the new standard C++11 (and to a lesser extent C++14 and C++17). It feels like a new language compared to C++03 and in a sense it is. First, C++11 improves and extends the syntax of C++03. Second, it has become a programming language that supports the functional programming model in addition to the object-oriented and generic programming models.

We apply modern C++ to design and implement applications in computational finance, in particular option pricing problems using partial differential equation (PDE)/finite difference method (FDM), Monte Carlo and lattice models. We show the benefits of using C++11 compared to similar solutions in C++03. The resulting code tends to be more maintainable and extendible, especially if the software system has been properly designed. We recommend spending some time on designing the software system before jumping into code and to this end we include a defined process to take a problem description, design the problem and then implement it in such a way that it results in a product that satisfies the requirements and that is delivered on time and within budget.

This book is a detailed exposition of the language features in C++, how to use these features and how to design applications in computational finance. We discuss modern numerical methods to price plain and American options and the book is written in a hands-on, step-by-step fashion.

1.2 What is C++?

C++ is a general-purpose systems programming language that was originally designed as an extension to the C programming language. Its original name was 'C with classes' and its object-oriented roots can be traced to the programming language Simula which was one of the first object-oriented languages. C++ was standardised by the International Organization for Standardization (ISO) in 1998 (called the C++03 standard) and C++14 is the standard at the moment of writing. It can be seen as a minor extension to C++11 which is a major update to the language.

C++ was designed primarily for applications in which performance, efficiency and flexibility play a vital role. In this sense it is a systems programming language and early applications in the 1990s were in telecommunications, embedded systems, medical devices and Computer Aided Design (CAD) as well as first-generation option pricing risk management systems in computational finance. The rise in popularity continued well into the late 1990s as major vendors such as Microsoft, Sun and IBM began to endorse object-oriented technology in general and C++ in particular. It was also in this period that the Java programming language appeared which in time became a competitor to C++.

C++ remains one of the most important programming languages at the moment of writing. It is evolving to support new hardware such as multicore processors, GPUs (graphics processing units) and heterogeneous computing environments. It also has a number of mathematical libraries that are useful in computational finance applications.

1.3 C++ As a Multiparadigm Programming Language

We give an overview of the programming paradigms that C++ supports. In general, a programming paradigm is a way to classify programming languages according to the style of computer programming. Features of various programming languages determine which programming paradigms they belong to. C++ is a multiparadigm programming language because it supports the following styles:

  • Procedural: organises code around functions, as typically seen in programs written in C, FORTRAN and COBOL. The style is based on structured programming in which a function or program is decomposed into simpler functions.
  • Object-oriented: organises code around classes. A class is an abstract entity that encapsulates functions and data into a logical unit. We instantiate a class to produce objects. Furthermore, classes can be grouped into hierarchies. It is probably safe to say that this style is the most popular one in the C++ community.
  • Generic/template: templates are a feature of C++ that allow functions and classes to operate with generic types. A function or class can then work on different data types.
  • Functional: treats computation as the evaluation of mathematical functions. It is a declarative programming paradigm; this means that programming is done with expressions and declarations instead of statements. The output value of a function depends only on its input arguments.

The generic programming style is becoming more important and pronounced in C++, possibly at the expense of the traditional object-oriented model which is based on class hierarchies and subtype (dynamic) polymorphism. Template code tends to perform better at run-time while many errors are caught at compile-time, in contrast to object-oriented code where the errors tend to be caught by the linker or even at run-time.

The most recent style that C++ has (some) support for is functional programming. This style predates both structured and object-oriented programming. Functional programming has its origins in lambda calculus, a formal system developed by Alonzo Church in the 1930s to investigate computability, function definition, function application and recursion. Many functional programming languages can be viewed as elaborations on the lambda calculus. C++ supports the notion of lambda functions. A lambda function in C++ is an unnamed function but it has all the characteristics of a normal function. Here is an example of defining a stored lambda function (which we can define in place in code) and we then call it as a normal function:

// TestLambda101.cpp // // Simple example of a lambda function // // (C) Datasim Education BV 2018 // //   #include <iostream> #include <string>   int main() { // Captured variable std::string cVar("Hello");   // Stored lambda function, with captured variable auto hello = [&cVar](const std::string& s) { // Return type automatically deduced   std::cout << cVar << " " << s << '\n'; };   // Call the stored lambda function hello(std::string("C")); hello(std::string("C++"));   return 0; }

In this case we see that the lambda function has a formal input string argument and it uses a captured variable cVar. Lambda functions are simple but powerful and we shall show how they can be used in computational finance.

C++11 is a major improvement on C++03 and it has a number of features that facilitate the design of software systems based on a combination of Structured Analysis and object-oriented technology. In general, we have a defined process to decompose a system into loosely coupled subsystems (Duffy, 2004). We then implement each subsystem in C++11. We discuss this process in detail in this book.

1.4 The Structure and Contents of this Book: Overview

This book examines C++ from a number of perspectives. In this sense it differs from other C++ literature because it discusses the full software lifecycle, starting with the problem description and eventually producing a working C++ program. In this book the topics are based on numerical analysis and its applications to computational finance (in particular, option pricing). In order to design and implement maintainable and efficient software systems we discuss each of the following building blocks in detail:

  • A1: The new and improved syntax and language features in C++.
  • A2: Integrating object-oriented, generic and functional programming styles in C++ code.
  • A3: Replacing and upgrading the traditional Gang-of-Four software design patterns to fit into a multiparadigm design methodology.
  • A4: Analysing and designing large and complex software systems using a combination of top-down system decomposition and bottom-up object assembly.
  • A5: When writing applications, determining how much of the features in A1, A2, A3 and A4 to use.

The chapters can be categorised into those that deal with modern C++ syntax and language features, those that focus on system design and finally those chapters that discuss applications. In general, the first ten chapters introduce new language features. Chapters 11 to 19 focus on using C++ to create numerical libraries, visualisation software in Excel and lattice option pricing code. Chapters 20 to 29 are devoted to the finite difference method on the one hand and to multithreading and parallel processing on the other hand. The last three chapters of the book deal with Monte Carlo methods. For easy reference, we give a one-line summary of each chapter in the book:

  1. Smart pointers, move semantics, r-value references.
  2. All...

Dateiformat: ePUB
Kopierschutz: Adobe-DRM (Digital Rights Management)


Computer (Windows; MacOS X; Linux): Installieren Sie bereits vor dem Download die kostenlose Software Adobe Digital Editions (siehe E-Book Hilfe).

Tablet/Smartphone (Android; iOS): Installieren Sie bereits vor dem Download die kostenlose App Adobe Digital Editions (siehe E-Book Hilfe).

E-Book-Reader: Bookeen, Kobo, Pocketbook, Sony, Tolino u.v.a.m. (nicht Kindle)

Das Dateiformat ePUB ist sehr gut für Romane und Sachbücher geeignet - also für "fließenden" Text ohne komplexes Layout. Bei E-Readern oder Smartphones passt sich der Zeilen- und Seitenumbruch automatisch den kleinen Displays an. Mit Adobe-DRM wird hier ein "harter" Kopierschutz verwendet. Wenn die notwendigen Voraussetzungen nicht vorliegen, können Sie das E-Book leider nicht öffnen. Daher müssen Sie bereits vor dem Download Ihre Lese-Hardware vorbereiten.

Bitte beachten Sie bei der Verwendung der Lese-Software Adobe Digital Editions: wir empfehlen Ihnen unbedingt nach Installation der Lese-Software diese mit Ihrer persönlichen Adobe-ID zu autorisieren!

Weitere Informationen finden Sie in unserer E-Book Hilfe.

Download (sofort verfügbar)

71,99 €
inkl. 7% MwSt.
Download / Einzel-Lizenz
ePUB mit Adobe-DRM
siehe Systemvoraussetzungen
E-Book bestellen