## HullWhite2FactorModelParameters

A set of parameters $\sigma_1, \sigma_2, \alpha_1, \alpha_2, \rho$ are estimated from ATM swaption volatilities. Swaption volatilities are preferred to caplets to better estimate $\rho$.Although assuming that $\sigma_1, \sigma_2$ are constant makes the calibration of this model considerably easier, in general, $\sigma_1, \sigma_2$ should be allowed a piecewise linear term structure dependent on the underlying swaptions.

For a set of $J$ ATM swaptions, we need to minimize:

Where $V_j(\sigma_1, \sigma_2, \alpha_1, \alpha_2, \rho)$ is the price of the $j^{th}$ swaption under the model, $V_j$ is the market value of the $j^{th}$ swaption and $\omega_j$ is the corresponding weight. The market value is calculated using the standard pricing functions

To find a good minimum of the model value, basin hopping as implemented here as well as least squares optimization are used.

The error $E$ is algorithmically differentiated and then solved via brute-force monte carlo using tensorflow and scipy.

If the currency of the interest rate is not the same as the base currency, then a quanto correction needs to be made. Assume $C$ is the value of the interest rate/FX correlation price factor (can be estimated from historical data), then the FX rate follows:

with $r(t)$ the short rate and $r_0(t)$ the short rate in base currency. The short rate with a quanto correction is:

where $W_1(t),W_2(t)$ and $W(t)$ are standard Wiener processes under the rate currency's risk neutral measure and $r_T(t,T)$ is the partial derivative of the instantaneous forward rate r(t,T) with respect to the maturity. date $T$. Define:

Then $\bar\rho_1, \bar\rho_2$ are assigned:

This is simply assumed to work