當前位置: 首頁>>代碼示例>>C#>>正文


C# QLNet.Period類代碼示例

本文整理匯總了C#中QLNet.Period的典型用法代碼示例。如果您正苦於以下問題:C# Period類的具體用法?C# Period怎麽用?C# Period使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Period類屬於QLNet命名空間,在下文中一共展示了Period類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: dates

        //! \name Volatility
        /*! by default, inflation is observed with the lag
            of the term structure.

            Because inflation is highly linked to dates (for
            interpolation, periods, etc) time-based overload of the
            methods are not provided.
        */

        //@{
        //! Returns the volatility for a given maturity date and strike rate.
        double volatility(Date maturityDate, double strike,
                           Period obsLag = null,
                           bool extrapolate = false)
        {
            if (obsLag == null)
                obsLag = new Period(-1, TimeUnit.Days);

            Period useLag = obsLag;
            if (obsLag == new Period(-1, TimeUnit.Days))
            {
                useLag = observationLag();
            }

            if (indexIsInterpolated())
            {
                checkRange(maturityDate - useLag, strike, extrapolate);
                double t = timeFromReference(maturityDate - useLag);
                return volatilityImpl(t, strike);
            }
            else
            {
                KeyValuePair<Date, Date> dd = Utils.inflationPeriod(maturityDate - useLag, frequency());
                checkRange(dd.Key, strike, extrapolate);
                double t = timeFromReference(dd.Key);
                return volatilityImpl(t, strike);
            }
        }
開發者ID:minikie,項目名稱:test,代碼行數:38,代碼來源:CPIVolatilitySurface.cs

示例2: CallableBondConstantVolatility

 public CallableBondConstantVolatility(int settlementDays, Calendar calendar, double volatility, DayCounter dayCounter)
    :base(settlementDays, calendar)
 {
    volatility_ = new Handle<Quote>(new SimpleQuote(volatility));
    dayCounter_ = dayCounter;
    maxBondTenor_ = new Period(100,TimeUnit.Years);
 }
開發者ID:minikie,項目名稱:OTCDerivativesCalculatorModule,代碼行數:7,代碼來源:CallableBondConstantVolatility.cs

示例3: AmortizingFixedRateBond

      public AmortizingFixedRateBond(
                          int settlementDays,
                          Calendar calendar,
                          double faceAmount,
                          Date startDate,
                          Period bondTenor,
                          Frequency sinkingFrequency,
                          double coupon,
                          DayCounter accrualDayCounter,
                          BusinessDayConvention paymentConvention = BusinessDayConvention.Following,
                          Date issueDate = null)
         :base(settlementDays, calendar, issueDate)
      {
         frequency_ = sinkingFrequency;
         dayCounter_ = accrualDayCounter;

         Utils.QL_REQUIRE( bondTenor.length() > 0,() =>
                  "bond tenor must be positive. "
                  + bondTenor + " is not allowed." );

         maturityDate_ = startDate + bondTenor;
         maturityDate_ = startDate + bondTenor;
         schedule_ = sinkingSchedule(startDate, bondTenor, sinkingFrequency, calendar);
         cashflows_ = new FixedRateLeg(schedule_)
                        .withCouponRates(coupon, accrualDayCounter)
                        .withNotionals(sinkingNotionals(bondTenor, sinkingFrequency, coupon, faceAmount))        
                        .withPaymentAdjustment(paymentConvention).value();

         addRedemptionsToCashflows();

      }
開發者ID:akasolace,項目名稱:qlnet,代碼行數:31,代碼來源:AmortizingFixedRateBond.cs

示例4: BlackVanillaOptionPricer

 public BlackVanillaOptionPricer(double forwardValue, Date expiryDate, Period swapTenor, SwaptionVolatilityStructure volatilityStructure) {
     forwardValue_ = forwardValue;
     expiryDate_ = expiryDate;
     swapTenor_ = swapTenor;
     volatilityStructure_ = volatilityStructure;
     smile_ = volatilityStructure_.smileSection(expiryDate_, swapTenor_);
 }
開發者ID:minikie,項目名稱:test,代碼行數:7,代碼來源:ConundrumPricer.cs

示例5: SwapRateHelper

        public SwapRateHelper(double rate, Period tenor, Calendar calendar,
            Frequency fixedFrequency, BusinessDayConvention fixedConvention, DayCounter fixedDayCount,
            IborIndex iborIndex)
            : this(rate, tenor, calendar, fixedFrequency, fixedConvention, fixedDayCount, iborIndex,
		                      	     new Handle<Quote>(), new Period(0, TimeUnit.Days))
        {
        }
