Posted by
Luigi Ballabio-2 on
URL: http://quantlib.414.s1.nabble.com/Hull-White-Calibration-tp2662p2668.html
At 03:16 PM 9/16/03, Perissin Francesco wrote:
>I am calibrating my Hull-White model in QL 0.3.1 using more or less the
>same code given in bermudan swaption example. This means considering a set
>of calibration helpers, and finding the parameters alfa and sigma that
>minimize the error function, via the simplex optimization method.
>
>Now I'd like to modify slightly this code, in order to keep a given alfa
>and to find the best sigma. Clearly, this is a much simpler problem since
>I have a single parameter to calibrate. Unfortunately, I am not an expert
>user of the library and I'd need some hints in order to reach the goal in
>a "decent" way...
Hi Francesco,
long time no see. Upon a superficial inspection of the code, it seems
to me that Sad didn't leave a hook for doing what you need. Were I to
tackle it, I would do something like:
1) create a new class:
class FixedAlphaHullWhite : public HullWhite { ... };
2) inside the new class, define an inner class:
class FixedAlphaConstraint : public Constraint { ... };
equal to Model::PrivateConstraint, but whose method test() works as:
if (params[0] != fixedAlpha_)
return false;
else {
... // same as PrivateConstraint
}
and whose constructor accepts and store the fixed alpha value besides the
other parameters;
3) define the constructor of the FixedAlphaHullWhite class as:
FixedAlphaHullWhite(const RelinkableHandle<TermStructure>& ts,
double a, double sigma = 0.01)
: HullWhite(ts,a,sigma) {
constraint_ = Handle<Constraint>(
new FixedAlphaConstraint(a, arguments_));
}
4) cross your fingers, compile and hope for the best as the above is highly
untested.
5) add a feature request to the QuantLib tracker
(
https://sourceforge.net/tracker/?group_id=12740&atid=362740)
called "Adding custom constraints to short-rate model calibration" or
something of the kind. Describe the problem shortly.
Hope this helps,
Luigi