Пример #1
0
            public double protectionLeg(PiecewiseconstantHazardRate creditCurve)
            {
                double ht0 = creditCurve.getRT_(_proLegIntPoints[0]);
                double rt0 = _proYieldCurveRT[0];
                double b0  = _proDF[0] * Math.Exp(-ht0);

                double pv = 0.0;

                for (int i = 1; i < _nProPoints; ++i)
                {
                    double ht1  = creditCurve.getRT_(_proLegIntPoints[i]);
                    double rt1  = _proYieldCurveRT[i];
                    double b1   = _proDF[i] * Math.Exp(-ht1);
                    double dht  = ht1 - ht0;
                    double drt  = rt1 - rt0;
                    double dhrt = dht + drt;

                    // this is equivalent to the ISDA code without explicitly calculating the time step - it also handles the limit
                    double dPV;
                    if (Math.Abs(dhrt) < 1e-5)
                    {
                        dPV = dht * b0 * Epsilon.epsilon(-dhrt);
                    }
                    else
                    {
                        dPV = (b0 - b1) * dht / dhrt;
                    }
                    pv += dPV;
                    ht0 = ht1;
                    rt0 = rt1;
                    b0  = b1;
                }
                pv *= _lgdDF; // multiply by LGD and adjust to valuation date

                return(pv);
            }