
P1: JYS
c07 JWBK378-Fletcher April 24, 2009 8:16 Printer: Yet to come
Timeline: Events and Controller 97
7.3 CONTROLLER
As already discussed in the introduction, the controller provides the main glue between the
trade representation (or more correctly its transformation into events) and the pricing models.
Essentially the controller is constructed from the trade, the model and the market environment.
The final argument of the constructor is used to control how historical discount factors are
treated and we defer further discussion on this point to later chapters. The main job of the
controller is to maintain a dictionary of variables whose values will be updated and retrieved
by the pricing models. The controller is also the conduit for the pricing models to evaluate
the payoffs in the trade representation. The payoffs are evaluated by first setting the event
followed by an invocation of the function call operator. The following excerpt from the
ppf.core.controller module illustrates the essential details of the controller class.
class controller:
def
init (self, trade, model, env, historic df):
self.
trade = trade
self.
model = model
self.
env = env
self.
historical df = historical df
self.
symbol table = {}
self.
event = None
def get
trade(self):
return self.
trade
def get
model(self):
return self.
model
def get
environment(self):
return self.
env
def get
event(self):
return self.
event
def set
event(self, event):
self.
event ...