예제 #1
0
        public IVolSurface GetVolSurface(string name, Currency currency = null)
        {
            if (IsFx(name))
            {
                return(FundingModel.GetVolSurface(name));
            }

            if (currency != null)
            {
                if (!_assetVols.TryGetValue(new VolSurfaceKey(name, currency), out var surface))
                {
                    throw new Exception($"Vol surface {name}/{currency} not found");
                }

                return(surface);
            }

            var surfaces = _assetVols.Where(x => name.Contains("~") ? x.Key.ToString() == name : x.Key.AssetId == name);

            if (!surfaces.Any())
            {
                throw new Exception($"Vol surface {name} not found");
            }

            return(surfaces.First().Value);
        }
예제 #2
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);
        }