예제 #1
0
 Volatility BlackVolTermStructure::blackForwardVol(Time time1,
                                                   Time time2,
                                                   Real strike,
                                                   bool extrapolate) const {
     QL_REQUIRE(time1 <= time2,
                time1 << " later than " << time2);
     checkRange(time2, extrapolate);
     checkStrike(strike, extrapolate);
     if (time2==time1) {
         if (time1==0.0) {
             Time epsilon = 1.0e-5;
             Real var = blackVarianceImpl(epsilon, strike);
             return std::sqrt(var/epsilon);
         } else {
             Time epsilon = std::min<Time>(1.0e-5, time1);
             Real var1 = blackVarianceImpl(time1-epsilon, strike);
             Real var2 = blackVarianceImpl(time1+epsilon, strike);
             QL_ENSURE(var2>=var1,
                       "variances must be non-decreasing");
             return std::sqrt((var2-var1)/(2*epsilon));
         }
     } else {
         Real var1 = blackVarianceImpl(time1, strike);
         Real var2 = blackVarianceImpl(time2, strike);
         QL_ENSURE(var2 >= var1,
                   "variances must be non-decreasing");
         return std::sqrt((var2-var1)/(time2-time1));
     }
 }
예제 #2
0
 Real BlackVolTermStructure::blackForwardVariance(Time time1,
                                                  Time time2,
                                                  Real strike,
                                                  bool extrapolate) const {
     QL_REQUIRE(time1 <= time2,
                time1 << " later than " << time2);
     checkRange(time2, extrapolate);
     checkStrike(strike, extrapolate);
     Real v1 = blackVarianceImpl(time1, strike);
     Real v2 = blackVarianceImpl(time2, strike);
     QL_ENSURE(v2 >= v1,
               "variances must be non-decreasing");
     return v2-v1;
 }
예제 #3
0
 inline Real BlackVolTermStructure::blackVariance(Time t,
                                                  Real strike,
                                                  bool extrapolate) const {
     checkRange(t, extrapolate);
     checkStrike(strike, extrapolate);
     return blackVarianceImpl(t, strike);
 }
예제 #4
0
 inline
 Volatility BlackVarianceTermStructure ::blackVolImpl(Time t,
                                                      Real strike) const {
     Time nonZeroMaturity = (t==0.0 ? 0.00001 : t);
     Real var = blackVarianceImpl(nonZeroMaturity, strike);
     return std::sqrt(var/nonZeroMaturity);
 }
예제 #5
0
 inline Real BlackVolTermStructure::blackVariance(const Date& d,
                                                  Real strike,
                                                  bool extrapolate) const {
     checkRange(d, extrapolate);
     checkStrike(strike, extrapolate);
     Time t = timeFromReference(d);
     return blackVarianceImpl(t, strike);
 }