本文整理汇总了C++中CurveState::swapRate方法的典型用法代码示例。如果您正苦于以下问题:C++ CurveState::swapRate方法的具体用法?C++ CurveState::swapRate怎么用?C++ CurveState::swapRate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CurveState
的用法示例。
在下文中一共展示了CurveState::swapRate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nextTimeStep
bool MultiStepSwaption::nextTimeStep(
const CurveState ¤tState,
std::vector<Size> &numberCashFlowsThisStep,
std::vector<std::vector<MarketModelMultiProduct::CashFlow> > &
genCashFlows) {
if (currentIndex_ == startIndex_) {
genCashFlows[0][0].timeIndex = 0;
// Rate swapRate =
// currentState.cmSwapRate(startIndex_,endIndex_-startIndex_);
// Real annuity =
// currentState.cmSwapAnnuity(startIndex_,startIndex_,endIndex_-startIndex_);
Rate swapRate =
currentState.swapRate(startIndex_, endIndex_, step_);
Real annuity = currentState.swapAnnuity(startIndex_, startIndex_,
endIndex_, step_);
genCashFlows[0][0].amount = (*payoff_)(swapRate) * annuity;
// std::max(swapRate-payoff_->strike(),0.0) * annuity; // test
numberCashFlowsThisStep[0] =
genCashFlows[0][0].amount != 0.0 ? 1 : 0;
} else {
numberCashFlowsThisStep[0] = 0;
}
++currentIndex_;
return currentIndex_ > startIndex_;
}
示例2: values
void CustomBasisSystem::values(const CurveState& currentState,
std::vector<Real>& results) const {
results.reserve(startByCurrentIndex_.size()+1);
results.resize(1);
results[0] = 1.0;
// std::cout << "Custom basis system:" << std::endl;
for(Size i=0;i<startByCurrentIndex_.size();i++) {
results.push_back(currentState.swapRate(startByCurrentIndex_[i](currentIndex_),
endByCurrentIndex_[i](currentIndex_),
step_));
// std::cout << "rate (" << startByCurrentIndex_[i](currentIndex_) << ";" <<
// endByCurrentIndex_[i](currentIndex_) << ";" << step_ << ") " << results.back() << std::endl;
}
}
示例3: nextTimeStep
bool MultiStepVolSwap::nextTimeStep(
const CurveState& currentState,
std::vector<Size>& numberCashFlowsThisStep,
std::vector<std::vector<MarketModelMultiProduct::CashFlow> >& genCashFlows)
{
//std::cout << "currentIndex=" << currentIndex_ << std::endl;
Rate referenceRate = currentState.swapRate(referenceRateIndices_.first, referenceRateIndices_.second, referenceRateStep_ );
for(Size i=8; i>=1; i--) referenceRateFixings_[i] = referenceRateFixings_[i-1];
referenceRateFixings_[0] = referenceRate;
Size noCf=0;
if(currentIndex_ == floatingFixingIndices_[currentFloatingIndex_]) {
Rate liborRate = currentState.forwardRate(currentFloatingIndex_);
//std::cout << "generate float payment @" << floatingPaymentIndices_[currentFloatingIndex_] << std::endl;
genCashFlows[0][noCf].timeIndex = floatingPaymentIndices_[currentFloatingIndex_];
genCashFlows[0][noCf].amount = (payer_ ? 1.0 : -1.0)*liborRate*floatingAccruals_[currentFloatingIndex_];
noCf++;
currentFloatingIndex_++;
}
if(currentIndex_ == structuredFixingIndices_[currentStructuredIndex_]) {
//std::cout << "generate structured payment @" << paymentTimes_[structuredPaymentIndices_[currentStructuredIndex_]] << std::endl;
Real volIdx = (fabs(referenceRateFixings_[1]-referenceRateFixings_[5])+
fabs(referenceRateFixings_[2]-referenceRateFixings_[6])+
fabs(referenceRateFixings_[3]-referenceRateFixings_[7])+
fabs(referenceRateFixings_[4]-referenceRateFixings_[8])) / 4.0;
genCashFlows[0][noCf].timeIndex = structuredPaymentIndices_[currentStructuredIndex_];
genCashFlows[0][noCf].amount = ( (currentStructuredIndex_== (Size)filterStructuredIndex_ || filterStructuredIndex_== -1) ? 1.0 : 0.0)*(payer_ ? -1.0 : 1.0)*structuredAccruals_[currentStructuredIndex_]*std::max(floor_,fixedRate_+multiplier_*volIdx);
//genCashFlows[0][noCf].amount = (currentIndex_==structuredFixingIndices_[0] ? 1.0 : 0.0)*std::max(referenceRate-fixedRate_,0.0)*currentState.swapAnnuity(12,12,52,2); // TEST (plain vanilla swaption payoff)
noCf++;
currentStructuredIndex_++;
}
numberCashFlowsThisStep[0] = noCf;
++currentIndex_;
bool done = (floatingFixingIndices_[currentFloatingIndex_] == QL_MAX_INTEGER && structuredFixingIndices_[currentStructuredIndex_] == QL_MAX_INTEGER );
//std::cout << "ok, finished = " << done << std::endl;
return done;
}