本文整理汇总了C++中CurveState::forwardRate方法的典型用法代码示例。如果您正苦于以下问题:C++ CurveState::forwardRate方法的具体用法?C++ CurveState::forwardRate怎么用?C++ CurveState::forwardRate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CurveState
的用法示例。
在下文中一共展示了CurveState::forwardRate方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nextTimeStep
bool OneStepCoterminalSwaps::nextTimeStep(
const CurveState& currentState,
std::vector<Size>& numberCashFlowsThisStep,
std::vector<std::vector<MarketModelMultiProduct::CashFlow> >&
genCashFlows) {
std::fill(numberCashFlowsThisStep.begin(),
numberCashFlowsThisStep.end(),0);
for (Size indexOfTime=0;indexOfTime<lastIndex_;indexOfTime++) {
Rate liborRate = currentState.forwardRate(indexOfTime);
for (Size i=0;i<=indexOfTime;i++) {
genCashFlows[i][(indexOfTime-i)*2].timeIndex = indexOfTime;
genCashFlows[i][(indexOfTime-i)*2].amount =
-fixedRate_*fixedAccruals_[indexOfTime];
genCashFlows[i][(indexOfTime-i)*2+1].timeIndex = indexOfTime;
genCashFlows[i][(indexOfTime-i)*2+1].amount =
liborRate*floatingAccruals_[indexOfTime];
numberCashFlowsThisStep[i] += 2;
}
}
return true ;
}
示例2: nextTimeStep
bool MultiStepTarn::nextTimeStep(
const CurveState& currentState,
std::vector<Size>& numberCashFlowsThisStep,
std::vector<std::vector<MarketModelMultiProduct::CashFlow> >&
genCashFlows)
{
Rate liborRate = currentState.forwardRate(currentIndex_);
numberCashFlowsThisStep[0] =2;
genCashFlows[0][0].amount = (liborRate+floatingSpreads_[currentIndex_])*accrualsFloating_[currentIndex_];
genCashFlows[0][0].timeIndex = lastIndex_ + currentIndex_;
genCashFlows[0][1].timeIndex = currentIndex_;
Real obviousCoupon = std::max(strikes_[currentIndex_] - multipliers_[currentIndex_]*liborRate,0.0)*accruals_[currentIndex_];
couponPaid_+= obviousCoupon;
++currentIndex_;
if (couponPaid_ < totalCoupon_ && currentIndex_ < lastIndex_ )
{
genCashFlows[0][1].amount = - obviousCoupon;
return false;
}
Real coupon = obviousCoupon +(totalCoupon_ -couponPaid_);
genCashFlows[0][1].amount = - coupon;
return true;
}
示例3: values
void SwapBasisSystem::values(const CurveState& currentState,
std::vector<Real>& results) const {
Size rateIndex = rateIndex_[currentIndex_-1];
results.reserve(3);
results.resize(2);
results[0] = 1.0;
results[1] = currentState.forwardRate(rateIndex);
if (rateIndex < rateTimes_.size()-2)
results.push_back(currentState.coterminalSwapRate(rateIndex+1));
}
示例4: nextTimeStep
bool MultiStepForwards::nextTimeStep(
const CurveState& currentState,
std::vector<Size>& numberCashFlowsThisStep,
std::vector<std::vector<MarketModelMultiProduct::CashFlow> >&
genCashFlows) {
Rate liborRate = currentState.forwardRate(currentIndex_);
genCashFlows[currentIndex_][0].timeIndex = currentIndex_;
genCashFlows[currentIndex_][0].amount =
(liborRate-strikes_[currentIndex_])*accruals_[currentIndex_];
std::fill(numberCashFlowsThisStep.begin(),
numberCashFlowsThisStep.end(),0);
numberCashFlowsThisStep[currentIndex_] = 1;
++currentIndex_;
return (currentIndex_ == strikes_.size());
}
示例5: 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;
}
示例6: nextTimeStep
bool OneStepOptionlets::nextTimeStep(
const CurveState& currentState,
std::vector<Size>& numberCashFlowsThisStep,
std::vector<std::vector<MarketModelMultiProduct::CashFlow> >&
genCashFlows) {
std::fill(numberCashFlowsThisStep.begin(),
numberCashFlowsThisStep.end(), 0);
for (Size i=0; i<payoffs_.size(); ++i) {
Rate liborRate = currentState.forwardRate(i);
Real payoff = (*payoffs_[i])(liborRate);
if (payoff>0.0) {
numberCashFlowsThisStep[i] = 1;
genCashFlows[i][0].timeIndex = i;
genCashFlows[i][0].amount = payoff*accruals_[i];
}
}
return true;
}
示例7: nextTimeStep
bool MarketModelPathwiseSwap::nextTimeStep(
const CurveState& currentState,
std::vector<Size>& numberCashFlowsThisStep,
std::vector<std::vector<MarketModelPathwiseMultiProduct::CashFlow> >& cashFlowsGenerated)
{
Rate liborRate = currentState.forwardRate(currentIndex_);
cashFlowsGenerated[0][0].timeIndex = currentIndex_+1;
cashFlowsGenerated[0][0].amount[0] =
(liborRate-strikes_[currentIndex_])*accruals_[currentIndex_]*multiplier_;
numberCashFlowsThisStep[0] = 1;
for (Size i=1; i <= numberRates_; ++i)
cashFlowsGenerated[0][0].amount[i] =0;
cashFlowsGenerated[0][0].amount[currentIndex_+1] = accruals_[currentIndex_]*multiplier_;
++currentIndex_;
return (currentIndex_ == strikes_.size());
}
示例8: nextTimeStep
bool MultiStepRatchet::nextTimeStep(
const CurveState& currentState,
std::vector<Size>& numberCashFlowsThisStep,
std::vector<std::vector<MarketModelMultiProduct::CashFlow> >&
genCashFlows)
{
Rate liborRate = currentState.forwardRate(currentIndex_);
Real currentCoupon = std::max(gearingOfFloor_* floor_ + spreadOfFloor_,
gearingOfFixing_* liborRate + spreadOfFixing_);
genCashFlows[0][0].timeIndex = currentIndex_;
genCashFlows[0][0].amount =
multiplier_* accruals_[currentIndex_]*currentCoupon;
//floor_ = liborRate; //StepRatchet
floor_ = currentCoupon; //FullRatchet
numberCashFlowsThisStep[0] = 1;
++currentIndex_;
return (currentIndex_ == lastIndex_);
}
示例9: nextTimeStep
bool MultiStepSwap::nextTimeStep(
const CurveState& currentState,
std::vector<Size>& numberCashFlowsThisStep,
std::vector<std::vector<MarketModelMultiProduct::CashFlow> >&
genCashFlows)
{
Rate liborRate = currentState.forwardRate(currentIndex_);
genCashFlows[0][0].timeIndex = currentIndex_;
genCashFlows[0][0].amount =
-multiplier_*fixedRate_*fixedAccruals_[currentIndex_];
genCashFlows[0][1].timeIndex = currentIndex_;
genCashFlows[0][1].amount =
multiplier_*liborRate*floatingAccruals_[currentIndex_];
numberCashFlowsThisStep[0] = 2;
++currentIndex_;
return (currentIndex_ == lastIndex_);
}
示例10: nextTimeStep
bool MarketModelPathwiseInverseFloater::nextTimeStep(
const CurveState& currentState,
std::vector<Size>& numberCashFlowsThisStep,
std::vector<std::vector<MarketModelPathwiseMultiProduct::CashFlow> >& cashFlowsGenerated)
{
numberCashFlowsThisStep[0] =1 ;
for (Size i=1; i <= lastIndex_; ++i)
cashFlowsGenerated[0][0].amount[i] =0;
Rate liborRate = currentState.forwardRate(currentIndex_);
Real inverseFloatingCoupon = std::max((fixedStrikes_[currentIndex_] - fixedMultipliers_[currentIndex_]*liborRate),0.0)*fixedAccruals_[currentIndex_] ;
Real floatingCoupon = (liborRate+floatingSpreads_[currentIndex_])*floatingAccruals_[currentIndex_];
cashFlowsGenerated[0][0].timeIndex = currentIndex_;
cashFlowsGenerated[0][0].amount[0] =multiplier_*(inverseFloatingCoupon - floatingCoupon);
if (inverseFloatingCoupon > 0.0)
{
cashFlowsGenerated[0][0].amount[currentIndex_+1] =multiplier_*( - fixedMultipliers_[currentIndex_]*fixedAccruals_[currentIndex_] - floatingAccruals_[currentIndex_]);
}
else
{
cashFlowsGenerated[0][0].amount[currentIndex_+1] =-multiplier_*floatingAccruals_[currentIndex_];
}
++currentIndex_;
return (currentIndex_ == lastIndex_);
}
示例11: nextTimeStep
bool MultiStepCoinitialSwaps::nextTimeStep(
const CurveState& currentState,
std::vector<Size>& numberCashFlowsThisStep,
std::vector<std::vector<MarketModelMultiProduct::CashFlow> >&
genCashFlows) {
Rate liborRate = currentState.forwardRate(currentIndex_);
std::fill(numberCashFlowsThisStep.begin(),
numberCashFlowsThisStep.end(),0);
for (Size i=currentIndex_;i<lastIndex_;i++) {
genCashFlows[i][0].timeIndex = currentIndex_;
genCashFlows[i][0].amount =
-fixedRate_*fixedAccruals_[currentIndex_];
genCashFlows[i][1].timeIndex = currentIndex_;
genCashFlows[i][1].amount =
liborRate*floatingAccruals_[currentIndex_];
numberCashFlowsThisStep[i] = 2;
}
++currentIndex_;
return (currentIndex_ == lastIndex_);
}