Exemple #1
0
 public CapletVarianceCurve(Date referenceDate,
                            List <Date> dates,
                            List <double> capletVolCurve,
                            DayCounter dayCounter)
     : base(referenceDate, new Calendar(), BusinessDayConvention.Following, new DayCounter())
 {
     blackCurve_ = new BlackVarianceCurve(referenceDate, dates, capletVolCurve, dayCounter, false);
 }
Exemple #2
0
        public Handle <LocalVolTermStructure> localVolatility()
        {
            if (!updated_)
            {
                isStrikeIndependent_ = true;

                // constant Black vol?
                BlackConstantVol constVol = blackVolatility().link as BlackConstantVol;
                if (constVol != null)
                {
                    // ok, the local vol is constant too.
                    localVolatility_.linkTo(new LocalConstantVol(constVol.referenceDate(),
                                                                 constVol.blackVol(0.0, x0_.link.value()),
                                                                 constVol.dayCounter()));
                    updated_ = true;
                    return(localVolatility_);
                }

                // ok, so it's not constant. Maybe it's strike-independent?
                BlackVarianceCurve volCurve = blackVolatility().link as BlackVarianceCurve;
                if (volCurve != null)
                {
                    // ok, we can use the optimized algorithm
                    localVolatility_.linkTo(new LocalVolCurve(new Handle <BlackVarianceCurve>(volCurve)));
                    updated_ = true;
                    return(localVolatility_);
                }

                // ok, so it's strike-dependent. Never mind.
                localVolatility_.linkTo(new LocalVolSurface(blackVolatility_, riskFreeRate_, dividendYield_,
                                                            x0_.link.value()));
                updated_             = true;
                isStrikeIndependent_ = false;
                return(localVolatility_);
            }
            else
            {
                return(localVolatility_);
            }
        }