C For Financial Mathematics - Programmer Books

Transcription

www.allitebooks.com

C forFinancialMathematicswww.allitebooks.com

CHAPMAN & HALL/CRCFinancial Mathematics SeriesAims and scope:The field of financial mathematics forms an ever-expanding slice of the financial sector. This seriesaims to capture new developments and summarize what is known over the whole spectrum of thisfield. It will include a broad range of textbooks, reference works and handbooks that are meant toappeal to both academics and practitioners. The inclusion of numerical code and concrete realworld examples is highly encouraged.Series EditorsM.A.H. DempsterDilip B. MadanRama ContCentre for Financial ResearchDepartment of PureMathematics and StatisticsUniversity of CambridgeRobert H. Smith Schoolof BusinessUniversity of MarylandDepartment of MathematicsImperial CollegePublished TitlesAmerican-Style Derivatives; Valuation and Computation, Jerome DetempleAnalysis, Geometry, and Modeling in Finance: Advanced Methods in OptionPricing, Pierre Henry-LabordèreC for Financial Mathematics, John ArmstrongCommodities, M. A. H. Dempster and Ke TangComputational Methods in Finance, Ali HirsaCounterparty Risk and Funding: A Tale of Two Puzzles, Stéphane Crépey andTomasz R. Bielecki, With an Introductory Dialogue by Damiano BrigoCredit Risk: Models, Derivatives, and Management, Niklas WagnerEngineering BGM, Alan BraceFinancial Mathematics: A Comprehensive Treatment, Giuseppe Campolieti andRoman N. MakarovThe Financial Mathematics of Market Liquidity: From Optimal Execution toMarket Making, Olivier GuéantFinancial Modelling with Jump Processes, Rama Cont and Peter TankovInterest Rate Modeling: Theory and Practice, Lixin WuIntroduction to Credit Risk Modeling, Second Edition, Christian Bluhm,Ludger Overbeck, and Christoph WagnerAn Introduction to Exotic Option Pricing, Peter BuchenIntroduction to Risk Parity and Budgeting, Thierry RoncalliIntroduction to Stochastic Calculus Applied to Finance, Second Edition,Damien Lamberton and Bernard LapeyreMonte Carlo Methods and Models in Finance and Insurance, Ralf Korn, Elke Korn,and Gerald KroisandtMonte Carlo Simulation with Applications to Finance, Hui Wangwww.allitebooks.com

Nonlinear Option Pricing, Julien Guyon and Pierre Henry-LabordèreNumerical Methods for Finance, John A. D. Appleby, David C. Edelman,and John J. H. MillerOption Valuation: A First Course in Financial Mathematics, Hugo D. JunghennPortfolio Optimization and Performance Analysis, Jean-Luc PrigentQuantitative Finance: An Object-Oriented Approach in C , Erik SchlöglQuantitative Fund Management, M. A. H. Dempster, Georg Pflug,and Gautam MitraRisk Analysis in Finance and Insurance, Second Edition, Alexander MelnikovRobust Libor Modelling and Pricing of Derivative Products, John SchoenmakersStochastic Finance: An Introduction with Market Examples, Nicolas PrivaultStochastic Finance: A Numeraire Approach, Jan VecerStochastic Financial Models, Douglas KennedyStochastic Processes with Applications to Finance, Second Edition,Masaaki KijimaStochastic Volatility Modeling, Lorenzo BergomiStructured Credit Portfolio Analysis, Baskets & CDOs, Christian Bluhmand Ludger OverbeckUnderstanding Risk: The Theory and Practice of Financial Risk Management,David MurphyUnravelling the Credit Crunch, David MurphyProposals for the series should be submitted to one of the series editors above or directly to:CRC Press, Taylor & Francis Group3 Park Square, Milton ParkAbingdon, Oxfordshire OX14 4RNUKwww.allitebooks.com

www.allitebooks.com

C forFinancialMathematicsJohn ArmstrongKing’s College London, Strand, UKwww.allitebooks.com