開發者ID:StreetConnect,項目名稱:QLNet,代碼行數:7,代碼來源:SwapRateHelper.cs

示例6: volatility

 //! returns the volatility for a given option date and swap tenor
 public double volatility(Date optionDate, Period swapTenor, double strike, bool extrapolate = false)
 {
    checkSwapTenor(swapTenor, extrapolate);
    checkRange(optionDate, extrapolate);
    checkStrike(strike, extrapolate);
    return volatilityImpl(optionDate, swapTenor, strike);
 }
開發者ID:minikie,項目名稱:test,代碼行數:8,代碼來源:SwaptionVolatilityStructure.cs

示例7: testCashedValues

        public void testCashedValues()
        {
            Date startDate = new Date(01, 03, 2007);
             Period period = new Period(360, TimeUnit.Months);
             Calendar calendar = new TARGET();
             Date endDate = calendar.advance(startDate,period,BusinessDayConvention.Unadjusted);

             Schedule schedule = new Schedule( startDate, endDate, new Period(1,TimeUnit.Months), calendar,
                                           BusinessDayConvention.Unadjusted,
                                           BusinessDayConvention.Unadjusted,
                                           DateGeneration.Rule.Backward, false);

             // PSA 100%
             PSACurve psa100 = new PSACurve(startDate);
             double[] listCPR = {0.2000,0.4000,0.6000,0.8000,1.0000,1.2000,1.4000,1.6000,1.8000,2.0000,2.2000,2.4000,2.6000,2.8000,
                             3.0000,3.2000,3.4000,3.6000,3.8000,4.0000,4.2000,4.4000,4.6000,4.8000,5.0000,5.2000,5.4000,5.6000,
                             5.8000,6.0000};

             for (int i = 0; i < schedule.Count; i++)
             {
            if ( i <= 29 )
               Assert.AreEqual(listCPR[i], psa100.getCPR(schedule[i])*100,0.001);
            else
               Assert.AreEqual(6.0000, psa100.getCPR(schedule[i])*100);
             }
        }
開發者ID:akasolace,項目名稱:qlnet,代碼行數:26,代碼來源:T_PSACurve.cs

示例8: YoYInflationCoupon

 public YoYInflationCoupon(Date paymentDate, double nominal, Date startDate, Date endDate, int fixingDays, YoYInflationIndex yoyIndex, Period observationLag, DayCounter dayCounter, double gearing, double spread, Date refPeriodStart, Date refPeriodEnd)
     : base(paymentDate, nominal, startDate, endDate, fixingDays, yoyIndex, observationLag, dayCounter, refPeriodStart, refPeriodEnd)
 {
     yoyIndex_ = yoyIndex;
     gearing_ = gearing;
     spread_ = spread;
 }
開發者ID:vdt,項目名稱:QLNet,代碼行數:7,代碼來源:YoYInflationCoupon.cs

示例9: SwaptionHelper

        SwaptionHelper( Date exerciseDate,
            Period length,
            Handle<Quote> volatility,
            IborIndex index,
            Period fixedLegTenor,
            DayCounter fixedLegDayCounter,
            DayCounter floatingLegDayCounter,
            Handle<YieldTermStructure> termStructure,
            CalibrationErrorType errorType = CalibrationErrorType.RelativePriceError,
            double? strike = null,
            double nominal = 1.0)
            : base(volatility, termStructure, errorType)
        {
            exerciseDate_ = exerciseDate;
            endDate_ = null;
            maturity_ = new Period(0,TimeUnit.Days);
            length_ = length;
            fixedLegTenor_ = fixedLegTenor;
            index_ = index;
            fixedLegDayCounter_ = fixedLegDayCounter;
            floatingLegDayCounter_ = floatingLegDayCounter;
            strike_ = strike;
            nominal_ = nominal;

            index_.registerWith( update );
        }
開發者ID:Yenyenx,項目名稱:qlnet,代碼行數:26,代碼來源:swaptionhelper.cs

