Exemple #1
0
        public double GetCorrelation(string label1, string label2, double t = 0)
        {
            if (CorrelationMatrix == null)
            {
                throw new Exception("No correlation matrix attached to model");
            }

            return(CorrelationMatrix.GetCorrelation(label1, label2, t));
        }
Exemple #2
0
        public void CorrelMatrixFacts()
        {
            var z = new CorrelationMatrix();

            z = new CorrelationMatrix(new[] { "x" }, new[] { "y" }, new[] { new [] { 0.9999 } });
            Assert.Throws <Exception>(() => z.GetCorrelation("x", "z"));
            Assert.False(z.TryGetCorrelation("x", "z", out var c));
            var zz     = z.Clone();
            var bumped = zz.Bump(0.5);

            Assert.True(bumped.GetCorrelation("x", "y") < 1.0);
        }
Exemple #3
0
        public double GetCompositeVolForStrikeAndDate(string assetId, DateTime expiry, double strike, Currency ccy)
        {
            var curve = GetPriceCurve(assetId);

            var fxId   = $"{curve.Currency.Ccy}/{ccy.Ccy}";
            var fxPair = FundingModel.FxMatrix.GetFxPair(fxId);

            var fxSpotDate = fxPair.SpotDate(expiry);
            var fxFwd      = FundingModel.GetFxRate(fxSpotDate, fxId);
            var fxVol      = FundingModel.GetVolSurface(fxId).GetVolForDeltaStrike(0.5, expiry, fxFwd);
            var tExpC      = BuildDate.CalculateYearFraction(expiry, DayCountBasis.Act365F);
            var correl     = CorrelationMatrix.GetCorrelation(fxId, assetId, tExpC);
            var sigma      = GetVolForStrikeAndDate(assetId, expiry, strike / fxFwd);

            sigma = System.Math.Sqrt(sigma * sigma + fxVol * fxVol + 2 * correl * fxVol * sigma);
            return(sigma);
        }