public ZcbRiskOutput CalculateZcbRiskBumpAndRun(LinearRateInstrument product, CurveTenor tenor, DateTime asOf) { ZcbRiskOutput output = new MasterThesis.ZcbRiskOutput(asOf); if (tenor == CurveTenor.DiscOis || tenor == CurveTenor.DiscLibor) { for (int i = 0; i < DiscCurve.Values.Count; i++) { DateTime curvePoint = DiscCurve.Dates[i]; double riskValue = BumpAndRunDisc(product, i); output.AddRiskCalculation(CurveTenor.DiscOis, curvePoint, riskValue); } } else if (EnumHelpers.IsFwdTenor(tenor)) { for (int j = 0; j < FwdCurveCollection.GetCurve(tenor).Dates.Count; j++) { DateTime curvePoint = FwdCurveCollection.GetCurve(tenor).Dates[j]; double riskValue = BumpAndRunFwdRisk(product, tenor, j); output.AddRiskCalculation(tenor, curvePoint, riskValue); } } else { throw new InvalidOperationException("tenor is not valid."); } return(output); }
public ZcbRiskOutputContainer ZcbRiskProductOutputContainer(LinearRateInstrument product, DateTime asOf) { double[] risk = ZcbRiskProductAD(product); ZcbRiskOutputContainer output = new ZcbRiskOutputContainer(); ZcbRiskOutput discRisk = new MasterThesis.ZcbRiskOutput(asOf); int j = 0; for (int i = 0; i < DiscCurve.Dimension; i++) { discRisk.AddRiskCalculation(CurveTenor.DiscOis, DiscCurve.Dates[i], risk[j]); j++; } output.AddDiscRisk(discRisk); CurveTenor[] tenors = new CurveTenor[] { CurveTenor.Fwd1M, CurveTenor.Fwd3M, CurveTenor.Fwd6M, CurveTenor.Fwd1Y }; foreach (CurveTenor tenor in tenors.ToList()) { ZcbRiskOutput tempFwdRisk = new ZcbRiskOutput(asOf); for (int i = 0; i < FwdCurveCollection.GetCurve(tenor).Dimension; i++) { DateTime curvePoint = FwdCurveCollection.GetCurve(tenor).Dates[i]; tempFwdRisk.AddRiskCalculation(tenor, curvePoint, risk[j]); j++; } output.AddForwardRisk(tenor, tempFwdRisk); } return(output); }