
P1: JYS
c07 JWBK378-Fletcher April 24, 2009 8:16 Printer: Yet to come
94 Financial Modelling in Python
def str (self) :
s = "payment [%s, %s, %s, %s], " % \
(self.
pay rcv, self. leg id, self. reset id,
str(self.
flow))
return s
class exercise
event:
def
init (
self
, exercise
opportunity
, exercise
type):
self.
exercise opportunity \
, self.
exercise type = exercise opportunity, exercise type
def exercise
type(self) : return self. exercise type
def exercise
opportunity(self) : return self. exercise opportunity
def pay
currency(self) :
return self.
exercise opportunity.fee currency()
def
str (self) :
s = "exercise [%s, %s], " % \
(self.
exercise type, str(self. exercise opportunity))
return s
def is
pay event(event): return isinstance(event, pay event)
def is
exercise event(event): return isinstance(event, exercise event)
7.2 TIMELINE
Now that we have a clear understanding of an event, we move on to the timeline. Any
financial payoff can be interpreted as a sequence of cash flows and exercise decisions with
potentially more than one cash flow occurring at any one point in time. The purpose of
the class timeline from the ppf.core.timeline module is to transform the trade
representation into a sequence of events. The actual transformation occurs in the constructor
of the timeline. We begin by harvesting the observables from the trade to create instances of
the pay
event and follow on by harvesting the exercises from the trade to ...