コード例 #1
0
    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;
    }
コード例 #2
0
 void update() {
     marketValue_ = blackPrice(volatility_->value());
     notifyObservers();
 }
コード例 #3
0
ファイル: calibrationhelper.hpp プロジェクト: pmcs/QuantLib
 void performCalculations() const {
     marketValue_ = blackPrice(volatility_->value());
 }