CRC PressTaylor & Francis Group6000 Broken Sound Parkway NW, Suite 300Boca Raton, FL 33487-2742 2017 by Taylor & Francis Group, LLCCRC Press is an imprint of Taylor & Francis Group, an Informa businessNo claim to original U.S. Government worksPrinted on acid-free paperVersion Date: 20161202International Standard Book Number-13: 978-1-4987-5005-9 (Hardback)This book contains information obtained from authentic and highly regarded sources. Reasonableefforts have been made to publish reliable data and information, but the author and publisher cannotassume responsibility for the validity of all materials or the consequences of their use. The authors andpublishers have attempted to trace the copyright holders of all material reproduced in this publicationand apologize to copyright holders if permission to publish in this form has not been obtained. If anycopyright material has not been acknowledged please write and let us know so we may rectify in anyfuture reprint.Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced,transmitted, or utilized in any form by any electronic, mechanical, or other means, now known orhereafter invented, including photocopying, microfilming, and recording, or in any information storage or retrieval system, without written permission from the publishers.For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For organizations that have been granted a photocopy license by the CCC, a separate system of payment has been arranged.Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and areused only for identification and explanation without intent to infringe.Visit the Taylor & Francis Web site athttp://www.taylorandfrancis.comand the CRC Press Web site athttp://www.crcpress.comwww.allitebooks.com

ContentsIntroductionxvii1 Getting Started1.11.21.31.41.51.61.71.81Installing your development environment1.1.1 For Windows . . . . . . . . . . .1.1.2 For Unix . . . . . . . . . . . . . .1.1.3 For MacOS X . . . . . . . . . . .Running an example program . . . . . .Compiling and running the code . . . .1.3.1 Compiling on Windows . . . . . .1.3.2 Compiling on Unix . . . . . . . .Understanding the example code . . . .Configuring the compiler . . . . . . . . .Making decisions . . . . . . . . . . . . .Exercises . . . . . . . . . . . . . . . . .Summary . . . . . . . . . . . . . . . . .2 Basic Data Types and Operators2.12.22.32.42.5Memory terminology . . . . . .Basic data types . . . . . . . .2.2.1 Integers . . . . . . . . .2.2.2 Floating point numbers .2.2.3 Booleans . . . . . . . . .2.2.4 Characters . . . . . . . .Casting . . . . . . . . . . . . .Memory addresses . . . . . . .Operators . . . . . . . . . . . .2.5.1 The sizeof operator . .2.5.2 Mathematical operations2.5.3 Comparison operators .2.5.4 Logical operators . . . .2.5.5 Bitwise operators . . . .2.5.6 Combining operators . .2.5.7 Assignment operators . 030viiwww.allitebooks.com

viiiContents2.62.5.8 If statements revisited . . . . . . . . . . . . . . . . .Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 Functions3.13.23.33.43.53.63.73.83.93.1037The C function syntax . . . . .Recursion . . . . . . . . . . . . . .Libraries . . . . . . . . . . . . . . .Declaring and defining functions .Functions that don’t return a valueSpecifying default values . . . . . .Overloading functions . . . . . . .Global and local variables . . . . .Namespaces . . . . . . . . . . . . .Summary . . . . . . . . . . . . . .4 Flow of 454647485255while loops . . . . . . . . . .do-while loops . . . . . . . .for loops . . . . . . . . . . .break, continue, return . .throw statements . . . . . . .switch statements . . . . . .Scope . . . . . . . . . . . . .Flow of control in operators .4.8.1 Short circuit evaluation4.8.2 The ternary operator .4.8.3 The comma operator .Summary . . . . . . . . . . .5 Working with Multiple Files5.15.25.33235The project FMLib . . . . . . . . . . . .Header files . . . . . . . . . . . . . . . .Creating our project . . . . . . . . . . .5.3.1 Creating the first header file . . .5.3.2 Some code that uses the functions5.3.3 Write the definitions . . . . . . .How header files work . . . . . . . . . .5.4.1 The meaning of include . . . . . .5.4.2 Pragma once . . . . . . . . . . . .5.4.3 Information hiding . . . . . . . .5.4.4 Inline . . . . . . . . . . . . . . . .A complete example . . . . . . . . . . 273737576777777788081

