15. (Software Framework (New Version); Medium-Sized Project) The goal of this exercise is to extend the initial

Question:

15. (Software Framework (New Version); Medium-Sized Project)

The goal of this exercise is to extend the initial software framework that we introduced in this chapter to help model a larger range of problems.

a) In this chapter we did not create a separate entity or class to model the SDE the lattice method is approximating. At this stage the method is only applicable to GBM but we need to determine if it can be adapted to other kinds of SDEs, for example by a change of variables as discussed in Nelson and Ramaswamy (1990). To this end, use the results from Section 6.8 to model an SDE class using the functional programming style. We repeat the code for convenience:

// Functions of arity 2 (two input arguments)

template

using FunctionType

= std::function;

template

using interface

= std::tuple, FunctionType>;

// Interface to simulate any SDE with drift/diffusion

// Use a tuple to aggregate two functions into what is similar to

// an interface in C# or Java.

template

using ISde = std::tuple, FunctionType>;

// Boost Functional Factory template

using Factory = boost::factory;

template class Sde

{

private:

FunctionType dr_;

FunctionType diff_;

T ic; // Initial condition public:

Sde() = default;

Sde(const Sde& sde2, const T& initialcCondition)

: dr_(sde2.dr_),diff_(sde2.diff_),ic(initialcCondition) {}
Sde(const ISde& functions, const T& initialcCondition)
:dr_(std::get<0>(functions)),diff_(std::get<1>(functions)), ic(initialcCondition) {}
T drift(const T& S, const T& t) { return dr_(S, t); }
T diffusion(const T& S, const T& t) { return diff_(S, t); }
;
Integrate this class into the framework and test for plain and American puts and calls. Choose an example from Nelson and Ramaswamy (1990) and test it using the modified framework. In which layer will you place the SDE classes and their adapters?

b) Consider how to create factory and builder classes to initialise the application objects in the framework. In which layers will you place these factories?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: