
P1: JYS
c08 JWBK378-Fletcher May 12, 2009 18:58 Printer: Yet to come
The Hull–White Model 121
... , duration = ppf.date time.years
... , shift
method = shift convention.modified following)
>>> structure = trade((pay
leg, receive leg), (ex sched,
exercise
type.callable))
>>> factory = hull
white lattice model factory()
>>> hwmodel = factory(structure, env)
The corresponding factory for the Hull–White Monte-Carlo model is shown below. The
details are almost identical to the factory for theHull–White lattice model. The main differences
are that the model argument dictionary is used to control the valuesof the number of simulations
and start seed, and instead of a rollback component being constructed we construct an evolve
component. We finish off by constructing an exercise component for the case when the trade
is callable.
class hull white monte carlo model factory:
def
call (self, trd, env, model args = None):
ccy = ppf.core.enforce
single currency(trd)
terminal
T = env.relative date(ppf.core.final important date(trd))/
365.0
num
sims = 1000
if model
args <> None and model args.has key("num sims"):
num
sims = model args["num sims"]
seed = 1234
if model
args <> None and model args.has key("seed"):
seed = model
args["seed"]
s = monte
carlo.state(num sims)
ev = monte
carlo.evolve(ccy, seed)
f = fill(terminal
T)
r = requestor()
ex = None
id = 0
if model
args <> None and \
model
args.has key("explanatory variables leg id"):
id = model ...