示例10: FixedRateBond

      //! fixed-rate bond
      /*! \ingroup instruments

          \test calculations are tested by checking results against
                cached values.
      */
 

      //! simple annual compounding coupon rates      
      public FixedRateBond(int settlementDays, double faceAmount, Schedule schedule,List<double> coupons, 
                           DayCounter accrualDayCounter, BusinessDayConvention paymentConvention = BusinessDayConvention.Following,
                           double redemption = 100, Date issueDate = null,Calendar paymentCalendar = null,
			                  Period exCouponPeriod = null,
                           Calendar exCouponCalendar = null,
									BusinessDayConvention exCouponConvention = BusinessDayConvention.Unadjusted,
                           bool exCouponEndOfMonth = false)
         : base(settlementDays, paymentCalendar == null ? schedule.calendar() : paymentCalendar, 
                issueDate) 
      {
         frequency_ = schedule.tenor().frequency();
         dayCounter_ = accrualDayCounter;
         maturityDate_ = schedule.endDate();

         cashflows_ = new FixedRateLeg(schedule)
            .withCouponRates(coupons, accrualDayCounter)
				.withExCouponPeriod(exCouponPeriod,
										  exCouponCalendar,
										  exCouponConvention,
										  exCouponEndOfMonth)
            .withPaymentCalendar(calendar_)
            .withNotionals(faceAmount)
            .withPaymentAdjustment(paymentConvention); 

         addRedemptionsToCashflows(new List<double>() { redemption });

         if (cashflows().Count == 0)
            throw new ApplicationException("bond with no cashflows!");

         if (redemptions_.Count != 1)
            throw new ApplicationException("multiple redemptions created");
      }
開發者ID:akasolace,項目名稱:qlnet,代碼行數:41,代碼來源:Fixedratebond.cs

示例11: IborIndex

 public IborIndex(string familyName, Period tenor, int settlementDays, Currency currency,
          Calendar fixingCalendar, BusinessDayConvention convention, bool endOfMonth,
          DayCounter dayCounter)
     : this(familyName, tenor, settlementDays, currency,
            fixingCalendar, convention, endOfMonth,
            dayCounter, new Handle<YieldTermStructure>())
 {
 }
開發者ID:Yenyenx,項目名稱:qlnet,代碼行數:8,代碼來源:IBORIndex.cs

示例12: EURLibor

 public EURLibor(Period tenor, Handle<YieldTermStructure> h)
     : base("EURLibor", tenor, 2, new EURCurrency(), new JointCalendar(new UnitedKingdom(UnitedKingdom.Market.Exchange), new TARGET(),
         JointCalendar.JointCalendarRule.JoinHolidays),
         Utils.eurliborConvention(tenor), Utils.eurliborEOM(tenor), new Actual360(), h) {
     target_ = new TARGET();
     if (!(this.tenor().units() != TimeUnit.Days))
         throw new ApplicationException("for daily tenors (" + this.tenor() + ") dedicated DailyTenor constructor must be used");
 }
開發者ID:akasolace,項目名稱:qlnet,代碼行數:8,代碼來源:Eurlibor.cs

示例13: Euribor365

 public Euribor365(Period tenor, Handle<YieldTermStructure> h)
     : base("Euribor365", tenor,
            2, // settlement days
            new EURCurrency(), new TARGET(), Utils.euriborConvention(tenor), Utils.euriborEOM(tenor),
            new Actual365Fixed(), h) {
     if (this.tenor().units() == TimeUnit.Days)
         throw new ApplicationException("for daily tenors (" + this.tenor() + ") dedicated DailyTenor constructor must be used");
 }
開發者ID:akasolace,項目名稱:qlnet,代碼行數:8,代碼來源:Euribor.cs

示例14: DepositRateHelper

 public DepositRateHelper(double rate, Period tenor, int fixingDays, Calendar calendar,
     BusinessDayConvention convention, bool endOfMonth, DayCounter dayCounter)
     : base(rate)
 {
     iborIndex_ = new IborIndex("no-fix", tenor, fixingDays, new Currency(), calendar, convention,
                                endOfMonth, dayCounter, termStructureHandle_);
     initializeDates();
 }
開發者ID:StreetConnect,項目名稱:QLNet,代碼行數:8,代碼來源:DepositRateHelper.cs

示例15: withExCouponPeriod

 public CPILegBase withExCouponPeriod(Period period, Calendar cal, BusinessDayConvention convention, bool endOfMonth = false)
 {
     exCouponPeriod_ = period;
       exCouponCalendar_ = cal;
       exCouponAdjustment_ = convention;
       exCouponEndOfMonth_ = endOfMonth;
       return this;
 }
開發者ID:Yenyenx,項目名稱:qlnet,代碼行數:8,代碼來源:RateLegBase.cs


注:本文中的QLNet.Period類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。