示例#1
0
        // The functionality below takes the original "double" curves
        // and converts them to AD curves.
        public void SetAdCurvesFromOrdinaryCurve()
        {
            List <ADouble> discValues = new List <ADouble>();

            for (int i = 0; i < DiscCurve.Values.Count; i++)
            {
                discValues.Add(new MasterThesis.ADouble(DiscCurve.Values[i]));
            }

            ADDiscCurve          = new MasterThesis.Curve_AD(DiscCurve.Dates, discValues);
            ADFwdCurveCollection = new ADFwdCurveContainer();

            foreach (CurveTenor tenor in FwdCurveCollection.Curves.Keys)
            {
                List <ADouble> tempValues = new List <ADouble>();

                for (int i = 0; i < FwdCurveCollection.GetCurve(tenor).Values.Count; i++)
                {
                    tempValues.Add(new ADouble(FwdCurveCollection.GetCurve(tenor).Values[i]));
                }

                Curve_AD tempCurve = new Curve_AD(FwdCurveCollection.GetCurve(tenor).Dates, tempValues);
                ADFwdCurveCollection.AddCurve(tempCurve, tenor);
            }

            ADCurvesHasBeenSet = true;
        }
示例#2
0
        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);
        }