• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ QL_FAIL函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中QL_FAIL函数的典型用法代码示例。如果您正苦于以下问题:C++ QL_FAIL函数的具体用法?C++ QL_FAIL怎么用?C++ QL_FAIL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: switch

    void BarrierOption::arguments::validate() const {
        OneAssetOption::arguments::validate();

        switch (barrierType) {
          case Barrier::DownIn:
          case Barrier::UpIn:
          case Barrier::DownOut:
          case Barrier::UpOut:
            break;
          default:
            QL_FAIL("unknown type");
        }

        QL_REQUIRE(barrier != Null<Real>(), "no barrier given");
        QL_REQUIRE(rebate != Null<Real>(), "no rebate given");
    }
开发者ID:SePTimO7,项目名称:QuantLib,代码行数:16,代码来源:barrieroption.cpp


示例2: underlyingPriceDate

 // gets a price that can include an arbitrary number of basis curves
 inline Real CommodityCurve::price(
             const Date& d,
             const boost::shared_ptr<ExchangeContracts>& exchangeContracts,
             Integer nearbyOffset) const {
     Date date = nearbyOffset > 0 ?
         underlyingPriceDate(d, exchangeContracts, nearbyOffset) : d;
     Time t = timeFromReference(date);
     Real priceValue = 0;
     try {
         priceValue = priceImpl(t);
     } catch (const std::exception& e) {
         QL_FAIL("error retrieving price for curve [" << name() << "]: "
                 << e.what());
     }
     return priceValue + basisOfPriceImpl(t);
 }
开发者ID:androidYibo,项目名称:documents,代码行数:17,代码来源:commoditycurve.hpp


示例3: cap_floor

	std::vector<Real> cap_floor(Date evaluationDate,
		CapFloor::Type type,
		Real strike,
		Real nominal,
		Schedule schedule,
		Natural fixingDays,
		BusinessDayConvention convention,
		boost::shared_ptr<IborIndex> index,
		boost::shared_ptr<YieldTermStructure> termStructure,
		Volatility volatility) {

			Date todaysDate = evaluationDate;
			Settings::instance().evaluationDate() = todaysDate;
			std::vector<Real> nominals = std::vector<Real>(1, nominal);		

			/*Make Leg*/
			Leg leg = IborLeg(schedule, index)
				.withNotionals(nominals)
				.withPaymentDayCounter(index->dayCounter())
				.withPaymentAdjustment(convention)
				.withFixingDays(fixingDays);

			/*Make Engine*/
			Handle<Quote> vol(boost::shared_ptr<Quote>(new SimpleQuote(volatility)));
			boost::shared_ptr<PricingEngine> engine = 
				boost::shared_ptr<PricingEngine>(new BlackCapFloorEngine(Handle<YieldTermStructure>(termStructure), vol));

			/*Pricing*/
			boost::shared_ptr<CapFloor> testProduct;
			switch (type) {
			case CapFloor::Cap:
				testProduct = boost::shared_ptr<CapFloor>(new Cap(leg, std::vector<Rate>(1, strike)));
				break;
			case CapFloor::Floor:
				testProduct = boost::shared_ptr<CapFloor>(new Floor(leg, std::vector<Rate>(1, strike)));
				break;
			default:
				QL_FAIL("unknown cap/floor type");
			}

			testProduct->setPricingEngine(engine);

			std::vector<Real> rst;
			rst.push_back(testProduct->NPV());		
			return rst;

	}
开发者ID:fder78,项目名称:MyQuantLib,代码行数:47,代码来源:cap_floor_swaption.cpp


示例4: switch

    Date Date::advance(const Date& date, Integer n, TimeUnit units) {
        switch (units) {
          case Days:
            return date + n;
          case Weeks:
            return date + 7*n;
          case Months: {
            Day d = date.dayOfMonth();
            Integer m = Integer(date.month())+n;
            Year y = date.year();
            while (m > 12) {
                m -= 12;
                y += 1;
            }
            while (m < 1) {
                m += 12;
                y -= 1;
            }

            QL_ENSURE(y >= 1900 && y <= 2199,
                      "year " << y << " out of bounds. "
                      << "It must be in [1901,2199]");

            Integer length = monthLength(Month(m), isLeap(y));
            if (d > length)
                d = length;

            return Date(d, Month(m), y);
          }
          case Years: {
              Day d = date.dayOfMonth();
              Month m = date.month();
              Year y = date.year()+n;

              QL_ENSURE(y >= 1900 && y <= 2199,
                        "year " << y << " out of bounds. "
                        << "It must be in [1901,2199]");

              if (d == 29 && m == February && !isLeap(y))
                  d = 28;

              return Date(d,m,y);
          }
          default:
            QL_FAIL("undefined time units");
        }
    }
