Real CalibrationHelper::calibrationError() {
        Real error;
        
        switch (calibrationErrorType_) {
          case RelativePriceError:
            error = std::fabs(marketValue() - modelValue())/marketValue();
            break;
          case PriceError:
            error = marketValue() - modelValue();
            break;
          case ImpliedVolError: 
            {
              const Real lowerPrice = blackPrice(0.001);
              const Real upperPrice = blackPrice(10);
              const Real modelPrice = modelValue();

              Volatility implied;
              if (modelPrice <= lowerPrice)
                  implied = 0.001;
              else
                  if (modelPrice >= upperPrice)
                      implied = 10.0;
                  else
                      implied = this->impliedVolatility(
                                          modelPrice, 1e-12, 5000, 0.001, 10);
              error = implied - volatility_->value();
            }
            break;
          default:
            QL_FAIL("unknown Calibration Error Type");
        }
        
        return error;
    }
 void update() {
     marketValue_ = blackPrice(volatility_->value());
     notifyObservers();
 }
Пример #3
0
 void performCalculations() const {
     marketValue_ = blackPrice(volatility_->value());
 }