Details

C# for Financial Markets


C# for Financial Markets


The Wiley Finance Series 1. Aufl.

von: Daniel J. Duffy, Andrea Germani

65,99 €

Verlag: Wiley
Format: PDF
Veröffentl.: 27.12.2012
ISBN/EAN: 9781118502815
Sprache: englisch
Anzahl Seiten: 864

DRM-geschütztes eBook, Sie benötigen z.B. Adobe Digital Editions und eine Adobe ID zum Lesen.

Beschreibungen

<p><b>A practice-oriented guide to using C# to design and program pricing and trading models</b></p> <p>In this step-by-step guide to software development for financial analysts, traders, developers and quants, the authors show both novice and experienced practitioners how to develop robust and accurate pricing models and employ them in real environments. Traders will learn how to design and implement applications for curve and surface modeling, fixed income products, hedging strategies, plain and exotic option modeling, interest rate options, structured bonds, unfunded structured products, and more. A unique mix of modern software technology and quantitative finance, this book is both timely and practical. The approach is thorough and comprehensive and the authors use a combination of C# language features, design patterns, mathematics and finance to produce efficient and maintainable software.</p> <p>Designed for quant developers, traders and MSc/MFE students, each chapter has numerous exercises and the book is accompanied by a dedicated companion website, <i>www.datasimfinancial.com/forum/viewforum.php?f=196&sid=f30022095850dee48c7db5ff62192b34</i>, providing all source code, alongside audio, support and discussion forums for readers to comment on the code and obtain new versions of the software.</p>
<p>List of Figures xix</p> <p>List of Tables xxiii</p> <p><b>Introduction 1</b></p> <p>0.1 What is This Book? 1</p> <p>0.2 Special Features in This Book 1</p> <p>0.3 Who is This Book for and What Do You Learn? 2</p> <p>0.4 Structure of This Book 2</p> <p>0.5 C# Source Code 3</p> <p><b>1 Global Overview of the Book 5</b></p> <p>1.1 Introduction and Objectives 5</p> <p>1.2 Comparing C# and C++ 5</p> <p>1.3 Using This Book 6</p> <p><b>2 C# Fundamentals 9</b></p> <p>2.1 Introduction and Objectives 9</p> <p>2.2 Background to C# 9</p> <p>2.3 Value Types, Reference Types and Memory Management 10</p> <p>2.4 Built-in Data Types in C# 10</p> <p>2.5 Character and String Types 12</p> <p>2.6 Operators 13</p> <p>2.7 Console Input and Output 14</p> <p>2.8 User-defined Structs 15</p> <p>2.9 Mini Application: Option Pricing 16</p> <p>2.10 Summary and Conclusions 21</p> <p>2.11 Exercises and Projects 22</p> <p><b>3 Classes in C# 25</b></p> <p>3.1 Introduction and Objectives 25</p> <p>3.2 The Structure of a Class: Methods and Data 25</p> <p>3.3 The Keyword ‘this’ 28</p> <p>3.4 Properties 28</p> <p>3.5 Class Variables and Class Methods 30</p> <p>3.6 Creating and Using Objects in C# 33</p> <p>3.7 Example: European Option Price and Sensitivities 33</p> <p>3.7.1 Supporting Mathematical Functions 34</p> <p>3.7.2 Black-Scholes Formula 35</p> <p>3.7.3 C# Implementation 36</p> <p>3.7.4 Examples and Applications 39</p> <p>3.8 Enumeration Types 40</p> <p>3.9 Extension Methods 42</p> <p>3.10 An Introduction to Inheritance in C# 44</p> <p>3.11 Example: Two-factor Payoff Hierarchies and Interfaces 46</p> <p>3.12 Exception Handling 50</p> <p>3.13 Summary and Conclusions 50</p> <p>3.14 Exercises and Projects 51</p> <p><b>4 Classes and C# Advanced Features 53</b></p> <p>4.1 Introduction and Objectives 53</p> <p>4.2 Interfaces 53</p> <p>4.3 Using Interfaces: Vasicek and Cox-Ingersoll-Ross (CIR) Bond and Option Pricing 54</p> <p>4.3.1 Defining Standard Interfaces 55</p> <p>4.3.2 Bond Models and Stochastic Differential Equations 55</p> <p>4.3.3 Option Pricing and the <i>Visitor </i>Pattern 58</p> <p>4.4 Interfaces in .NET and Some Advanced Features 61</p> <p>4.4.1 Copying Objects 62</p> <p>4.4.2 Interfaces and Properties 63</p> <p>4.4.3 Comparing Abstract Classes and Interfaces 64</p> <p>4.4.4 Explicit Interfaces 65</p> <p>4.4.5 Casting an Object to an Interface 65</p> <p>4.5 Combining Interfaces, Inheritance and Composition 67</p> <p>4.5.1 Design Philosophy: Modular Programming 67</p> <p>4.5.2 A Model Problem and Interfacing 68</p> <p>4.5.3 Implementing the Interfaces 69</p> <p>4.5.4 Examples and Testing 72</p> <p>4.6 Introduction to Delegates and Lambda Functions 72</p> <p>4.6.1 Comparing Delegates and Interfaces 74</p> <p>4.7 Lambda Functions and Anonymous Methods 76</p> <p>4.8 Other Features in C# 77</p> <p>4.8.1 Static Constructors 77</p> <p>4.8.2 Finalisers 78</p> <p>4.8.3 Casting 79</p> <p>4.8.4 The var Keyword 80</p> <p>4.9 Advanced .NET Delegates 80</p> <p>4.9.1 <i>Provides </i>and <i>Requires </i>Interfaces: Creating Plug-in Methods with Delegates 82</p> <p>4.9.2 Multicast Delegates 85</p> <p>4.9.3 Generic Delegate Types 86</p> <p>4.9.4 Delegates versus Interfaces, Again 87</p> <p>4.10 The Standard Event Pattern in .NET and the Observer Pattern 87</p> <p>4.11 Summary and Conclusions 91</p> <p>4.12 Exercises and Projects 92</p> <p><b>5 Data Structures and Collections 97</b></p> <p>5.1 Introduction and Objectives 97</p> <p>5.2 Arrays 97</p> <p>5.2.1 Rectangular and Jagged Arrays 98</p> <p>5.2.2 Bounds Checking 101</p> <p>5.3 Dates, Times and Time Zones 101</p> <p>5.3.1 Creating and Modifying Dates 101</p> <p>5.3.2 Formatting and Parsing Dates 103</p> <p>5.3.3 Working with Dates 104</p> <p>5.4 Enumeration and Iterators 105</p> <p>5.5 Object-based Collections and Standard Collection Interfaces 107</p> <p>5.6 The List<T> Class 109</p> <p>5.7 The Hashtable<T> Class 110</p> <p>5.8 The Dictionary<Key, Value> Class 111</p> <p>5.9 The HashSet<T> Classes 112</p> <p>5.10 BitArray: Dynamically Sized Boolean Lists 114</p> <p>5.11 Other Data Structures 114</p> <p>5.11.1 Stack<T> 114</p> <p>5.11.2 Queue<T> 115</p> <p>5.11.3 Sorted Dictionaries 116</p> <p>5.12 Strings and StringBuilder 117</p> <p>5.12.1 Methods in string 118</p> <p>5.12.2 Manipulating Strings 119</p> <p>5.13 Some new Features in .NET 4.0 120</p> <p>5.13.1 Optional Parameters 120</p> <p>5.13.2 Named Parameters 121</p> <p>5.13.3 COM Interoperability in .NET 4.0 121</p> <p>5.13.4 Dynamic Binding 122</p> <p>5.14 Summary and Conclusions 123</p> <p>5.15 Exercises and Projects 123</p> <p><b>6 Creating User-defined Data Structures 125</b></p> <p>6.1 Introduction and Objectives 125</p> <p>6.2 Design Rationale and General Guidelines 125</p> <p>6.2.1 An Introduction to C# Generics 125</p> <p>6.2.2 Generic Methods and Generic Delegates 128</p> <p>6.2.3 Generic Constraints 129</p> <p>6.2.4 Generics, Interfaces and Inheritance 130</p> <p>6.2.5 Other Remarks 130</p> <p>6.3 Arrays and Matrices 131</p> <p>6.4 Vectors and Numeric Matrices 135</p> <p>6.5 Higher-dimensional Structures 139</p> <p>6.6 Sets 140</p> <p>6.7 Associative Arrays and Matrices 142</p> <p>6.7.1 Associative Arrays 142</p> <p>6.7.2 Associative Matrices 144</p> <p>6.8 Standardisation: Interfaces and Constraints 145</p> <p>6.9 Using Associative Arrays and Matrices to Model Lookup Tables 152</p> <p>6.10 Tuples 155</p> <p>6.11 Summary and Conclusions 156</p> <p>6.12 Exercises and Projects 156</p> <p><b>7 An Introduction to Bonds and Bond Pricing 159</b></p> <p>7.1 Introduction and Objectives 159</p> <p>7.2 Embedded Optionality 160</p> <p>7.3 The Time Value of Money: Fundamentals 160</p> <p>7.3.1 A Simple Bond Class 164</p> <p>7.3.2 Testing the Bond Functionality 165</p> <p>7.4 Measuring Yield 166</p> <p>7.5 Macauley Duration and Convexity 167</p> <p>7.6 Dates and Date Schedulers for Fixed Income Applications 168</p> <p>7.6.1 Accrued Interest Calculations and Day Count Conventions 169</p> <p>7.6.2 C# Classes for Dates 170</p> <p>7.6.3 DateSchedule Class 174</p> <p>7.7 Exporting Schedulers to Excel 176</p> <p>7.8 Other Examples 177</p> <p>7.9 Pricing Bonds: An Extended Design 178</p> <p>7.10 Summary and Conclusions 181</p> <p>7.10.1 Appendix: Risks Associated with Bonds 181</p> <p>7.11 Exercises and Projects 181</p> <p><b>8 Data Management and Data Lifecycle 185</b></p> <p>8.1 Introduction and Objectives 185</p> <p>8.2 Data Lifecycle in Trading Applications 185</p> <p>8.2.1 Configuration Data and Calculated Data 186</p> <p>8.2.2 Which Kinds of Data Storage Devices Can We Use? 186</p> <p>8.3 An Introduction to Streams and I/O 186</p> <p>8.3.1 Stream Architecture 186</p> <p>8.3.2 Backing Store Streams Functionality 187</p> <p>8.3.3 Stream Decorators 189</p> <p>8.3.4 Stream Adapters 191</p> <p>8.4 File and Directory Classes 195</p> <p>8.4.1 The Class Hierarchy 196</p> <p>8.4.2 FileInfo and DirectoryInfo Classes 198</p> <p>8.5 Serialisation Engines in .NET 199</p> <p>8.5.1 DataContractSerializer 199</p> <p>8.5.2 NetDataContractSerializer 201</p> <p>8.5.3 Formatters 201</p> <p>8.5.4 Implicit and Explicit Serialisation 203</p> <p>8.6 The Binary Serialiser 203</p> <p>8.7 XML Serialisation 204</p> <p>8.7.1 Subclasses and Child Objects 205</p> <p>8.7.2 Serialisation of Collections 206</p> <p>8.7.3 The IXmlSerializable Interface 207</p> <p>8.8 Data Lifetime Management in Financial and Trading Applications 209</p> <p>8.9 Summary and Conclusions 213</p> <p>8.10 Exercises and Projects 213</p> <p><b>9 Binomial Method, Design Patterns and Excel Output 215</b></p> <p>9.1 Introduction and Objectives 215</p> <p>9.2 Design of Binomial Method 216</p> <p>9.3 Design Patterns and Classes 217</p> <p>9.3.1 Creating Input Data: Factory Method Pattern 217</p> <p>9.3.2 Binomial Parameters and the <i>Strategy </i>Pattern 219</p> <p>9.3.3 The Complete Application Object and the Mediator Pattern 228</p> <p>9.3.4 Lattice Presentation in Excel 230</p> <p>9.4 Early Exercise Features 232</p> <p>9.5 Computing Hedge Sensitivities 233</p> <p>9.6 Multi-dimensional Binomial Method 233</p> <p>9.7 Improving Performance Using Pad´e Rational Approximants 236</p> <p>9.8 Summary and Conclusions 238</p> <p>9.9 Projects and Exercises 238</p> <p><b>10 Advanced Lattices and Finite Difference Methods 241</b></p> <p>10.1 Introduction and Objectives 241</p> <p>10.2 Trinomial Model of the Asset Price and Its C# Implementation 241</p> <p>10.3 Stability and Convergence of the Trinomial Method 246</p> <p>10.4 The Black-Scholes Partial Differential Equation and Explicit Schemes 246</p> <p>10.5 Implementing Explicit Schemes in C# 247</p> <p>10.5.1 Using the Explicit Finite Difference Method 251</p> <p>10.6 Stability of the Explicit Finite Difference Scheme 252</p> <p>10.7 An Introduction to the Alternating Direction Explicit Method (ADE) 255</p> <p>10.7.1 ADE in a Nutshell: The One-factor Diffusion Equation 255</p> <p>10.7.2 ADE for Equity Pricing Problems 256</p> <p>10.8 Implementing ADE for the Black-Scholes PDE 258</p> <p>10.9 Testing the ADE Method 262</p> <p>10.10 Advantages of the ADE Method 263</p> <p>10.11 Summary and Conclusions 263</p> <p>10.12 Appendix: ADE Numerical Experiments 263</p> <p>10.13 Exercises and Projects 268</p> <p><b>11 Interoperability: Namespaces, Assemblies and C++/CLI 271</b></p> <p>11.1 Introduction and Objectives 271</p> <p>11.2 Namespaces 271</p> <p>11.2.1 Applications of Namespaces 272</p> <p>11.3 An Introduction to Assemblies 273</p> <p>11.3.1 Assembly Types 274</p> <p>11.3.2 Specifying Assembly Attributes in AssemblyInfo.cs 275</p> <p>11.3.3 The Relationship between Namespaces and Assemblies 276</p> <p>11.4 Reflection and Metadata 276</p> <p>11.4.1 Other Classes in the Reflection Namespace 281</p> <p>11.4.2 Dynamic Method Invocation 283</p> <p>11.4.3 Dynamic Object Creation 283</p> <p>11.4.4 Dynamic Assembly Loading 284</p> <p>11.4.5 Attributes and Reflection 284</p> <p>11.4.6 Custom Attributes 286</p> <p>11.5 C# and Native C++ Interoperability: How is That Possible? 289</p> <p>11.5.1 Using Native C++ from C# 289</p> <p>11.6 Using C# from C++ 293</p> <p>11.7 Code Generation Using the Reflection API 298</p> <p>11.7.1 The DynamicMethod Class 299</p> <p>11.7.2 The Evaluation Stack and Argument Passing to Dynamic Methods 300</p> <p>11.7.3 The Case in Hand: Operator Overloading for Generic Vectors and Matrices 301</p> <p>11.8 Application Domains 304</p> <p>11.8.1 Creating and Destroying Application Domains 304</p> <p>11.8.2 Multiple Application Domains 305</p> <p>11.8.3 Sharing Data between Domains 307</p> <p>11.8.4 When to Use Application Domains 308</p> <p>11.9 Summary and Conclusions 309</p> <p>11.10 Exercises and Projects 309</p> <p><b>12 Bond Pricing: Design, Implementation and Excel Interfacing 311</b></p> <p>12.1 Introduction and Objectives 311</p> <p>12.2 High-level Design of Bond Pricing Problem 311</p> <p>12.3 Bond Scheduling 312</p> <p>12.4 Bond Functionality and Class Hierarchies 313</p> <p>12.5 Calculating Price, Yield and Discount Factors: MathTools 317</p> <p>12.6 Data Presentation and Excel Interop 319</p> <p>12.7 Bond Data Management 321</p> <p>12.7.1 Data into Memory 321</p> <p>12.7.2 Serialisation and Deserialisation 322</p> <p>12.8 Using the Excel Files 324</p> <p>12.9 Summary and Conclusions 328</p> <p>12.10 Exercises and Projects 328</p> <p>1 Code Integration: Handling Bond Details 328</p> <p>2 Spread on Benchmark 330</p> <p>3 Floating Rate Bond and Other Structured Notes 331</p> <p>4 Class Hierarchy Integration 333</p> <p><b>13 Interpolation Methods in Interest Rate Applications 335</b></p> <p>13.1 Introduction and Objectives 335</p> <p>13.2 Interpolation and Curve Building: Basic Formula for Interpolator Tests 335</p> <p>13.3 Types of Curve Shape 337</p> <p>13.4 An Overview of Interpolators 338</p> <p>13.5 Background to Interpolation 339</p> <p>13.6 Approximation of Function Derivatives 341</p> <p>13.7 Linear and Cubic Spline Interpolation 342</p> <p>13.8 Positivity-preserving Cubic Interpolations: Dougherty/Hyman and Hussein 344</p> <p>13.9 The Akima Method 348</p> <p>13.10 Hagan-West Approach 349</p> <p>13.11 Global Interpolation 350</p> <p>13.11.1 Polynomial Interpolation 351</p> <p>13.11.2 Rational Interpolation 352</p> <p>13.12 Bilinear Interpolation 352</p> <p>13.13 Some General Guidelines, Hints and Tips 355</p> <p>13.14 Using the Interpolators and Test Examples 357</p> <p>13.14.1 The 101 Example, from A to Z 357</p> <p>13.14.2 Some Financial Formulae 360</p> <p>13.14.3 Cubic Spline Interpolation: an Application Example 361</p> <p>13.14.4 A Bilinear Interpolation Simple Example 364</p> <p>13.15 Summary and Conclusions 367</p> <p>13.16 Exercises and Projects 367</p> <p><b>14 Short Term Interest Rate (STIR) Futures and Options 369</b></p> <p>14.1 Introduction and Objectives 369</p> <p>14.2 An Overview of Cash Money Markets 370</p> <p>14.3 Sources of Risk in Money Market Transactions 370</p> <p>14.4 Reference Rate and Fixings 371</p> <p>14.5 STIR Futures 371</p> <p>14.6 Pricing STIR Options 374</p> <p>14.7 Generating International Monetary Market (IMM) Dates 378</p> <p>14.7.1 Modelling Option Delta and Sensitivity Analysis 380</p> <p>14.7.2 Listed Instruments and Contracts 383</p> <p>14.8 List STIR Futures and STIR Futures Options 384</p> <p>14.9 Putting It All Together: STIR versus OTC from a Trader’s Perspective 387</p> <p>14.10 Summary and Conclusions 389</p> <p>14.11 Exercises and Projects 389</p> <p><b>15 Single-curve Building 393</b></p> <p>15.1 Introduction and Objectives 393</p> <p>15.2 Starting Definitions and Overview of Curve Building Process 393</p> <p>15.3 Building Blocks 395</p> <p>15.3.1 Unsecured Deposit 395</p> <p>15.3.2 Forward Rate Agreements (FRA) 396</p> <p>15.3.3 Future Implied Rate 397</p> <p>15.3.4 Interest Rate Swap (IRS) 397</p> <p>15.4 Introduction to Interest Rate Swap 397</p> <p>15.4.1 IRS Cash Flow 398</p> <p>15.4.2 The Use of Interest Rate Swaps 399</p> <p>15.4.3 Contract Specification and Practical Aspects 399</p> <p>15.4.4 Traditional Swap Valuation 402</p> <p>15.4.5 Overnight Index Swap (OIS) 403</p> <p>15.5 The Curve Construction Mechanism 403</p> <p>15.5.1 Traditional Bootstrapping Method 404</p> <p>15.5.2 Best Fit Method 405</p> <p>15.5.3 The Key Role of Interpolation 405</p> <p>15.6 Code Design and Implementation 406</p> <p>15.6.1 Process Design 406</p> <p>15.6.2 ISingleRateCurve Interface 406</p> <p>15.6.3 RateSet Class and BuildingBlock Class 407</p> <p>15.6.4 Interpolator and Adapters 409</p> <p>15.6.5 The Generic Base Class SingleCurveBuilder 410</p> <p>15.6.6 Derived Class for Traditional Bootstrapping Method 412</p> <p>15.6.7 Derived Class for Global Method with Interpolation 413</p> <p>15.6.8 Derived Class for Global Method with Smoothness Condition 415</p> <p>15.7 Console Examples 418</p> <p>15.7.1 Calculating Present Value (PV) of the Floating Leg of a Swap 418</p> <p>15.7.2 Checking If the Curve is Calibrated 418</p> <p>15.7.3 Calculate the Time Taken to Instantiate a SingleCurveBuilder 418</p> <p>15.7.4 Visualise Forward Rates in Excel 419</p> <p>15.7.5 Computing Forward Start Swap 421</p> <p>15.7.6 Computing Sensitivities: An Initial Example 421</p> <p>15.7.7 More on Sensitivities 422</p> <p>15.8 Summary and Conclusions 426</p> <p>15.9 Exercises and Projects 427</p> <p>15.10 Appendix: Types of Swaps 429</p> <p><b>16 Multi-curve Building 431</b></p> <p>16.1 Introduction and Objectives 431</p> <p>16.2 The Consequences of the Crisis on Interest Rate Derivatives Valuation 431</p> <p>16.2.1 The Growing Importance of Overnight Indexed Swap 432</p> <p>16.2.2 Collateralisation under a CSA 432</p> <p>16.2.3 The Role of OIS Discounting: One Curve is Not Enough 433</p> <p>16.2.4 Basis 433</p> <p>16.2.5 The Par Swap Rate Formulae 434</p> <p>16.3 Impact of Using OIS Discounting 436</p> <p>16.3.1 Effect on Forward Rates 436</p> <p>16.3.2 Effect on Mark-to-Market 436</p> <p>16.3.3 Risk Effect 436</p> <p>16.4 The Bootstrapping Process Using Two Curves: Description of the Mechanism 437</p> <p>16.5 Sensitivities 438</p> <p>16.6 How to Organise the Code: A Possible Solution 439</p> <p>16.6.1 IRateCurve Base Interface and Derived Interfaces 439</p> <p>16.6.2 The class MultiCurveBuilder 441</p> <p>16.7 Putting it Together, Working Examples 445</p> <p>16.7.1 Calibration Consistency 445</p> <p>16.7.2 Print Forward Rates and Discount Factors on Excel 446</p> <p>16.7.3 Sensitivities on Console 446</p> <p>16.7.4 Forward Swap Matrix 447</p> <p>16.7.5 Mark-to-Market Differences 448</p> <p>16.7.6 Comparing Two Versions of the MultiCurveBuilder 450</p> <p>16.7.7 Input Data, Interpolation and Forward Rates 452</p> <p>16.7.8 Comparing Discount Factor 453</p> <p>16.8 Summary and Conclusions 453</p> <p>16.9 Exercises and Projects 453</p> <p>16.10 Appendix: Par Asset Swap Spread and Zero Volatility Spread 455</p> <p><b>17 Swaption, Cap and Floor 459</b></p> <p>17.1 Introduction and Objectives: A Closed Formula World 459</p> <p>17.2 Description of Instruments and Formulae 459</p> <p>17.2.1 Cap and Floor: Description and Formulae 459</p> <p>17.2.2 Cap and Floor <i>at the money </i>Strike 461</p> <p>17.2.3 Cap Volatility and Caplet Volatility 462</p> <p>17.2.4 Implied Volatility 463</p> <p>17.2.5 Multi-strike and Amortising Cap and Floor 463</p> <p>17.2.6 Swaption: Mechanism and Closed Pricing Formulae 464</p> <p>17.2.7 Call Put Parity for Cap, Floor and Swaption 466</p> <p>17.3 Multi-curve Framework on Cap, Floor and Swaption 467</p> <p>17.4 Bootstrapping Volatility for Cap and Floor 469</p> <p>17.4.1 Cap Stripping 469</p> <p>17.4.2 Missing Data, Volatility Models and Interpolation 473</p> <p>17.5 How to Organise the Code in C#: A Possible Solution 474</p> <p>17.5.1 Ready to Use Formula 474</p> <p>17.5.2 Cap Stripping Code 476</p> <p>17.5.3 Calculating Mono-strike Caplet Volatilities 476</p> <p>17.5.4 Managing More Mono-strike Caplet Volatilities 479</p> <p>17.6 Console and Excel Working Examples 481</p> <p>17.6.1 Simple Caplet Price 481</p> <p>17.6.2 Cap As a Sum of Caplets 482</p> <p>17.6.3 Simple Cap Volatility Bootstrapping: First Unknown Volatility 483</p> <p>17.6.4 ATM Strike and Recursive Bootstrapping 485</p> <p>17.6.5 Sparse Data from the Market: Volatility Optimisation and Input Interpolation 487</p> <p>17.7 Summary and Conclusions 490</p> <p>17.8 Exercise and Discussion 491</p> <p><b>18 Software Architectures and Patterns for Pricing Applications 493</b></p> <p>18.1 Introduction and Objectives 493</p> <p>18.2 An Overview of the GOF Pattern 494</p> <p>18.3 Creational Patterns 496</p> <p>18.4 Builder Pattern 496</p> <p>18.5 Structural Patterns 499</p> <p>18.5.1 Facade Pattern 499</p> <p>18.5.2 Layers Pattern 499</p> <p>18.6 Behavioural Patterns 500</p> <p>18.6.1 <i>Visitor </i>Pattern 501</p> <p>18.6.2 Strategy and Template Method Patterns 501</p> <p>18.7 Builder Application Example: Calibration Algorithms for Cap and Floor 502</p> <p>18.7.1 Example Caplet Volatility Matrix 502</p> <p>18.7.2 Volatility Matrix with Multiple Strikes 503</p> <p>18.8 A PDE/FDM Patterns-based Framework for Equity Options 504</p> <p>18.8.1 High-level Design 506</p> <p>18.8.2 Generalisations and Extensions 508</p> <p>18.9 Using Delegates to Implement Behavioural Design Patterns 509</p> <p>18.10 A System Design for Monte Carlo Applications 510</p> <p>18.10.1 A Universal System Design Methodology 511</p> <p>18.11 Dynamic Programming in .NET 513</p> <p>18.11.1 Numeric Type Unification 514</p> <p>18.11.2 Implementing Dynamic Objects 516</p> <p>18.12 Summary and Conclusions 516</p> <p>18.13 Exercises and Projects 517</p> <p><b>19 LINQ (Language Integrated Query) and Fixed Income Applications 523</b></p> <p>19.1 Introduction and Objectives 523</p> <p>19.2 Scope of Chapter and Prerequisites 523</p> <p>19.3 LINQ Query Operators 524</p> <p>19.3.1 Collection as Input, Collection as Output 524</p> <p>19.3.2 Collection as Input, Noncollection as Output 525</p> <p>19.3.3 Noncollection to Collection 526</p> <p>19.4 LINQ Queries and Initial Examples 526</p> <p>19.4.1 Lambda Queries and Composition 527</p> <p>19.4.2 Comprehension Queries 528</p> <p>19.4.3 Deferred Execution 529</p> <p>19.5 Advanced Queries 531</p> <p>19.5.1 Subqueries 531</p> <p>19.5.2 Composition Strategies 532</p> <p>19.5.3 Interpreted Queries 533</p> <p>19.6 A Numerical Example 533</p> <p>19.6.1 Basic Functionality 533</p> <p>19.6.2 User-defined Aggregation Methods 534</p> <p>19.6.3 Set Operations 535</p> <p>19.7 Join and GroupJoin 535</p> <p>19.8 Examples in Fixed Income Applications 540</p> <p>19.8.1 Using Conversion Operators 540</p> <p>19.8.2 Discount Factors 540</p> <p>19.8.3 Bonds 542</p> <p>19.8.4 Scenarios 543</p> <p>19.8.5 Cash Flow Aggregation 545</p> <p>19.8.6 Ordering Collections 546</p> <p>19.8.7 Eonia Rates Replication 547</p> <p>19.9 LINQ and Excel Interoperability 549</p> <p>19.9.1 Applications in Computational Finance 557</p> <p>19.10 Summary and Conclusions 557</p> <p>19.11 Exercises and Projects 557</p> <p><b>20 Introduction to C# and Excel Integration 561</b></p> <p>20.1 Introduction and Objectives 561</p> <p>20.2 Excel Object Model 561</p> <p>20.3 Using COM Technology in .NET 561</p> <p>20.4 Primary Interop Assemblies (PIA) 563</p> <p>20.5 Standalone Applications 564</p> <p>20.5.1 Standalone Application: Workbook and Worksheets 564</p> <p>20.5.2 Charts 565</p> <p>20.5.3 Using Excel with C++/CLI 565</p> <p>20.6 Types of Excel Add-ins 566</p> <p>20.6.1 XLL 567</p> <p>20.6.2 XLA 567</p> <p>20.6.3 COM 567</p> <p>20.6.4 Automation 567</p> <p>20.6.5 VSTO 568</p> <p>20.7 The IDTExtensibility2 Interface and COM/.NET Interoperability 569</p> <p>20.8 Data Visualisation in Excel 570</p> <p>20.8.1 Excel Driver 570</p> <p>20.8.2 Data Structures 572</p> <p>20.8.3 ExcelMechanisms and Exception Handling 572</p> <p>20.8.4 Examples and Applications 575</p> <p>20.9 Conclusion and Summary 578</p> <p>20.10 Exercises and Projects 579</p> <p><b>21 Excel Automation Add-ins 581</b></p> <p>21.1 Introduction and Objectives 581</p> <p>21.2 COM Overview 581</p> <p>21.3 Creating Automation Add-ins: The Steps 583</p> <p>21.4 Example: Creating a Calculator, Version 1 585</p> <p>21.5 Example: Creating a Calculator, Version 2 588</p> <p>21.6 Versioning 590</p> <p>21.7 Working with Ranges 590</p> <p>21.8 Volatile Methods 590</p> <p>21.9 Optional Parameters 591</p> <p>21.10 Using VBA with Automation Add-ins 592</p> <p>21.11 Summary and Conclusions 593</p> <p>21.12 Exercises and Projects 594</p> <p><b>22 C# and Excel Integration COM Add-ins 595</b></p> <p>22.1 Introduction and Objectives 595</p> <p>22.2 Preparations for COM Add-ins 595</p> <p>22.3 The Interface IDTExtensibility2 596</p> <p>22.4 Creating COM Add-ins: The Steps 596</p> <p>22.5 Utility Code and Classes 597</p> <p>22.6 Using Windows Forms 600</p> <p>22.7 Example: Creating a COM Add-in 601</p> <p>22.8 Debugging and Troubleshooting 603</p> <p>22.9 An Introduction to Excel-DNA 603</p> <p>22.9.1 Example 001: Hello World 604</p> <p>22.9.2 Example 101: Simple Option Pricer 605</p> <p>22.9.3 Excel-DNA and Rate Curves 608</p> <p>22.9.4 Registration and Loading 613</p> <p>22.9.5 What is Inside ExcelDna.Integration.dll? 614</p> <p>22.10 Excel COM Interoperability and Rate Multi-curve 615</p> <p>22.11 Conclusion and Summary 622</p> <p>22.12 Exercises and Projects 622</p> <p><b>23 Real-time Data (RTD) Server 625</b></p> <p>23.1 Introduction and Objectives 625</p> <p>23.2 Real-time Data in Excel: Overview 625</p> <p>23.3 Real-time Data Function 626</p> <p>23.4 Example 627</p> <p>23.5 The Topic Class and Data 629</p> <p>23.6 Creating an RTD Server 631</p> <p>23.7 Using the RTD Server 631</p> <p>23.8 Testing and Troubleshooting the RTD Server 632</p> <p>23.9 Conclusion and Summary 632</p> <p>23.10 Exercises and Projects 632</p> <p><b>24 Introduction to Multi-threading in C# 635</b></p> <p>24.1 Introduction and Objectives 635</p> <p>24.2 Processes 636</p> <p>24.3 Using ProcessStartInfo to Redirect Process I/O 637</p> <p>24.4 An Introduction to Threads in C# 638</p> <p>24.4.1 The Differences between Processes and Threads 641</p> <p>24.5 Passing Data to a Thread and between Threads 641</p> <p>24.6 Thread States and Thread Lifecycle 644</p> <p>24.6.1 Sleep 645</p> <p>24.6.2 Thread Joining 646</p> <p>24.6.3 Thread Interrupt and Abort 648</p> <p>24.7 Thread Priority 650</p> <p>24.8 Thread Pooling 651</p> <p>24.9 Atomic Operations and the Interlocked Class 652</p> <p>24.10 Exception Handling 653</p> <p>24.11 Multi-threaded Data Structures 654</p> <p>24.11.1 Extended Producer–Consumer Pattern 657</p> <p>24.12 A Simple Example of Traditional Multi-threading 659</p> <p>24.13 Summary and Conclusions 661</p> <p>24.14 Exercises and Projects 661</p> <p><b>25 Advanced Multi-threading in C# 665</b></p> <p>25.1 Introduction and Objectives 665</p> <p>25.2 Thread Safety 666</p> <p>25.3 Locking Mechanisms for Objects and Classes 667</p> <p>25.3.1 Locking a Class 669</p> <p>25.3.2 Nested Locking 669</p> <p>25.4 Mutex and Semaphore 673</p> <p>25.5 Notification and Signalling 676</p> <p>25.5.1 Thread Notification and the Monitor Class 678</p> <p>25.6 Asynchronous Delegates 679</p> <p>25.7 Synchronising Collections 681</p> <p>25.8 Timers 682</p> <p>25.9 Foreground and Background Threads 684</p> <p>25.10 Executing Operations on Separate Threads: the BackgroundWorker Class 685</p> <p>25.11 Parallel Programming in .NET 687</p> <p>25.11.1 The Parallel Class 687</p> <p>25.12 Task Parallel Library (TPL) 691</p> <p>25.12.1 Creating and Starting Tasks 692</p> <p>25.12.2 Continuations 694</p> <p>25.13 Concurrent Data Structures 694</p> <p>25.13.1 An Example: Producer Consumer Pattern and Random Number Generation 695</p> <p>25.13.2 The Barrier Class 698</p> <p>25.13.3 PLINQ 699</p> <p>25.14 Exception Handling 701</p> <p>25.15 Shifting Curves 702</p> <p>25.16 Summary and Conclusions 704</p> <p>25.17 Exercises and Projects 704</p> <p><b>26 Creating Multi-threaded and Parallel Applications for Computational Finance 707</b></p> <p>26.1 Introduction and Objectives 707</p> <p>26.2 Multi-threaded and Parallel Applications for Computational Finance 707</p> <p>26.3 Fork and Join Pattern 709</p> <p>26.4 Geometric Decomposition 711</p> <p>26.5 Shared Data and Reader/Writer Locks: Multiple Readers and Multiple Writers 715</p> <p>26.5.1 Upgradeable Locks and Recursion 718</p> <p>26.6 Monte Carlo Option Pricing and the Producer–Consumer Pattern 719</p> <p>26.7 The StopWatch Class 726</p> <p>26.8 Garbage Collection and Disposal 727</p> <p>26.8.1 Disposal and the IDisposable Interface 727</p> <p>26.8.2 Automatic Garbage Collection 728</p> <p>26.8.3 Managed Memory Leaks 730</p> <p>26.9 Summary and Conclusions 730</p> <p>26.10 Exercises and Projects 730</p> <p><b>A1 Object-oriented Fundamentals 735</b></p> <p>A1.1 Introduction and Objectives 735</p> <p>A1.2 Object-oriented Paradigm 735</p> <p>A1.3 Generic Programming 737</p> <p>A1.4 Procedural Programming 738</p> <p>A1.5 Structural Relationships 738</p> <p>A1.5.1 Aggregation 739</p> <p>A1.5.2 Association 740</p> <p>A1.5.3 Generalisation/Specialisation (Gen/Spec Relationship) 742</p> <p>A1.6 An Introduction to Concept Modelling 743</p> <p>A1.6.1 The Defining Attribute View 743</p> <p>A1.6.2 The Prototype View 744</p> <p>A1.6.3 The Exemplar-based View 744</p> <p>A1.6.4 The Explanation-based View 744</p> <p>A1.7 Categorisation and Concept Levels 745</p> <p>A1.8 Whole–Part Pattern 745</p> <p>A1.8.1 Data Decomposition 746</p> <p>A1.9 Message-passing Concept versus Procedural Programming 748</p> <p><b>A2 Nonlinear Least-squares Minimisation 751</b></p> <p>A2.1 Introduction and Objectives 751</p> <p>A2.2 Nonlinear Programming and Multi-variable Optimisation 751</p> <p>A2.3 Nonlinear Least Squares 753</p> <p>A2.3.1 Nonlinear Regression 753</p> <p>A2.3.2 Simultaneous Nonlinear Equations 754</p> <p>A2.3.3 Derivatives of Sum-of-Squares Functions 754</p> <p>A2.4 Some Specific Methods 755</p> <p>A2.5 The ALGLIB Library 756</p> <p>A2.6 An Application to Curve Building 758</p> <p>A2.7 Rate Calibration Example 759</p> <p>A2.8 Exercises and Projects 764</p> <p><b>A3 The Mathematical Background to the Alternating Direction Explicit (ADE) Method 765</b></p> <p>A3.1 Introduction and Objectives 765</p> <p>A3.2 Background to ADE 765</p> <p>A3.3 Scoping the Problem: One-factor Problems 766</p> <p>A3.4 An Example: One-factor Black-Scholes PDE 768</p> <p>A3.5 Boundary Conditions 769</p> <p>A3.6 Example: Boundary Conditions for the One-factor Black-Scholes PDE 772</p> <p>A3.7 Motivating the ADE Method 772</p> <p>A3.8 The ADE Method Exposed 773</p> <p>A3.9 The Convection Term 773</p> <p>A3.10 Other Kinds of Boundary Conditions 774</p> <p>A3.11 Nonlinear Problems 775</p> <p>A3.12 ADE for PDEs in Conservative Form 775</p> <p>A3.13 Numerical Results and Guidelines 776</p> <p>A3.13.1 The Consequences of Conditional Consistency 776</p> <p>A3.13.2 Call Payoff Behaviour at the Far Field 777</p> <p>A3.13.3 General Formulation of the ADE Method 777</p> <p>A3.14 The Steps to Use when Implementing ADE 778</p> <p>A3.15 Summary and Conclusions 778</p> <p>A3.16 Exercises and Projects 779</p> <p><b>A4 Cap, Floor and Swaption Using Excel-DNA 789</b></p> <p>A4.1 Introduction 789</p> <p>A4.2 Different Ways of Stripping Cap Volatility 789</p> <p>A4.3 Comparing Caplet Volatility Surface 792</p> <p>A4.4 Call Put Parity 794</p> <p>A4.5 Cap Price Matrix 795</p> <p>A4.6 Multi-strike and Amortising 797</p> <p>A4.7 Simple Swaption Formula 798</p> <p>A4.8 Swaption Straddle 800</p> <p>A4.9 Exercises 804</p> <p>Bibliography 805</p> <p>Web References 812</p> <p>Index 815</p>
<p><b>DANIEL J. DUFFY</b> has been working with numerical methods in finance, industry and engineering since 1979. He has written four books on financial models and numerical methods and C++ for computational finance and he has also developed a number of new schemes for this field. He is the founder of Datasim Education and has a PhD in Numerical Analysis from Trinity College, Dublin.</p> <p><b>ANDREA GERMANI</b> was born in Lodi, Italy in 1975, where he currently lives. After graduating from Bocconi University in Milano, he obtained the Certificate in Quantitative Finance in London under the supervision of Paul Wilmott. Since then he has been working as a trader in some of the major Italian banks, where he gained a deep knowledge of financial markets. He also worked on valuation and pricing of equity and interest-derivatives, with a focus on the practical use of models on the trading floor. His teaching experience includes finance training courses for university students and practitioners. He is the Head of Interest Rate Derivatives Trading and Treasury in a bank.</p>
<p><b>C# for Financial Markets</b> <p><b>Duffy and Germani</b> <p>C# is a modern object-oriented programming language that runs under the Microsoft .NET Framework and it is suitable for the development of pricing and trading applications in quantitative finance. It has functionality to support the needs of quants and traders who develop fixed income and computational finance applications. It is more accessible than C++ and has interfaces with other tools such as Excel, C++, F# and database systems. <p><i>C# for Financial Markets</i> is a practice-oriented book that shows how to design and program pricing models using the C# programming language. It is a step-by-step account of how to develop software programs that can be used by traders in real-life situations. The reader will discover how to design and implement real finance applications including new methodologies that were developed after the crash of 2007. The approach is thorough and comprehensive and the authors use a combination of C# language features, design patterns, mathematics and finance to produce efficient and maintainable software. <p>Some key features in the book are: <ul> <li>The C# language from A to Z (version 4.0).</li> <li>C# as a language that supports the object-oriented, generic and functional programming models.</li> <li>Implementing lattice models in C#.</li> <li>Two chapters on PDE models (including an in-depth analysis of the Alternating Direction Explicit (ADE) finite difference method).</li> <li>Six major chapters on fixed income applications including the single curve and multi curve framework.</li> <li>How to create COM and Automation addins in Excel and link them to fixed income applications.</li> <li>A thorough introduction to C# multi-threading and the TPL (Task Programming Language).</li> <li>A detailed overview of LINQ (Language Integrated Query), its applications to finance and LINQ–Excel interoperability.</li> <li>Multi-language development in .NET, in particular creating mixed C#/C++ applications.</li> <li>Introduction to .NET assemblies.</li> </ul> <p>Designed for quant developers, traders and MSc/MFE students, each chapter has numerous exercises. After purchasing this book you can register at the dedicated companion website, <i>www.datasimfinancial.com</i>, where all of the source code is provided, alongside forums for readers to comment on the code and obtain new versions of the software.

Diese Produkte könnten Sie auch interessieren:

Mindfulness
Mindfulness
von: Gill Hasson
PDF ebook
12,99 €
Counterparty Credit Risk, Collateral and Funding
Counterparty Credit Risk, Collateral and Funding
von: Damiano Brigo, Massimo Morini, Andrea Pallavicini
EPUB ebook
69,99 €