开发者ID:JingGuo0806,项目名称:quantlib-full,代码行数:47,代码来源:date.cpp


示例5: if

 Decimal operator/(const Money& m1, const Money& m2) {
     if (m1.currency() == m2.currency()) {
         return m1.value()/m2.value();
     } else if (Money::conversionType == Money::BaseCurrencyConversion) {
         Money tmp1 = m1;
         convertToBase(tmp1);
         Money tmp2 = m2;
         convertToBase(tmp2);
         return tmp1/tmp2;
     } else if (Money::conversionType == Money::AutomatedConversion) {
         Money tmp = m2;
         convertTo(tmp, m1.currency());
         return m1/tmp;
     } else {
         QL_FAIL("currency mismatch and no conversion specified");
     }
 }
开发者ID:SePTimO7,项目名称:QuantLib,代码行数:17,代码来源:money.cpp


示例6: close_enough

 bool close_enough(const Money& m1, const Money& m2, Size n) {
     if (m1.currency() == m2.currency()) {
         return close_enough(m1.value(),m2.value(),n);
     } else if (Money::conversionType == Money::BaseCurrencyConversion) {
         Money tmp1 = m1;
         convertToBase(tmp1);
         Money tmp2 = m2;
         convertToBase(tmp2);
         return close_enough(tmp1,tmp2,n);
     } else if (Money::conversionType == Money::AutomatedConversion) {
         Money tmp = m2;
         convertTo(tmp, m1.currency());
         return close_enough(m1,tmp,n);
     } else {
         QL_FAIL("currency mismatch and no conversion specified");
     }
 }
开发者ID:SePTimO7,项目名称:QuantLib,代码行数:17,代码来源:money.cpp


示例7: switch

 void BlackCalculator::Calculator::visit(CashOrNothingPayoff& payoff) {
     black_.alpha_ = black_.DalphaDd1_ = 0.0;
     black_.x_ = payoff.cashPayoff();
     black_.DxDstrike_ = 0.0;
     switch (payoff.optionType()) {
       case Option::Call:
         black_.beta_     = black_.cum_d2_;
         black_.DbetaDd2_ = black_.n_d2_;
         break;
       case Option::Put:
         black_.beta_     = 1.0-black_.cum_d2_;
         black_.DbetaDd2_ =    -black_.n_d2_;
         break;
       default:
         QL_FAIL("invalid option type");
     }
 }
开发者ID:NicholasBertocchi,项目名称:QuantLib,代码行数:17,代码来源:blackcalculator.cpp


示例8: switch

    std::vector<boost::function1<Real, Real> >
    LsmBasisSystem::pathBasisSystem(Size order, PolynomType polynomType) {

        std::vector<boost::function1<Real, Real> > ret;
        for (Size i=0; i<=order; ++i) {
            switch (polynomType) {
              case Monomial:
                  ret.push_back(MonomialFct(i));
                break;
              case Laguerre:
                ret.push_back(
                    bind(&GaussianOrthogonalPolynomial::weightedValue,
                                GaussLaguerrePolynomial(), i, _1));
                break;
              case Hermite:
                ret.push_back(
                    bind(&GaussianOrthogonalPolynomial::weightedValue,
                                GaussHermitePolynomial(), i, _1));
                break;
              case Hyperbolic:
                ret.push_back(
                    bind(&GaussianOrthogonalPolynomial::weightedValue,
                                GaussHyperbolicPolynomial(), i, _1));
                break;
              case Legendre:
                ret.push_back(
                    bind(&GaussianOrthogonalPolynomial::weightedValue,
                                GaussLegendrePolynomial(), i, _1));
                break;
              case Chebyshev:
                ret.push_back(
                    bind(&GaussianOrthogonalPolynomial::weightedValue,
                                GaussChebyshevPolynomial(), i, _1));
                break;
              case Chebyshev2nd:
                ret.push_back(
                    bind(&GaussianOrthogonalPolynomial::weightedValue,
                                GaussChebyshev2ndPolynomial(), i, _1));
                break;
              default:
                QL_FAIL("unknown regression type");
            }
        }

        return ret;
    }