Contents5.6Summaryix. . . . . . . . . . . . . . . . . . . . . . . . . . . .6 Unit Testing6.16.26.36.46.56.66.785A testing framework for C . . . . . . .Macros . . . . . . . . . . . . . . . . . . .The macros in testing.h . . . . . . . . .6.3.1 The ASSERT macro . . . . . . . . .6.3.2 The ASSERT APPROX EQUAL macro .6.3.3 The INFO macro . . . . . . . . . . .6.3.4 The DEBUG PRINT macro . . . . . .6.3.5 The TEST macro . . . . . . . . . .Using testing.h . . . . . . . . . . . . . .What have we gained? . . . . . . . . . . .Testing normcdf . . . . . . . . . . . . . .Summary . . . . . . . . . . . . . . . . . .7 Using C 1929497Vectors . . . . . . . . . . . . . . . . . . . . . . . .Pass by reference and const . . . . . . . . . . . . .7.2.1 Pass by reference . . . . . . . . . . . . . . .7.2.2 The const keyword . . . . . . . . . . . . . .7.2.3 Pass by reference without const . . . . . . .Using ofstream . . . . . . . . . . . . . . . . . . . .Working with string . . . . . . . . . . . . . . . .Building strings efficiently . . . . . . . . . . . . . .Writing a pie chart . . . . . . . . . . . . . . . . . .7.6.1 A web-based chart . . . . . . . . . . . . . .7.6.2 Create a header file . . . . . . . . . . . . . .7.6.3 Write a source file . . . . . . . . . . . . . . .7.6.4 Enable testing in your files . . . . . . . . . .7.6.5 Write functions to generate the boiler plate7.6.6 Write a simple version of the chart data . .7.6.7 Write a test of what we’ve done so far . . .7.6.8 Write the interesting code . . . . . . . . . .7.6.9 Testing the interesting code . . . . . . . . .7.6.10 Wrap it all up into a single function . . . . .The architecture of the World Wide Web . . . . .Summary . . . . . . . . . . . . . . . . . . . . . . .8 User-Defined 2112113114114115116117121123Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . .Writing your own class . . . . . . . . . . . . . . . . . . . . .www.allitebooks.com123124

xContents8.38.48.58.68.78.88.98.2.1 Writing the declaration . . . . . . .8.2.2 Using a class . . . . . . . . . . . . .8.2.3 Passing objects between functions .8.2.4 How have classes helped? . . . . . .Adding functions to classes . . . . . . . .8.3.1 Using const on member functions .A financial example . . . . . . . . . . . .8.4.1 What have we gained? . . . . . . .Recommendations on writing classes . . .Encapsulation . . . . . . . . . . . . . . . .8.6.1 Implementing PieChart . . . . . . .8.6.2 Using PieChart . . . . . . . . . . .Constructors . . . . . . . . . . . . . . . .8.7.1 Writing a default constructor . . .8.7.2 An alternative, and superior syntaxConstructors with parameters . . . . . . .Summary . . . . . . . . . . . . . . . . . .9 Monte Carlo Pricing in C 9.19.29.39.4145A function to simulate stock prices . . . . . .Writing a Monte Carlo pricer . . . . . . . . .Generating random numbers for Monte CarloSummary . . . . . . . . . . . . . . . . . . . .10 Interfaces10.110.210.310.410.510.610.7An interface for pricing options . . . . . .Describing an interface in C . . . . . .Examples of interfaces . . . . . . . . . . .Interfaces in object-oriented programmingWhat’s wrong with if statements? . . . .An interface for integration . . . . . . . .Summary . . . . . . . . . . . . . . . . . .11.311.4Arrays, the C alternative to vectorPointers . . . . . . . . . . . . . . .11.2.1 new and delete . . . . . . .11.2.2 Pointer operators . . . . . .11.2.3 Looping with pointers . . .11.2.4 Using pointers in practice .Pointers to text . . . . . . . . . . .Pass by pointer . . . . . . . . . . .146151154158159.11 Arrays, Strings, and 9180182185185187

Contents11.511.611.711.811.9Don’t return pointers to local variablesUsing pointers to share data . . . . . .11.6.1 Sharing with shared ptr . . . .Sharing data with references . . . . .The C memory model . . . . . . .11.8.1 The stack . . . . . . . . . . . .11.8.2 The heap . . . . . . . . . . . . .Summary . . . . . . . . . . . . . . . .xi.12 More Sophisticated Classes20512.112.212.3Inlining member functions . . . . . . . . . . . . . .The this keyword . . . . . . . . . . . . . . . . . .Inheritance . . . . . . . . . . . . . . . . . . . . . .12.3.1 What have we gained? . . . . . . . . . . . .12.3.2 Terminology . . . . . . . . . . . . . . . . . .12.4 Overriding methods — the virtual keyword . . .12.4.1 A note on the keyword virtual . . . . . . .12.5 Abstract functions 0 . . . . . . . . . . . . . . . .12.6 Multiple layers . . . . . . . . . . . . . . . . . . . .12.6.1 UML . . . . . . . . . . . . . . . . . . . . . .12.6.2 Another object hierarchy . . . . . . . . . . .12.6.3 Multiple inheritance . . . . . . . . . . . . .12.6.4 Calling superclass methods . . . . . . . . . .12.7 Forward declarations and the structure of cpp files12.8 The static keyword . . . . . . . . . . . . . . . . .12.9 The protected keyword . . . . . . . . . . . . . . .12.10 Summary . . . . . . . . . . . . . . . . . . . . . . .13 The Portfolio Class13.113.213.313.413.513.6The Priceable interface . . . . . . . . . . . .The Portfolio interface and implementation13.2.1 Implementation of PortfolioImpl . .Testing . . . . . . . . . . . . . . . . . . . . .UML . . . . . . . . . . . . . . . . . . . . . . .Limitations . . . . . . . . . . . . . . . . . . .Summary . . . . . . . . . . . . . . . . . . . .Discrete-time delta hedging . . . . . . . .Implementing the delta hedging strategy in14.2.1 Class declaration . . . . . . . . . .14.2.2 Implementation of 16217218220222223.14 Delta 8230231232233. . . .C . . . . . . .233235235237

