Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jojogh opened this issue Nov 6, 2023 · 2 comments
Assignees

Comments

@jojogh
Copy link

jojogh commented Nov 6, 2023

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,....

@montrixdev
Copy link
Owner

montrixdev commented Nov 6, 2023

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.

@montrixdev montrixdev self-assigned this Nov 6, 2023
@jojogh
Copy link
Author

jojogh commented Nov 7, 2023

Many thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants