C++ Course

 

Lecture 1, Jan. 10, 2005

 

Some very simple programs.
Using #include statements, namespace, the cout function, strings and character arrays.

 

Download Code

 


Lecture 5, Jan 24, 2005

 

Computer Lab: Implementing the IRR function in the cash_flow class.

 

Download the three source code files:

cash_flow.cpp
cash_flow.h
test.cpp

by right-click and using “Save Target As…”.

 

Open a new empty project in Visual Studio and put the “test.cpp” and “cash_flow.cpp” in the Source code folder, “cash_flow.h” in the Headers folder.

 

We will study the code in “Numerial Recipes in C++” p. 356 (Root Finding) to get clues on how to implement the IRR() function.

 

Source Code

 


Lecture 6, Jan 26, 2005

 

Finish implementing the IIR function in the cash_flow class.
Last time we managed to write the code that will bracket the IRR between two rates. We now use bisection to actually find the IRR.

 

Use the same procedure as above to download the updated code.

 

Source Code

 


 

Lecture 7, Jan 31, 2005

 

BondAnalyzer project: the Date class

 

Homework: Implement the checkDate() function and build it into the constructors for the Date class.
                   Use the Date class to find all the Friday the 13th from Feb. 2, 2005 to Feb. 2, 2010.

 

Source Code

 


 

Lecture 8, Feb 7, 2005

 

Implementing the checkDate() function and the overloaded operators  pre and post-increment ++, +=, pre and post-decrement --, nextBusDay() and adding a number of days to a given Date object. Using the pointer “this” .i.e. the pointer in an object that points to the object itself.

 

Homework: even with our checkDate() function there is still a backdoor for a user to make an invalid Date object. See if you can find what it is and fix it.
                   Build the – and the -= operators so there are safeguards agains them resulting in invalid Date objects.

 

Source Code

 


 

 

Lecture 9, Feb 14, 2005

 

Using the Date class and the cash_flow class to build a present value calculator that allows us to input the date of cash flows.

 

Homework for the Lab: eliminate one of the loops to make the cashFlow.cpp code more efficient while still providing the same functionality

 

Source Code

 

 


 

Lecture 10, Feb 21, 2005

 

Pointers and Inheritance. The TermStructure class as a base class for the other classes of term structures. The notion of polymorphism i.e. how a pointer of base class type can point to an object of a derived class type, through the use of virtual functions.

Homework for the Lab: begin to code the derived classes. As a first step write a routine that will take a given date d and find the two dates where we have observed rates on either side of d.

 

Source Code

 


 

Lab, Mar 9, 2005

 

Source Code

 


 

Lecture Mar 28, 2005

 

Working version of the TermStructureCubicSpline class, test program.

Beginning discussion of QuantLib library

 

Code

 


Lecture Apr 4, 2005

 

Building a simple option pricer with QuantLib.

 

Code

 


 

Lecture Apr 6, 2005

 

Pricing an Asian Option with QuantLib

 


 

Lecture Apr 11, 2005

 

Designing the ContinuousArithmeticAveragingAsionOption class and writing the code for the pricing engine

 

Code

 


 

Lecture Apr 13, 2005

 

Compound Options

 


 

Lecture Apr 18, 2005

 

Compound Options, Function Objects

 

Code

 


 

Lecture June 1, 2005

 

Pricing Options under Jump Processes

 

Notes