montrixdev/mxdevtool-python

How to generate whole yield curve term structure tenors results use Hull White model?

jojogh opened this issue · 2 comments

jojogh commented

I search all document in the repository, and I found out that the if I use fitted curve, like below:

tenor_rates = [('3M', 0.0151, 0.01),
('6M', 0.0152, 0.01),
('9M', 0.0153, 0.01),
('1Y', 0.0154, 0.01),
('2Y', 0.0155, 0.01),
('3Y', 0.0156, 0.01),
('4Y', 0.0157, 0.01),
('5Y', 0.0158, 0.01),
('7Y', 0.0159, 0.01),
('10Y', 0.0160, 0.01),
('15Y', 0.0161, 0.01),
('20Y', 0.0162, 0.01)]

models = [hw1f]
corrMatrix = mx.IdentityMatrix(len(models))

timegrid1 = mx.TimeDateGrid_Equal(refDate=ref_date, maxYear=3, nPerYear=1)

results2 = xen.generate(models=models, calcs=None, corr=corrMatrix, timegrid=timegrid1,
rsg=sobol_rsg, filename=filename2, isMomentMatching=False)

ndarray = results2.toNumpyArr()

I found out that ndarray output only contained the very first tenor(3M tenor), may I ask how I can get the whole term tenors generated rates, like 9M, 1Y, 2Y, 3Y,....

hi, jojogh
I think your question is about the calculation of SpotRates (9M, 1Y, 2Y, 3Y) using the short rate.
it's formula -> T-maturity discount bond

to add SpotRate associated hw1f model,

define calcs for 9m, 1y, 2y, 3y

hw1f_spot9m = hw1f.spot('hw1f_spot9m', maturityTenor=mx.Period(9, mx.Months), compounding=mx.Continuous)
hw1f_spot1y = hw1f.spot('hw1f_spot1y', maturityTenor=mx.Period(1, mx.Years), compounding=mx.Continuous)
hw1f_spot2y = hw1f.spot('hw1f_spot2y', maturityTenor=mx.Period(2, mx.Years), compounding=mx.Continuous)
hw1f_spot3y = hw1f.spot('hw1f_spot3y', maturityTenor=mx.Period(3, mx.Years), compounding=mx.Continuous)

calcs = [hw1f_spot9m, hw1f_spot1y, hw1f_spot2y, hw1f_spot3y]

update generation code ( add calcs to parameter )

results2 = xen.generate(models=models, calcs=calcs, corr=corrMatrix, timegrid=timegrid1,
rsg=sobol_rsg, filename=filename2, isMomentMatching=False)

I hope my answer is helpful.
thanks.

jojogh commented

Many thanks!!!