Example #1
0
        public override double correctYoYRate(Date d, double r, InflationTermStructure iTS)
        {
            KeyValuePair <Date, Date> lim = Utils.inflationPeriod(iTS.baseDate(), iTS.frequency());
            Date curveBaseDate            = lim.Value;

            return(seasonalityCorrection(r, d, iTS.dayCounter(), curveBaseDate, false));
        }
Example #2
0
        public override bool isConsistent(InflationTermStructure iTS)
        {
            // If multi-year is the specification consistent with the term structure start date?
            // We do NOT test daily seasonality because this will, in general, never be consistent
            // given weekends, holidays, leap years, etc.
            if (this.frequency() == Frequency.Daily)
            {
                return(true);
            }
            if ((int)this.frequency() == seasonalityFactors().Count)
            {
                return(true);
            }

            // how many years do you need to test?
            int nTest = seasonalityFactors().Count / (int)this.frequency();
            // ... relative to the start of the inflation curve
            KeyValuePair <Date, Date> lim = Utils.inflationPeriod(iTS.baseDate(), iTS.frequency());
            Date   curveBaseDate          = lim.Value;
            double factorBase             = this.seasonalityFactor(curveBaseDate);

            double eps = 0.00001;

            for (int i = 1; i < nTest; i++)
            {
                double factorAt = this.seasonalityFactor(curveBaseDate + new Period(i, TimeUnit.Years));
                Utils.QL_REQUIRE(Math.Abs(factorAt - factorBase) < eps, () =>
                                 "seasonality is inconsistent with inflation " +
                                 "term structure, factors " + factorBase + " and later factor "
                                 + factorAt + ", " + i + " years later from inflation curve "
                                 + " with base date at " + curveBaseDate);
            }

            return(true);
        }
Example #3
0
 /*! It is possible for multi-year seasonalities to be
  *  inconsistent with the inflation term structure they are
  *  given to.  This method enables testing - but programmers
  *  are not required to implement it.  E.g. for price
  *  seasonality the corrections at whole years after the
  *  inflation curve base date should be the same or else there
  *  can be an inconsistency with quoted instruments.
  *  Alternatively, the seasonality can be set _before_ the
  *  inflation curve is bootstrapped.
  */
 public virtual bool isConsistent(InflationTermStructure iTS)
 {
     return(true);
 }
Example #4
0
 public virtual double correctYoYRate(Date d, double r, InflationTermStructure iTS)
 {
     return(0);
 }
 /*! It is possible for multi-year seasonalities to be
     inconsistent with the inflation term structure they are
     given to.  This method enables testing - but programmers
     are not required to implement it.  E.g. for price
     seasonality the corrections at whole years after the
     inflation curve base date should be the same or else there
     can be an inconsistency with quoted instruments.
     Alternatively, the seasonality can be set _before_ the
     inflation curve is bootstrapped.
 */
 public virtual bool isConsistent(InflationTermStructure iTS)
 {
    return true;
 }
 public virtual double correctYoYRate(Date d, double r,InflationTermStructure iTS) 
 {
    return 0;
 }
      public virtual bool isConsistent(InflationTermStructure iTS) 
      {

         // If multi-year is the specification consistent with the term structure start date?
         // We do NOT test daily seasonality because this will, in general, never be consistent
         // given weekends, holidays, leap years, etc.
         if(this.frequency() == Frequency.Daily) return true;
         if( (int)this.frequency() == seasonalityFactors().Count ) return true;

         // how many years do you need to test?
         int nTest = seasonalityFactors().Count / (int)this.frequency();
         // ... relative to the start of the inflation curve
         KeyValuePair<Date,Date> lim = Utils.inflationPeriod(iTS.baseDate(), iTS.frequency());
         Date curveBaseDate = lim.Value;
         double factorBase = this.seasonalityFactor(curveBaseDate);

         double eps = 0.00001;
         for (int i = 1; i < nTest; i++) 
         {
            double factorAt = this.seasonalityFactor(curveBaseDate+new Period(i,TimeUnit.Years));
            if (Math.Abs(factorAt-factorBase)>=eps)
               throw new ApplicationException("seasonality is inconsistent with inflation " +
                        "term structure, factors " + factorBase + " and later factor " 
                        + factorAt + ", " + i + " years later from inflation curve "
                        + " with base date at " + curveBaseDate);
         }

         return true;

      }
 public virtual double correctYoYRate(Date d, double r, InflationTermStructure iTS)
 {
    KeyValuePair<Date,Date> lim = Utils.inflationPeriod(iTS.baseDate(), iTS.frequency());
    Date curveBaseDate = lim.Value;
    return seasonalityCorrection(r, d, iTS.dayCounter(), curveBaseDate, false);
 }
Example #9
0
 //! \name Seasonality interface
 //@{
 public virtual double correctZeroRate(Date d, double r,InflationTermStructure iTS) 
 {
    return 0;
 }