开发者ID:shlagbaum,项目名称:quantlib-1.0,代码行数:46,代码来源:lsmbasissystem.cpp


示例9: switch

 std::ostream& operator<<(std::ostream& out,
                          SwapIndex::FixingType t) {
     switch (t) {
       case SwapIndex::IsdaFixA:
         return out << "IsdaFixA";
       case SwapIndex::IsdaFixB:
         return out << "IsdaFixB";
       case SwapIndex::IfrFix:
         return out << "IfrFix";
       case SwapIndex::IsdaFixAm:
         return out << "IsdaFixAm";
       case SwapIndex::IsdaFixPm:
         return out << "IsdaFixPm";
       default:
         QL_FAIL("unknown SwapIndex::FixingType(" << QuantLib::Integer(t) << ")");
     }
 }
开发者ID:AAthresh,项目名称:quantlib,代码行数:17,代码来源:swapindex.cpp


示例10: switch

 boost::shared_ptr<DayCounter::Impl>
 ActualActual::implementation(ActualActual::Convention c) {
     switch (c) {
       case ISMA:
       case Bond:
         return boost::shared_ptr<DayCounter::Impl>(new ISMA_Impl);
       case ISDA:
       case Historical:
       case Actual365:
         return boost::shared_ptr<DayCounter::Impl>(new ISDA_Impl);
       case AFB:
       case Euro:
         return boost::shared_ptr<DayCounter::Impl>(new AFB_Impl);
       default:
         QL_FAIL("unknown act/act convention");
     }
 }
开发者ID:AAthresh,项目名称:quantlib,代码行数:17,代码来源:actualactual.cpp


示例11: settlementImpl

 SouthKorea::SouthKorea(Market market) {
     // all calendar instances share the same implementation instance
     static boost::shared_ptr<Calendar::Impl> settlementImpl(
                                           new SouthKorea::SettlementImpl);
     static boost::shared_ptr<Calendar::Impl> krxImpl(
                                                  new SouthKorea::KrxImpl);
     switch (market) {
       case Settlement:
         impl_ = settlementImpl;
         break;
       case KRX:
         impl_ = krxImpl;
         break;
       default:
         QL_FAIL("unknown market");
     }
 }
开发者ID:lab616,项目名称:third_party,代码行数:17,代码来源:southkorea.cpp


示例12: x

    Real FilonIntegral::integrate(const ext::function<Real (Real)>& f,
                                  Real a, Real b) const {
        const Real h = (b-a)/(2*n_);
        Array x(2*n_+1, a, h);

        const Real theta = t_*h;
        const Real theta2 = theta*theta;
        const Real theta3 = theta2*theta;

        const Real alpha = 1/theta + std::sin(2*theta)/(2*theta2)
            - 2*square<Real>()(std::sin(theta))/theta3;
        const Real beta = 2*( (1+square<Real>()(std::cos(theta)))/theta2
            - std::sin(2*theta)/theta3);
        const Real gamma = 4*(std::sin(theta)/theta3 - std::cos(theta)/theta2);

        Array v(x.size());
        std::transform(x.begin(), x.end(), v.begin(), f);

        ext::function<Real(Real)> f1, f2;
        switch(type_) {
          case Cosine:
            f1 = static_cast<Real(*)(Real)>(std::sin);
            f2 = static_cast<Real(*)(Real)>(std::cos);
            break;
          case Sine:
            f1 = static_cast<Real(*)(Real)>(std::cos);
            f2 = static_cast<Real(*)(Real)>(std::sin);
            break;
          default:
            QL_FAIL("unknown integration type");
        }

        Real c_2n_1 = 0.0;
        Real c_2n = v[0]*f2(t_*a)
            - 0.5*(v[2*n_]*f2(t_*b) + v[0]*f2(t_*a));

        for (Size i=1; i <= n_; ++i) {
            c_2n   += v[2*i]  *f2(t_*x[2*i]);
            c_2n_1 += v[2*i-1]*f2(t_*x[2*i-1]);
        }

        return h*(alpha*(v[2*n_]*f1(t_*x[2*n_]) - v[0]*f1(t_*x[0]))
                  *((type_ == Cosine) ? 1.0 : -1.0)
                 + beta*c_2n + gamma*c_2n_1);
    }
