36 ext::shared_ptr<PiecewiseConstantCorrelation> corr,
37 std::vector<ext::shared_ptr<PiecewiseConstantVariance> > displacedSwapVariances,
38 std::vector<Volatility> mktCapletVols,
39 ext::shared_ptr<CurveState> cs,
41 : evolution_(
std::move(evolution)), corr_(
std::move(corr)),
42 displacedSwapVariances_(
std::move(displacedSwapVariances)),
43 mktCapletVols_(
std::move(mktCapletVols)), mdlCapletVols_(evolution_.numberOfRates()),
44 mktSwaptionVols_(evolution_.numberOfRates()), mdlSwaptionVols_(evolution_.numberOfRates()),
45 cs_(
std::move(cs)), displacement_(displacement), numberOfRates_(evolution_.numberOfRates()) {
50 const std::vector<Volatility>&
54 "index (" << i <<
") must less than number of rates (" <<
59 const std::vector<Volatility>&
63 "index (" << i <<
") must less than number of rates (" <<
71 const std::vector<ext::shared_ptr<
73 displacedSwapVariances,
74 const std::vector<Volatility>& mktCapletVols,
77 const std::vector<Time>& evolutionTimes = evolution.
evolutionTimes();
81 <<
" not equal to correlation times "
84 const std::vector<Time>& rateTimes = evolution.
rateTimes();
86 "mismatch between EvolutionDescription and "
87 "CurveState rate times");
90 QL_REQUIRE(numberOfRates==displacedSwapVariances.size(),
91 "mismatch between EvolutionDescription number of rates ("
92 << numberOfRates <<
") and displacedSwapVariances size ("
93 << displacedSwapVariances.size() <<
")");
95 "mismatch between EvolutionDescription number of rates ("
96 << numberOfRates <<
") and corr number of rates ("
99 "mismatch between EvolutionDescription number of rates ("
100 << numberOfRates <<
") and mktCapletVols size ("
103 "mismatch between EvolutionDescription number of rates ("
104 << numberOfRates <<
") and CurveState number of rates ("
107 std::vector<Time> temp(rateTimes.begin(), rateTimes.end()-1);
109 "mismatch between evolutionTimes and rateTimes");
112 displacedSwapVariances.back()->totalVolatility(numberOfRates-1);
114 "last caplet vol (" << std::setprecision(16) <<
116 ") must be equal to last swaption vol (" <<
117 lastSwaptionVol <<
"); discrepancy is " <<
124 Real capletVolTolerance,
126 Natural innerSolvingMaxIterations,
127 Real innerSolvingTolerance) {
149 innerSolvingMaxIterations,
150 innerSolvingTolerance);
152 ext::shared_ptr<MarketModel> ctsmm(
new
155 cs_->coterminalSwapRates(),
157 const Matrix& swaptionTotCovariance =
161 const Matrix& capletTotCovariance =
174 mdlCapletVols_[i] = std::sqrt(capletTotCovariance[i][i]/rateTimes[i]);
185 }
while (iterations<maxIterations &&
188 ext::shared_ptr<MarketModel> ctsmm(
new
191 cs_->coterminalSwapRates(),
197 ctsmm->timeDependentVolatility(i));
ext::shared_ptr< PiecewiseConstantCorrelation > corr_
std::vector< std::vector< Volatility > > timeDependentCalibratedSwaptionVols_
const std::vector< Volatility > & timeDependentCalibratedSwaptionVols(Size i) const
std::vector< Volatility > mktCapletVols_
ext::shared_ptr< CurveState > cs_
std::vector< Volatility > mktSwaptionVols_
bool calibrate(Natural numberOfFactors, Natural maxIterations, Real tolerance, Natural innerMaxIterations=100, Real innerTolerance=1e-8)
static void performChecks(const EvolutionDescription &evolution, const PiecewiseConstantCorrelation &corr, const std::vector< ext::shared_ptr< PiecewiseConstantVariance > > &displacedSwapVariances, const std::vector< Volatility > &mktCapletVols, const CurveState &cs)
std::vector< Spread > displacements() const
std::vector< Volatility > mdlSwaptionVols_
std::vector< ext::shared_ptr< PiecewiseConstantVariance > > displacedSwapVariances_
virtual Natural calibrationImpl_(Natural numberOfFactors, Natural innerMaxIterations, Real innerTolerance)=0
std::vector< Volatility > usedCapletVols_
EvolutionDescription evolution_
const std::vector< Volatility > & timeDependentUnCalibratedSwaptionVols(Size i) const
const std::vector< Volatility > & mktCapletVols() const
std::vector< Volatility > mdlCapletVols_
CTSMMCapletCalibration(EvolutionDescription evolution, ext::shared_ptr< PiecewiseConstantCorrelation > corr, std::vector< ext::shared_ptr< PiecewiseConstantVariance > > displacedSwapVariances, std::vector< Volatility > mktCapletVols, ext::shared_ptr< CurveState > cs, Spread displacement)
std::vector< Matrix > swapCovariancePseudoRoots_
Curve state for market-model simulations
Size numberOfRates() const
const std::vector< Time > & rateTimes() const
Market-model evolution description.
Size numberOfRates() const
const std::vector< Time > & rateTimes() const
const std::vector< Time > & evolutionTimes() const
virtual const Matrix & totalCovariance(Size endIndex) const
Matrix used in linear algebra.
virtual Size numberOfRates() const =0
virtual const std::vector< Time > & times() const =0
floating-point comparisons
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
detail::sequence_holder< typename Container::const_iterator > sequence(const Container &c)
output STL-compliant containers as space-separated sequences
unsigned QL_INTEGER Natural
positive integer
Real Volatility
volatility
Real Spread
spreads on interest rates
std::size_t Size
size of a container
bool close(const Quantity &m1, const Quantity &m2, Size n)
pseudo square root of a real symmetric matrix
Utility functions for mapping between swap rate and forward rate.