Introduction |
|
xvii | |
|
|
1 | (16) |
|
1.1 Installing your development environment |
|
|
1 | (1) |
|
|
1 | (1) |
|
|
1 | (1) |
|
|
1 | (1) |
|
1.2 Running an example program |
|
|
2 | (1) |
|
1.3 Compiling and running the code |
|
|
3 | (5) |
|
1.3.1 Compiling on Windows |
|
|
4 | (2) |
|
|
6 | (2) |
|
1.4 Understanding the example code |
|
|
8 | (4) |
|
1.5 Configuring the compiler |
|
|
12 | (1) |
|
|
13 | (1) |
|
|
14 | (1) |
|
|
15 | (2) |
|
2 Basic Data Types and Operators |
|
|
17 | (20) |
|
|
17 | (1) |
|
|
18 | (4) |
|
|
18 | (2) |
|
2.2.2 Floating point numbers |
|
|
20 | (1) |
|
|
20 | (1) |
|
|
20 | (2) |
|
|
22 | (4) |
|
|
26 | (2) |
|
|
28 | (7) |
|
2.5.1 The sizeof operator |
|
|
28 | (1) |
|
2.5.2 Mathematical operations |
|
|
28 | (1) |
|
2.5.3 Comparison operators |
|
|
29 | (1) |
|
|
29 | (1) |
|
|
29 | (1) |
|
2.5.6 Combining operators |
|
|
30 | (1) |
|
2.5.7 Assignment operators |
|
|
30 | (2) |
|
2.5.8 If statements revisited |
|
|
32 | (3) |
|
|
35 | (2) |
|
|
37 | (18) |
|
3.1 The C++ function syntax |
|
|
37 | (4) |
|
|
41 | (1) |
|
|
42 | (1) |
|
3.4 Declaring and defining functions |
|
|
42 | (2) |
|
3.5 Functions that don't return a value |
|
|
44 | (1) |
|
3.6 Specifying default values |
|
|
45 | (1) |
|
3.7 Overloading functions |
|
|
46 | (1) |
|
3.8 Global and local variables |
|
|
47 | (1) |
|
|
48 | (4) |
|
|
52 | (3) |
|
|
55 | (16) |
|
|
55 | (2) |
|
|
57 | (1) |
|
|
58 | (2) |
|
4.4 Break, Continue, Return |
|
|
60 | (1) |
|
|
61 | (2) |
|
|
63 | (2) |
|
|
65 | (1) |
|
4.8 Flow of control in operators |
|
|
65 | (4) |
|
4.8.1 Short circuit evaluation |
|
|
66 | (1) |
|
4.8.2 The ternary operator |
|
|
66 | (1) |
|
|
67 | (2) |
|
|
69 | (2) |
|
5 Working with Multiple Files |
|
|
71 | (14) |
|
|
71 | (1) |
|
|
72 | (1) |
|
|
73 | (4) |
|
5.3.1 Creating the first header file |
|
|
73 | (2) |
|
5.3.2 Some code that uses the functions |
|
|
75 | (1) |
|
5.3.3 Write the definitions |
|
|
76 | (1) |
|
5.4 How header files work |
|
|
77 | (4) |
|
5.4.1 The meaning of include |
|
|
77 | (1) |
|
|
77 | (1) |
|
|
78 | (2) |
|
|
80 | (1) |
|
|
81 | (1) |
|
|
82 | (3) |
|
|
85 | (12) |
|
6.1 A testing framework for C++ |
|
|
86 | (1) |
|
|
86 | (1) |
|
6.3 The macros in testing.h |
|
|
87 | (2) |
|
|
87 | (1) |
|
6.3.2 The ASSERT_APPRDX_EQUAL macro |
|
|
87 | (1) |
|
|
88 | (1) |
|
6.3.4 The DEBUG_PRINT macro |
|
|
88 | (1) |
|
|
89 | (1) |
|
|
89 | (2) |
|
|
91 | (1) |
|
|
92 | (2) |
|
|
94 | (3) |
|
|
97 | (26) |
|
|
97 | (3) |
|
7.2 Pass by reference and const |
|
|
100 | (4) |
|
|
101 | (1) |
|
|
102 | (2) |
|
7.2.3 Pass by reference without const |
|
|
104 | (1) |
|
|
104 | (2) |
|
|
106 | (1) |
|
7.5 Building strings efficiently |
|
|
107 | (1) |
|
|
108 | (9) |
|
|
109 | (2) |
|
7.6.2 Create a header file |
|
|
111 | (1) |
|
7.6.3 Write a source file |
|
|
112 | (1) |
|
7.6.4 Enable testing in your files |
|
|
112 | (1) |
|
7.6.5 Write functions to generate the boiler plate |
|
|
112 | (1) |
|
7.6.6 Write a simple version of the chart data |
|
|
113 | (1) |
|
7.6.7 Write a test of what we've done so far |
|
|
114 | (1) |
|
7.6.8 Write the interesting code |
|
|
114 | (1) |
|
7.6.9 Testing the interesting code |
|
|
115 | (1) |
|
7.6.10 Wrap it all up into a single function |
|
|
116 | (1) |
|
7.7 The architecture of the World Wide Web |
|
|
117 | (4) |
|
|
121 | (2) |
|
|
123 | (22) |
|
|
123 | (1) |
|
8.2 Writing your own class |
|
|
124 | (4) |
|
8.2.1 Writing the declaration |
|
|
124 | (2) |
|
|
126 | (1) |
|
8.2.3 Passing objects between functions |
|
|
127 | (1) |
|
8.2.4 How have classes helped? |
|
|
127 | (1) |
|
8.3 Adding functions to classes |
|
|
128 | (3) |
|
8.3.1 Using const on member functions |
|
|
130 | (1) |
|
|
131 | (3) |
|
8.4.1 What have we gained? |
|
|
133 | (1) |
|
8.5 Recommendations on writing classes |
|
|
134 | (1) |
|
|
135 | (3) |
|
8.6.1 Implementing PieChart |
|
|
137 | (1) |
|
|
137 | (1) |
|
|
138 | (3) |
|
8.7.1 Writing a default constructor |
|
|
139 | (1) |
|
8.7.2 An alternative, and superior syntax |
|
|
140 | (1) |
|
8.8 Constructors with parameters |
|
|
141 | (3) |
|
|
144 | (1) |
|
9 Monte Carlo Pricing in C++ |
|
|
145 | (14) |
|
9.1 A function to simulate stock prices |
|
|
146 | (5) |
|
9.2 Writing a Monte Carlo pricer |
|
|
151 | (3) |
|
9.3 Generating random numbers for Monte Carlo |
|
|
154 | (4) |
|
|
158 | (1) |
|
|
159 | (16) |
|
10.1 An interface for pricing options |
|
|
159 | (2) |
|
10.2 Describing an interface in C++ |
|
|
161 | (3) |
|
10.3 Examples of interfaces |
|
|
164 | (2) |
|
10.4 Interfaces in object-oriented programming |
|
|
166 | (2) |
|
10.5 What's wrong with if statements? |
|
|
168 | (1) |
|
10.6 An interface for integration |
|
|
169 | (4) |
|
|
173 | (2) |
|
11 Arrays, Strings, and Pointers |
|
|
175 | (30) |
|
11.1 Arrays, the C alternative to vector |
|
|
176 | (3) |
|
|
179 | (6) |
|
|
179 | (1) |
|
|
180 | (2) |
|
11.2.3 Looping with pointers |
|
|
182 | (3) |
|
11.2.4 Using pointers in practice |
|
|
185 | (1) |
|
|
185 | (2) |
|
|
187 | (2) |
|
11.5 Don't return pointers to local variables |
|
|
189 | (2) |
|
11.6 Using pointers to share data |
|
|
191 | (6) |
|
11.6.1 Sharing with shared__ptr |
|
|
194 | (3) |
|
11.7 Sharing data with references |
|
|
197 | (2) |
|
11.8 The C++ memory model |
|
|
199 | (5) |
|
|
200 | (2) |
|
|
202 | (2) |
|
|
204 | (1) |
|
12 More Sophisticated Classes |
|
|
205 | (18) |
|
12.1 Inlining member functions |
|
|
205 | (1) |
|
|
206 | (1) |
|
|
207 | (3) |
|
12.3.1 What have we gained? |
|
|
209 | (1) |
|
|
209 | (1) |
|
12.4 Overriding methods -- the virtual keyword |
|
|
210 | (2) |
|
12.4.1 A note on the keyword virtual |
|
|
211 | (1) |
|
12.5 Abstract functions =0 |
|
|
212 | (1) |
|
|
212 | (5) |
|
|
213 | (2) |
|
12.6.2 Another object hierarchy |
|
|
215 | (1) |
|
12.6.3 Multiple inheritance |
|
|
215 | (1) |
|
12.6.4 Calling superclass methods |
|
|
216 | (1) |
|
12.7 Forward declarations and the structure of cpp files |
|
|
217 | (1) |
|
|
218 | (2) |
|
12.9 The protected keyword |
|
|
220 | (2) |
|
|
222 | (1) |
|
|
223 | (10) |
|
13.1 The Priceable interface |
|
|
223 | (1) |
|
13.2 The Portfolio interface and implementation |
|
|
224 | (4) |
|
13.2.1 Implementation of PortfolioImpl |
|
|
227 | (1) |
|
|
228 | (2) |
|
|
230 | (1) |
|
|
231 | (1) |
|
|
232 | (1) |
|
|
233 | (12) |
|
14.1 Discrete-time delta hedging |
|
|
233 | (2) |
|
14.2 Implementing the delta hedging strategy in C++ |
|
|
235 | (6) |
|
|
235 | (2) |
|
14.2.2 Implementation of runSimulation |
|
|
237 | (1) |
|
14.2.3 Implementing the other methods of HedgingSimulator |
|
|
238 | (2) |
|
14.2.4 Changes to CallOption |
|
|
240 | (1) |
|
14.3 Testing the simulation |
|
|
241 | (1) |
|
14.4 Interpreting and extending our simulation |
|
|
241 | (3) |
|
|
244 | (1) |
|
15 Debugging and Development Tools |
|
|
245 | (22) |
|
15.1 Debugging strategies |
|
|
245 | (3) |
|
|
245 | (1) |
|
|
246 | (1) |
|
15.1.3 Logging statements |
|
|
246 | (1) |
|
|
247 | (1) |
|
15.1.5 Divide and conquer |
|
|
247 | (1) |
|
15.2 Debugging with Visual Studio |
|
|
248 | (4) |
|
15.2.1 Obtaining a stack trace in Visual Studio |
|
|
248 | (2) |
|
15.2.2 Breakpoints and single stepping in Visual Studio |
|
|
250 | (2) |
|
|
252 | (6) |
|
15.3.1 Using GDB to obtain a stack trace |
|
|
253 | (3) |
|
15.3.2 Breakpoints and single stepping with GDB |
|
|
256 | (1) |
|
15.3.3 Other commands and features |
|
|
257 | (1) |
|
15.4 Other development tools and practices |
|
|
258 | (6) |
|
|
258 | (1) |
|
|
259 | (1) |
|
|
259 | (1) |
|
|
260 | (1) |
|
15.4.5 Continuous integration |
|
|
261 | (1) |
|
|
261 | (1) |
|
|
261 | (1) |
|
15.4.8 Memory-leak detection |
|
|
262 | (1) |
|
|
262 | (1) |
|
|
263 | (1) |
|
|
264 | (3) |
|
|
267 | (28) |
|
16.1 Basic functionality of Matrix |
|
|
267 | (2) |
|
16.2 The constructor and destructor of Matrix |
|
|
269 | (5) |
|
16.2.1 Virtual destructors |
|
|
271 | (1) |
|
16.2.2 When is a destructor needed? |
|
|
272 | (1) |
|
16.2.3 Additional constructors |
|
|
273 | (1) |
|
|
274 | (1) |
|
16.4 Operator overloading |
|
|
275 | (7) |
|
|
275 | (2) |
|
16.4.2 Overloading other arithmetic operators |
|
|
277 | (1) |
|
16.4.3 Overloading comparison operators |
|
|
278 | (1) |
|
16.4.4 Overloading the << operator |
|
|
279 | (1) |
|
16.4.4.1 Remarks on return by reference |
|
|
280 | (1) |
|
16.4.5 Overloading the () operator |
|
|
280 | (1) |
|
|
281 | (1) |
|
|
282 | (3) |
|
16.5.1 Overriding the assignment operator |
|
|
282 | (1) |
|
16.5.2 Writing a copy constructor |
|
|
283 | (1) |
|
16.5.3 The easy way to abide by the rule of three |
|
|
284 | (1) |
|
|
285 | (1) |
|
16.6 Completing the Matrix class |
|
|
285 | (1) |
|
|
286 | (6) |
|
16.7.1 Implementing an efficient matrix class |
|
|
286 | (1) |
|
|
287 | (1) |
|
16.7.3 Array programming in the option classes |
|
|
288 | (1) |
|
16.7.4 Array programming for the BlackScholesModel |
|
|
289 | (1) |
|
16.7.5 Array programming the Monte Carlo pricer |
|
|
290 | (1) |
|
|
290 | (2) |
|
|
292 | (3) |
|
17 An Overview of Templates |
|
|
295 | (8) |
|
|
295 | (2) |
|
|
297 | (2) |
|
17.3 Templates as an alternative to interfaces |
|
|
299 | (3) |
|
|
302 | (1) |
|
18 The Standard Template Library |
|
|
303 | (26) |
|
|
304 | (2) |
|
|
306 | (1) |
|
18.3 Using iterators with vectors |
|
|
307 | (2) |
|
18.4 For Loops and Containers |
|
|
309 | (1) |
|
|
310 | (1) |
|
18.6 The container vector |
|
|
311 | (1) |
|
|
312 | (3) |
|
18.8 The container initializer_list |
|
|
315 | (1) |
|
18.9 The containers map and unordered_map |
|
|
315 | (5) |
|
|
317 | (1) |
|
18.9.2 How an unordered_map works |
|
|
318 | (2) |
|
18.10 Storing complex types in containers |
|
|
320 | (1) |
|
18.11 A mathematical model for multiple stocks |
|
|
320 | (2) |
|
18.12 Using the Standard Template Library in FMLib |
|
|
322 | (5) |
|
|
327 | (2) |
|
19 Function Objects and Lambda Functions |
|
|
329 | (8) |
|
|
329 | (1) |
|
|
330 | (3) |
|
|
333 | (1) |
|
19.4 Sorting with lambda functions |
|
|
334 | (2) |
|
|
336 | (1) |
|
|
337 | (22) |
|
20.1 Concurrent programming in C++ |
|
|
338 | (8) |
|
|
338 | (1) |
|
|
339 | (3) |
|
20.1.3 Global variables and race conditions |
|
|
342 | (1) |
|
20.1.4 Problems with locking |
|
|
343 | (3) |
|
20.2 The command design pattern |
|
|
346 | (1) |
|
|
347 | (5) |
|
20.3.1 Random number generation with multiple threads |
|
|
348 | (1) |
|
20.3.2 A multi-threaded pricer |
|
|
349 | (1) |
|
|
350 | (1) |
|
20.3.4 Using the Executor |
|
|
351 | (1) |
|
20.3.5 Remarks upon the design |
|
|
351 | (1) |
|
20.4 Coordinating threads |
|
|
352 | (6) |
|
20.4.1 The Pipeline pattern |
|
|
352 | (3) |
|
20.4.2 How Pipeline is implemented |
|
|
355 | (3) |
|
|
358 | (1) |
|
|
359 | (4) |
|
|
359 | (2) |
|
|
359 | (1) |
|
21.1.2 Software development |
|
|
359 | (1) |
|
21.1.3 C++ language features |
|
|
360 | (1) |
|
|
360 | (1) |
|
21.2 Financial mathematics |
|
|
361 | (2) |
|
|
363 | (20) |
|
A.1 The players in financial markets |
|
|
363 | (3) |
|
A.2 Derivatives contracts |
|
|
366 | (4) |
|
|
370 | (2) |
|
A.4 Modelling stock prices |
|
|
372 | (5) |
|
|
377 | (2) |
|
|
379 | (3) |
|
|
382 | (1) |
Bibliography |
|
383 | (2) |
Index |
|
385 | |