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


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

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


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

示例1: nextStep

void LongstaffSchwartzExerciseStrategy::nextStep(
    const CurveState& currentState) {
    principalInNumerairePortfolio_ = newPrincipal_;

    if (isRebateTime_[currentIndex_])
        exercise_->nextStep(currentState);
    if (isControlTime_[currentIndex_])
        control_->nextStep(currentState);
    if (isBasisTime_[currentIndex_])
        basisSystem_->nextStep(currentState);

    if (currentIndex_ < numeraires_.size()-1) {
        Size numeraire = numeraires_[currentIndex_];
        Size nextNumeraire = numeraires_[currentIndex_+1];
        newPrincipal_ *=
            currentState.discountRatio(numeraire, nextNumeraire);
    }

    ++currentIndex_;
}
开发者ID:Bernd8,项目名称:quantlib,代码行数:20,代码来源:lsstrategy.cpp

示例2: nextTimeStep

    bool MultiStepPeriodCapletSwaptions::nextTimeStep(
            const CurveState& currentState,
            std::vector<Size>& numberCashFlowsThisStep,
            std::vector<std::vector<MarketModelMultiProduct::CashFlow> >&
                                                               genCashFlows)
    {

     for (Size i=0; i < numberCashFlowsThisStep.size(); ++i)
        numberCashFlowsThisStep[i]=0UL;

    if (currentIndex_ >=offset_ && (currentIndex_ - offset_) % period_ ==0)
    {
        // caplet first
        Real df = currentState.discountRatio(currentIndex_ + period_, currentIndex_);
        Time tau = rateTimes_[currentIndex_+period_]- rateTimes_[currentIndex_];
        Real forward = (1.0/df-1.0)/tau;
        Real value = (*forwardPayOffs_[productIndex_])(forward);
        value *= tau*currentState.discountRatio(currentIndex_+period_,currentIndex_);

        if (value >0)
        {
            numberCashFlowsThisStep[productIndex_]=1UL;
            genCashFlows[productIndex_][0].amount = value;
            genCashFlows[productIndex_][0].timeIndex= productIndex_;
        }

        // now swaption

        unsigned long numberPeriods = numberBigFRAs_ - productIndex_;
        Real B = 0.0;
        double P0 = 1.0; // i.e currentState.discountRatio(currentIndex_,currentIndex_);
        Real Pn = currentState.discountRatio(currentIndex_ + numberPeriods*period_, currentIndex_);
        for (unsigned long i=0; i < numberPeriods; ++i)
        {
            Time tau = rateTimes_[currentIndex_+(i+1)*period_]- rateTimes_[currentIndex_+i*period_];
            B+= tau*currentState.discountRatio(currentIndex_+(i+1)*period_,currentIndex_);
        }


        Real swapRate = (P0-Pn)/B;

        Real swaptionValue=  (*swapPayOffs_[productIndex_])(swapRate);
        swaptionValue *=B;

        if (swaptionValue >0)
        {
            numberCashFlowsThisStep[productIndex_+numberBigFRAs_]=1UL;
            genCashFlows[productIndex_+numberBigFRAs_][0].amount = swaptionValue;
            genCashFlows[productIndex_+numberBigFRAs_][0].timeIndex=productIndex_+numberBigFRAs_;
       }

        ++productIndex_;

    }

    ++currentIndex_;

    bool terminate =(productIndex_ >= numberBigFRAs_);


    return terminate;
    }
开发者ID:pcaspers,项目名称:quantlib-old,代码行数:62,代码来源:multistepperiodcapletswaptions.cpp


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