Does anyone know how to replace a value in a yield curve object for revaluing a bond (to get partial durations)? I suppose you could re-do all of these steps again, but it seems like there's a better way to just adjust it in place?
http://khandrikacm.blogspot.com/2014/03/usd-yield-curve-building-using-python.html
If the setup is as in the page you linked, then it's as simple as writing (for instance):
swaps[(5,Years)].setValue(0.016)
setting a new value will cause the curve to be marked as out of date: the next time you ask the bond for its value, the curve will automatically recalculate and the bond will return the updated price.
See also QuantLib: Building Key Rate Risks to see how to bump the curve in a different way.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.