xiiContents14.314.414.514.2.3 Implementing the other methods of HedgingSimulator14.2.4 Changes to CallOption . . . . . . . . . . . . . . . .Testing the simulation . . . . . . . . . . . . . . . . . . . . .Interpreting and extending our simulation . . . . . . . . . .Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . .15 Debugging and Development Tools15.115.215.315.415.5245Debugging strategies . . . . . . . . . . . . . . . . . . . .15.1.1 Unit tests . . . . . . . . . . . . . . . . . . . . . .15.1.2 Reading your code . . . . . . . . . . . . . . . . .15.1.3 Logging statements . . . . . . . . . . . . . . . . .15.1.4 Using a debugger . . . . . . . . . . . . . . . . . .15.1.5 Divide and conquer . . . . . . . . . . . . . . . . .Debugging with Visual Studio . . . . . . . . . . . . . . .15.2.1 Obtaining a stack trace in Visual Studio . . . . .15.2.2 Breakpoints and single stepping in Visual StudioDebugging with GDB . . . . . . . . . . . . . . . . . . .15.3.1 Using GDB to obtain a stack trace . . . . . . . .15.3.2 Breakpoints and single stepping with GDB . . . .15.3.3 Other commands and features . . . . . . . . . . .Other development tools and practices . . . . . . . . . .15.4.1 Version control . . . . . . . . . . . . . . . . . . .15.4.2 Bug tracking . . . . . . . . . . . . . . . . . . . . .15.4.3 Testing framework . . . . . . . . . . . . . . . . .15.4.4 Automated build . . . . . . . . . . . . . . . . . .15.4.5 Continuous integration . . . . . . . . . . . . . . .15.4.6 Logging . . . . . . . . . . . . . . . . . . . . . . .15.4.7 Static analysis . . . . . . . . . . . . . . . . . . . .15.4.8 Memory-leak detection . . . . . . . . . . . . . . .15.4.9 Profiling tools . . . . . . . . . . . . . . . . . . . .15.4.10 Example . . . . . . . . . . . . . . . . . . . . . . .Summary . . . . . . . . . . . . . . . . . . . . . . . . . .16 A Matrix Class16.116.216.316.4Basic functionality of Matrix . . . . . . . . .The constructor and destructor of Matrix . .16.2.1 Virtual destructors . . . . . . . . . . .16.2.2 When is a destructor needed? . . . . .16.2.3 Additional constructors . . . . . . . . .Const pointers . . . . . . . . . . . . . . . . .Operator overloading . . . . . . . . . . . . . .16.4.1 Overloading . . . . . . . . . . . . . .16.4.2 Overloading other arithmetic 67.267269271272273274275275277

