当前位置: 首页>>代码示例>>C++>>正文


C++ CurveState::swapRate方法代码示例

本文整理汇总了C++中CurveState::swapRate方法的典型用法代码示例。如果您正苦于以下问题:C++ CurveState::swapRate方法的具体用法?C++ CurveState::swapRate怎么用?C++ CurveState::swapRate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CurveState的用法示例。


在下文中一共展示了CurveState::swapRate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: nextTimeStep

    bool MultiStepSwaption::nextTimeStep(
        const CurveState &currentState,
        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_;
    }
开发者ID:cathie912jin,项目名称:quantlib,代码行数:28,代码来源:multistepswaption.cpp

示例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;
     }
     
 }
开发者ID:pcaspers,项目名称:quantlib-old,代码行数:15,代码来源:custombasissystem.cpp

示例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; 
    }
开发者ID:cathie912jin,项目名称:quantlib,代码行数:47,代码来源:multistepvolswap.cpp


注:本文中的CurveState::swapRate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。