开发者ID:SePTimO7,项目名称:QuantLib,代码行数:45,代码来源:filonintegral.cpp


示例13: if

boost::shared_ptr<QuantLib::OperatorND> qlOperatorFactory::operatorND(const boost::shared_ptr<FpmlSerialized::OperatorND>& xml_serial)
{
	boost::shared_ptr<QuantLib::OperatorND> ql_oper;

	std::string operNDType = xml_serial->getType()->SValue();

	if ( operNDType == "additionOperND" )
	{
		const boost::shared_ptr<FpmlSerialized::AdditionOperND>& xml_operND
			= xml_serial->getAdditionOperND();

		ql_oper = this->additionOperND(xml_operND);
	}
	else if ( operNDType == "multipleOperND" )
	{
		const boost::shared_ptr<FpmlSerialized::MultipleOperND>& xml_operND
			= xml_serial->getMultipleOperND();

		ql_oper = this->multipleOperND(xml_operND);
	}
	else if ( operNDType == "maximumOperND" )
	{
		const boost::shared_ptr<FpmlSerialized::MaximumOperND>& xml_operND
			= xml_serial->getMaximumOperND();

		ql_oper = this->maximumOperND(xml_operND);
	}
	else if ( operNDType == "divisionOperND" )
	{
		const boost::shared_ptr<FpmlSerialized::DivisionOperND>& xml_operND
			= xml_serial->getDivisionOperND();

		ql_oper = this->divisionOperND(xml_operND);
	}
	else if ( operNDType == "identityOperND" )
	{
		ql_oper = this->identityOperND();
	}
	else
	{
		QL_FAIL("unknown operNDType : " << operNDType);
	}

	return ql_oper;
}
开发者ID:minikie,项目名称:OTCDerivativesCalculatorModule,代码行数:45,代码来源:qlOperatorFactory.cpp


示例14: businessDayConvention

			QuantLib::BusinessDayConvention businessDayConvention(const std::string& typeStr)
			{
				QuantLib::BusinessDayConvention bdc;

				std::string upperStr = boost::to_upper_copy(typeStr);

				if(upperStr=="FOLLOWING")
				{
					bdc = QuantLib::Following;
				}
				else
				{
					QL_FAIL("unknown type calendar string");
				}

				return bdc;

			}
开发者ID:minikie,项目名称:OTCDerivativesCalculatorModule,代码行数:18,代码来源:qlBusinessDayConvention.hpp


示例15: N

		/*! The constructor takes as inputs
		- rateTimes		the libor grid points
		- mode			the parametrization mode, see below which are available
		- parameters	generic parameters describing the parameterization, see below for their meaning for each mode
		The following values for mode are possible and the following parameters must be given:
		- mode=0: N (N=number of libors) parameters must be given. The first parameter is the skew for the next libor not yet expired,
		the second one for the libor after that and so on.
		- mode=1: 2 Parameters \f$ (b_0, lambda) \f$ must be given. The skew for the ith not expired libor (i starting with 0) is
		\f$ 1.0 - b_0 e^{-\lambda i}\f$
		*/
		PiecewiseConstantBeta(std::vector<Time>& rateTimes,
			int mode, 
			std::vector<Real>& parameters
			) : rateTimes_(rateTimes), N_(rateTimes.size()-1), parameters_(parameters), mode_(mode) {

				// set number of parameters
				switch(mode_) {
					case 0: P_=N_;
						break;
					case 1: P_=2;
						break;
					default: QL_FAIL("mode " << mode_ << " not supported.");
				}

				// initialize beta
				beta_=std::vector<double>(N_,0.0);
				setParameters();
		}
