36 vector<ext::shared_ptr<SwapIndex> > swapIndexes,
37 ext::shared_ptr<IborIndex> iborIndex,
39 const vector<ext::shared_ptr<CmsCouponPricer> >& pricers,
41 : swapLengths_(
std::move(swapLengths)), swapIndexes_(
std::move(swapIndexes)),
42 iborIndex_(
std::move(iborIndex)), bidAskSpreads_(bidAskSpreads), pricers_(pricers),
43 discTS_(
std::move(discountingTS)),
45 nExercise_(swapLengths_.size()), nSwapIndexes_(swapIndexes_.size()),
46 swapTenors_(nSwapIndexes_),
48 spotFloatLegNPV_(nExercise_, nSwapIndexes_), spotFloatLegBPS_(nExercise_, nSwapIndexes_),
50 mktBidSpreads_(nExercise_, nSwapIndexes_), mktAskSpreads_(nExercise_, nSwapIndexes_),
52 mktSpreads_(nExercise_, nSwapIndexes_), mdlSpreads_(nExercise_, nSwapIndexes_),
53 errSpreads_(nExercise_, nSwapIndexes_),
55 mktSpotCmsLegNPV_(nExercise_, nSwapIndexes_), mdlSpotCmsLegNPV_(nExercise_, nSwapIndexes_),
56 errSpotCmsLegNPV_(nExercise_, nSwapIndexes_),
58 mktFwdCmsLegNPV_(nExercise_, nSwapIndexes_), mdlFwdCmsLegNPV_(nExercise_, nSwapIndexes_),
59 errFwdCmsLegNPV_(nExercise_, nSwapIndexes_),
61 spotSwaps_(nExercise_, vector<ext::shared_ptr<
Swap> >(nSwapIndexes_)),
62 fwdSwaps_(nExercise_, vector<ext::shared_ptr<
Swap> >(nSwapIndexes_)) {
65 <<
") != bidAskSpreads columns() ("
66 << bidAskSpreads[0].size() <<
")");
68 "nExercise_ (" <<
nExercise_ <<
") != bidAskSpreads rows() ("
69 << bidAskSpreads.size() <<
")");
94 .operator ext::shared_ptr<Swap>();
101 .operator ext::shared_ptr<Swap>();
110 Real mktPrevPart = 0.0, mdlPrevPart = 0.0;
122 false,
discTS_->referenceDate());
125 false,
discTS_->referenceDate());
156 Real meanReversion) {
158 ext::make_shared<SimpleQuote>(meanReversion));
164 ext::shared_ptr<MeanRevertingPricer> p =
165 ext::dynamic_pointer_cast<MeanRevertingPricer>(
167 QL_REQUIRE(p !=
nullptr,
"mean reverting pricer required at index " << j);
168 p->setMeanReversion(meanReversionQuote);
210 mean += w[i][j]*var[i][j]*var[i][j];
221 weightedVars[i*
nSwapIndexes_+j] = std::sqrt(w[i][j])*var[i][j];
Cash-flow analysis functions.
1-D array used in linear algebra.
static Real npv(const Leg &leg, const YieldTermStructure &discountCurve, bool includeSettlementDateFlows, Date settlementDate=Date(), Date npvDate=Date())
NPV of the cash flows.
static Real bps(const Leg &leg, const YieldTermStructure &discountCurve, bool includeSettlementDateFlows, Date settlementDate=Date(), Date npvDate=Date())
Basis-point sensitivity of the cash flows.
Array weightedFwdNpvErrors(const Matrix &weights)
void performCalculations() const override
Handle< YieldTermStructure > discTS_
std::vector< std::vector< Handle< Quote > > > bidAskSpreads_
std::vector< Period > swapTenors_
Real weightedSpotNpvError(const Matrix &weights)
Real weightedSpreadError(const Matrix &weights)
std::vector< ext::shared_ptr< CmsCouponPricer > > pricers_
Array weightedSpotNpvErrors(const Matrix &weights)
ext::shared_ptr< IborIndex > iborIndex_
Real weightedMean(const Matrix &var, const Matrix &weights) const
std::vector< std::vector< ext::shared_ptr< Swap > > > fwdSwaps_
std::vector< ext::shared_ptr< SwapIndex > > swapIndexes_
Array weightedMeans(const Matrix &var, const Matrix &weights) const
void reprice(const Handle< SwaptionVolatilityStructure > &volStructure, Real meanReversion)
CmsMarket(std::vector< Period > swapLengths, std::vector< ext::shared_ptr< SwapIndex > > swapIndexes, ext::shared_ptr< IborIndex > iborIndex, const std::vector< std::vector< Handle< Quote > > > &bidAskSpreads, const std::vector< ext::shared_ptr< CmsCouponPricer > > &pricers, Handle< YieldTermStructure > discountingTS)
Array weightedSpreadErrors(const Matrix &weights)
Real weightedFwdNpvError(const Matrix &weights)
std::vector< std::vector< ext::shared_ptr< Swap > > > spotSwaps_
std::vector< Period > swapLengths_
Shared handle to an observable.
virtual void calculate() const
helper class for instantiating CMS
MakeCms & withDiscountingTermStructure(const Handle< YieldTermStructure > &discountingTermStructure)
MakeCms & withCmsCouponPricer(const ext::shared_ptr< CmsCouponPricer > &couponPricer)
Matrix used in linear algebra.
template class providing a null value for a given type.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
std::size_t Size
size of a container
Helper class to instantiate standard market CMS.
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
ext::shared_ptr< BlackVolTermStructure > v
Interest-rate term structure.