Contents16.516.616.716.8xiii16.4.3 Overloading comparison operators . . . . . . . .16.4.4 Overloading the operator . . . . . . . . . . .16.4.4.1 Remarks on return by reference . . . .16.4.5 Overloading the () operator . . . . . . . . . . .16.4.6 Overloading . . . . . . . . . . . . . . . . . .The rule of three . . . . . . . . . . . . . . . . . . . . .16.5.1 Overriding the assignment operator . . . . . . .16.5.2 Writing a copy constructor . . . . . . . . . . . .16.5.3 The easy way to abide by the rule of three . . .16.5.4 Move operators . . . . . . . . . . . . . . . . . .Completing the Matrix class . . . . . . . . . . . . . . .Array Programming . . . . . . . . . . . . . . . . . . .16.7.1 Implementing an efficient matrix class . . . . .16.7.2 Array programming . . . . . . . . . . . . . . . .16.7.3 Array programming in the option classes . . . .16.7.4 Array programming for the BlackScholesModel16.7.5 Array programming the Monte Carlo pricer . .16.7.6 Performance . . . . . . . . . . . . . . . . . . . .Summary . . . . . . . . . . . . . . . . . . . . . . . . .17 An Overview of Templates17.117.217.317.4Template functions . . . . . .Template classes . . . . . . .Templates as an alternative toSummary . . . . . . . . . . .295. . . . . . . . . . .interfaces. . . . . .18 The Standard Template 86287288289290290292typedef . . . . . . . . . . . . . . . . . . . . . .auto . . . . . . . . . . . . . . . . . . . . . . . .Using iterators with vectors . . . . . . . . . . .for loops and containers . . . . . . . . . . . . .The container set . . . . . . . . . . . . . . . .The container vector . . . . . . . . . . . . . .The container list . . . . . . . . . . . . . . . .The container initializer list . . . . . . .The containers map and unordered map . . . .18.9.1 How a map works . . . . . . . . . . . . .18.9.2 How an unordered map works . . . . . .Storing complex types in containers . . . . . .A mathematical model for multiple stocks . . .Using the Standard Template Library in FMLibSummary . . . . . . . . . . . . . . . . . . . . .295297299302303. .304306307309310311312315315317318320320322327

xivContents19 Function Objects and Lambda Functions19.119.219.319.419.5Function objects . . . . . . .Lambda functions . . . . . .Function pointers . . . . . . .Sorting with lambda functionsSummary . . . . . . . . . . . . . . . . . . . . . . . . .329.20 Threads20.120.220.320.420.5337Concurrent programming in C . . . . . . . . . . . .20.1.1 Creating threads . . . . . . . . . . . . . . . . . .20.1.2 Mutual exclusion . . . . . . . . . . . . . . . . . .20.1.3 Global variables and race conditions . . . . . . .20.1.4 Problems with locking . . . . . . . . . . . . . . .The command design pattern . . . . . . . . . . . . . . .Monte Carlo pricing . . . . . . . . . . . . . . . . . . . .20.3.1 Random number generation with multiple threads20.3.2 A multi-threaded pricer . . . . . . . . . . . . . .20.3.3 Implementing Task . . . . . . . . . . . . . . . . .20.3.4 Using the Executor . . . . . . . . . . . . . . . . .20.3.5 Remarks upon the design . . . . . . . . . . . . . .Coordinating threads . . . . . . . . . . . . . . . . . . . .20.4.1 The Pipeline pattern . . . . . . . . . . . . . . . .20.4.2 How Pipeline is implemented . . . . . . . . . . .Summary . . . . . . . . . . . . . . . . . . . . . . . . . .21 Next Steps21.121.2Programming . . . . . . . . .21.1.1 Libraries . . . . . . . .21.1.2 Software development .21.1.3 C language features21.1.4 Other languages . . . .Financial mathematics . . . .The players in financialDerivatives contracts .Risk-neutral pricing .Modelling stock pricesMonte Carlo pricing .Hedging . . . . . . . .Summary . . . . . . 59.A Risk-Neutral 59360360361363markets. . . . . . . . . . . . . . . . . . . . . . . . .363366370372377379382

ContentsxvBibliography383Index385

IntroductionThe aim of this book is teach you C from scratch using examples fromfinancial mathematics. It is a streamlined account of the features of C that are most useful to a financial mathematician.Throughout the book we will focus on a key recurring example: How doyou price a portfolio of financial derivatives? We will use this example to show How to use C language in practice What kinds of problems banks face The skills you need to solve themThese skills include C programming skills and mathematical skills but alsoinclude testing, debugging, design, and software architecture.The financial mathematics knowledge needed for this book has been keptto a minimum and is summarised in Appendix A.Why should you learn C ?There are many jobs in the finance industry which require sophisticatedmathematical skills. One of those roles is being a “quant developer”. A quantdeveloper’s task is to implement the ideas of financial mathematics in practiceto produce practical systems to price, trade, and risk manage complex financialproducts. This book is aimed at people who already know the mathematicsand want to learn the programming skills of a quant developer.C is a programming language. It is just one of many languages that canbe used for performing financial calculations. When banks began to developtheir trading and risk management platforms, many of them decided that theywould write them in C . As a result, C is one of the most sought-afterprogramming skills for quant-developer jobs.However, it would be wrong to say that C is the only programminglanguage worth knowing if you want to be a quant developer. Languages suchas C#, Java, MATLAB , and Python are all heavily used in the financialindustry. For someone new to programming, the biggest practical differencebetween C and these other languages is that C is much harder to learn!xvii

