Exemple #1
0
        public double GetCompositeVolForStrikeAndDate(string assetId, DateTime expiry, double strike, Currency ccy)
        {
            var curve = GetPriceCurve(assetId);

            if (curve.Currency == ccy)
            {
                return(GetVolForStrikeAndDate(assetId, expiry, strike));
            }

            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) ?? 0.0;
            var sigma      = GetVolForStrikeAndDate(assetId, expiry, strike / fxFwd);

            sigma = System.Math.Sqrt(sigma * sigma + fxVol * fxVol + 2 * correl * fxVol * sigma);
            return(sigma);
        }
Exemple #2
0
        public IAssetFxModel Clone()
        {
            var c = new AssetFxModel(BuildDate, FundingModel.DeepClone(null));

            foreach (var kv in _assetCurves)
            {
                c.AddPriceCurve(kv.Key, kv.Value);
            }

            foreach (var kv in _assetVols)
            {
                c.AddVolSurface(kv.Key, kv.Value);
            }

            foreach (var kv in _fixings)
            {
                c.AddFixingDictionary(kv.Key, kv.Value);
            }

            c.CorrelationMatrix = CorrelationMatrix;
            c.AttachPortfolio(_portfolio);
            return(c);
        }
Exemple #3
0
        public IPriceCurve GetPriceCurve(string name, Currency currency = null)
        {
            if (IsFx(name))
            {
                return(new FxForwardCurve(BuildDate, FundingModel, FundingModel.GetCurrency(name.Substring(0, 3)), FundingModel.GetCurrency(name.Substring(4, 3))));
            }

            if (!_assetCurves.TryGetValue(name, out var curve))
            {
                throw new Exception($"Curve with name {name} not found");
            }

            if (currency != null && curve.Currency != currency)
            {
                return(new CompositePriceCurve(curve.BuildDate, curve, FundingModel, currency));
            }

            return(curve);
        }