开发者ID:cathie912jin,项目名称:quantlib,代码行数:28,代码来源:betaParametrization.hpp


示例16: Array

TridiagonalOperator::TridiagonalOperator(Size size) {
    if (size>=2) {
        n_ = size;
        diagonal_      = Array(size);
        lowerDiagonal_ = Array(size-1);
        upperDiagonal_ = Array(size-1);
        temp_          = Array(size);
    } else if (size==0) {
        n_ = 0;
        diagonal_      = Array(0);
        lowerDiagonal_ = Array(0);
        upperDiagonal_ = Array(0);
        temp_          = Array(0);
    } else {
        QL_FAIL("invalid size (" << size << ") for tridiagonal operator "
                "(must be null or >= 2)");
    }
}
开发者ID:Bernd8,项目名称:quantlib,代码行数:18,代码来源:tridiagonaloperator.cpp


示例17: QL_FAIL

    Real GaussJacobiPolynomial::beta(Size i) const {
        Real num = 4.0*i*(i+alpha_)*(i+beta_)*(i+alpha_+beta_);
        Real denom = (2.0*i+alpha_+beta_)*(2.0*i+alpha_+beta_)
                   * ((2.0*i+alpha_+beta_)*(2.0*i+alpha_+beta_)-1);

        if (!denom) {
            if (num != 0.0) {
                QL_FAIL("can't compute b_k for jacobi integration\n");
            } else {
                // l'Hospital
                num  = 4.0*i*(i+beta_)* (2.0*i+2*alpha_+beta_);
                denom= 2.0*(2.0*i+alpha_+beta_);
                denom*=denom-1;
                QL_ASSERT(denom, "can't compute b_k for jacobi integration\n");
            }
        }
        return num / denom;
    }
开发者ID:21hub,项目名称:QuantLib,代码行数:18,代码来源:gaussianorthogonalpolynomial.cpp


示例18: QL_FAIL

Date ComplexTimeFunctionVariableValue::calculateLastIndexFixing()
{
	if(!(this->variableBindingFlag_))
		QL_FAIL("variable is not bind");
		
	for(Size i=0;i<addedVariableValues_.size();++i)
	{
		const Date& roopDate = addedVariableValues_[i]->calculateLastIndexFixing();

		if( lastFixingDate_ < roopDate )
		{
			lastFixingDate_ = roopDate;
		}
	}

	return lastFixingDate_;
	
}
开发者ID:minikie,项目名称:OTCDerivativesCalculatorModule,代码行数:18,代码来源:ComplexTimeFunctionVariableValue.cpp


示例19: settlementImpl

 Brazil::Brazil(Brazil::Market market) {
     // all calendar instances on the same market share the same
     // implementation instance
     static boost::shared_ptr<Calendar::Impl> settlementImpl(
                                               new Brazil::SettlementImpl);
     static boost::shared_ptr<Calendar::Impl> exchangeImpl(
                                                 new Brazil::ExchangeImpl);
     switch (market) {
       case Settlement:
         impl_ = settlementImpl;
         break;
       case Exchange:
         impl_ = exchangeImpl;
         break;
       default:
         QL_FAIL("unknown market");
     }
 }
开发者ID:AAthresh,项目名称:quantlib,代码行数:18,代码来源:brazil.cpp


示例20: switch

    boost::shared_ptr<Fdm1dMesher>
    FdmVPPStepConditionFactory::stateMesher() const {
        Size nStates;
        switch (type_) {
          case Vanilla:
            nStates = 2*args_.tMinUp + args_.tMinDown;
            break;
          case StartLimit:
            nStates = FdmVPPStartLimitStepCondition::nStates(
                       args_.tMinUp,args_.tMinDown, args_.nStarts);
            break;
          default:
            QL_FAIL("vpp type is not supported");
        }

        return boost::shared_ptr<Fdm1dMesher>(
            new Uniform1dMesher(0.0, 1.0, nStates));
    }
开发者ID:21hub,项目名称:QuantLib,代码行数:18,代码来源:fdmvppstepconditionfactory.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ QL_REQUIRE函数代码示例发布时间:2022-05-30
下一篇:
C++ QLOG_WARN函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap