
P1: JYS
c09 JWBK378-Fletcher May 12, 2009 19:0 Printer: Yet to come
128 Financial Modelling in Python
underlying = ctr.retrieve symbol("underlying")
underlying *= 0
cnt=0
for l in self.
trade.legs():
underlying += ctr.retrieve
symbol("leg"+str(cnt))
cnt += 1
ctr.update
symbol("underlying", underlying, to )
pv = 0
if self.
trade.has exercise schedule():
if self.
trade.exercise type() == exercise type.callable:
pv = ctr.retrieve
symbol("berm").mean()
else:
pv = ctr.retrieve
symbol("underlying").mean() \
+ ctr.retrieve
symbol("berm").mean()
else:
pv = ctr.retrieve
symbol("underlying").mean()
return pv
It needs to be emphasised that in the above pricing framework there is theoretically no
restriction on the dimensionality of the model. Everything will flow through just as well for a
multidimensional model, albeit more slowly, as it would do for a one-dimensional model. The
only assumption being made on the underlying numerical container is that it has the arithmetic
operators overloaded and a mean operator.
To conclude this section, we note that sometimes it is useful for diagnostics purposes
to be able to listen to the symbols at various stages of the calculation. The optional
symbol
table listener argument in the constructor provides this functionality. A con-
crete example, provided in the test module ppf.test.test lattice pricer,isgiven
below:
class european symbol table listener:
def
init (self):
self.
symbols = []
def