
P1: JYS
c09 JWBK378-Fletcher May 12, 2009 19:0 Printer: Yet to come
138 Financial Modelling in Python
events = self. timeline.events(time)
# evaluate explanatory variables and immediate exercise values
for event in events:
# set event on controller
ctr.set
event(event)
# evaluate
if is
exercise event(event):
# evaluate underlying
underlying = ies[ex
cnt, :]
cnt = 0
for l in self.
trade.legs():
underlying += ctr.retrieve
symbol("leg"+str(cnt))
cnt += 1
underlying *= self.
trade.exercise type()
underlying *= normalisation
# evaluate explanatory variables and numeraire
ns[ex
cnt, :] = ctr.numeraire(to )
vs[ex
cnt, :] = ctr.explanatory variables(to )
ex
cnt += 1
# evaluate cash flows
for event in events:
# set event on controller
ctr.set
event(event)
# evaluate
if is
pay event(event):
# evaluate payoff
cpn = ctr(to
)
symbol = "leg"+str(event.leg
id())
leg
pv = ctr.retrieve symbol(symbol)
leg
pv += cpn
self.
symbol listener (to , symbol, leg pv)
ctr.update
symbol(symbol, leg pv, to )
from
=to
.
.
.
Once we have all of this information we compute the immediate exercise values by subtracting
from the total sum of all cash flows each of the stored sum of cash flows in turn. The regression
is then carried out via an invocation of the free function pickup
value regression.The
method ends with the creation of an instance of the exercise
helper class, which will be
used in the actual pricing of the callable structure.
class monte carlo pricer:
def
exercise ...