public override void fetchResults(IPricingEngineResults r) { base.fetchResults(r); VanillaSwap.Results results = r as VanillaSwap.Results; if (results != null) { // might be a swap engine, so no error is thrown fairRate_ = results.fairRate; fairSpread_ = results.fairSpread; } else { fairRate_ = null; fairSpread_ = null; } if (fairRate_ == null) { // calculate it from other results if (legBPS_[0] != null) { fairRate_ = fixedRate_ - NPV_.GetValueOrDefault() / (legBPS_[0] / Const.BASIS_POINT); } } if (fairSpread_ == null) { // ditto if (legBPS_[1] != null) { fairSpread_ = spread_ - NPV_.GetValueOrDefault() / (legBPS_[1] / Const.BASIS_POINT); } } }
/// <summary> /// Performs the valuation of the instruments. Returns Net Present Value (NPV). /// </summary> new public double NPV() { calculate(); if (NPV_ == null) { throw new ArgumentException("NPV not provided"); } return(NPV_.GetValueOrDefault()); }