// Instrument interface public override void calculate() { if (discountCurve_.empty()) { throw new ArgumentException("no discounting term structure set"); } if (discountCurve_.Count != arguments_.legs.Count) { throw new ArgumentException("no discounting term structure set for all legs"); } results_.value = results_.cash = 0; results_.errorEstimate = null; results_.legNPV = new InitializedList <double?>(arguments_.legs.Count); results_.legBPS = new InitializedList <double?>(arguments_.legs.Count); List <double?> startDiscounts = new InitializedList <double?>(arguments_.legs.Count); for (int i = 0; i < arguments_.legs.Count; ++i) { results_.value += results_.legNPV[i]; results_.cash += arguments_.payer[i] * CashFlows.cash(arguments_.legs[i]); try { Date d = CashFlows.startDate(arguments_.legs[i]); startDiscounts[i] = discountCurve_[i].link.discount(d); } catch { startDiscounts[i] = null; } } results_.additionalResults.Add("startDiscounts", startDiscounts); }