xviiiIntroductionBut as a result, C skills are also particularly highly valued. Moreover, onceyou know C you will find any of these other languages easy to learn.In summary, C is the language to learn if you want to open up themaximum number of employment possibilities in quant-developer roles. Ofcourse, this probably won’t be true forever as technologies do change. Sobefore buying this book, have a search online for your dream job. If C isone of the skills required, read on.Pricing a portfolioThis book will focus throughout on financial examples. As we introducefeatures of C we will show how they can be used to solve real financialproblems. Indeed, we will focus on a single important financial problem: Howdo you compute the price and risk of a portfolio of complex financial products?This is just a simplified version of the real problem faced by a bank of valuingand measuring the risk of their entire position.It is important to see just how complex this question really is. So let usexamine it in more detail.Any major bank will trade on many different exchanges. Famous examples include the New York Stock Exchange and the London Stock Exchange.However, there are many other less-famous exchanges in cities throughout theworld.Each stock exchange has its own trading rules. Obviously there is someattempt to rationalise things on national and international bases, but contractsand conventions can, and do, vary from market to market.Of course, one doesn’t just trade in stocks. One can also trade in stockderivatives, currencies, currency derivatives, government bonds, municipalbonds, commodities, electricity, etc.Now let us return again to the problem of calculating the current value of abank’s overall position and the riskiness of that position. Given the complexityof a bank’s total position, and the total amount of detail in all the contractsthey have entered into, one sees that this is a daunting task. No individual isever likely to understand every detail of the calculation.Problem 1. How do you write software so that no individual has to understand everything that is going on?Problem 2. How do you write software so that a team of hundreds can workon the software at the same time without getting in a mess?Problem 3. How do you write code that is easy for others to understand?Another important consideration is that the results of a computer error in financial applications can be catastrophic. If Adobe Acrobat crashes,

Introductionxixyou might swear under your breath. When Barclay’s cash machine networkcrashed, it was headline news in the UK. If your trading algorithm throwsaway half a billion dollars, it is unlikely that you will get as large a bonus asyou were hoping for.Problem 4. How do you write code that doesn’t contain bugs? How do youensure that there are no bugs in the code written by a team of hundreds?Problem 5. Given that you probably can’t guarantee that there are no bugs,how do you ensure that the effects of a bug are not too harmful?Every day, new financial products are invented and creative new financialcontracts are devised and sold. It must be possible to rapidly update thesoftware used by a bank to reflect these new contracts. While Microsoft onlyreleases a new version of its operating system periodically, banks update theirsoftware on an almost daily basis.Problem 6. How do you write code that can be extended easily and rapidly?Problem 7. How do you ensure that no bugs have crept into the latest versionof your code, given that you plan to release a new version almost daily?Problem 8. How do you release new code, when all the software has to keeprunning 24 7?If a bank is doing well, their business should be expanding. The bank willbe moving into new markets and the data volumes in existing markets will begrowing exponentially. Nobody wants investments that have sub-exponentialgrowth!Problem 9. How can you ensure that your software will continue to workwith exponentially increasing data volumes?We can broadly categorise all of these problems as problems of scalabilityand maintainability. These problems are the biggest IT problems that banksface. It is these problems that explain why such a large proportion of theemployees in the finance sector in fact work in IT rather than finance. Andit is problems of this sort that object-oriented programming was designed toaddress.In this book we will show you how to use the object-oriented features ofC to solve these problems. In addition we will show you how to use otherimportant programming techniques such as testing, debugging, and design, allof which are essential to building complex financial software.Why do banks use C ?We have already discussed why you should learn C . In case you’veforgotten, it is to get a job in finance. But why do banks choose to use C ?

xxIntroductionBack in 1969, development had started on the computer language C. Itquickly caught on because it allows you to write very

Financial Mathematics Series Aims and scope: The field of financial mathematics forms an ever-expanding slice of the financial sector. This series aims to capture new developments and summarize what is known over the whole spectrum of this field. It will include a broad range of textbooks, reference works and handbooks that are meant to