Beispiel #1
0
        public CapVolatilityCurve(ILogger logger, ICoreCache cache, string nameSpace, NamedValueSet properties, QuotedAssetSet instrumentData,
                                  IRateCurve discountCurve, IRateCurve forecastCurve, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar)
            : this(logger, cache, nameSpace, new VolatilitySurfaceIdentifier(properties), fixingCalendar, rollCalendar)
        {
            DiscountCurve = discountCurve;
            ForecastCurve = forecastCurve;
            var curveId  = GetCurveId();
            var volCurve = SetConfigurationData();

            //TODO This for backwards compatability. AnalyticalResults is the current interface.
            Handle           = properties.GetString(CurveProp.EngineHandle, null);
            BootstrapResults = new VolCurveBootstrapResults();
            //Set the underlying asset information.
            var instrument = properties.GetString(CurveProp.Instrument, true);

            Asset = new AnyAssetReference {
                href = instrument
            };
            UnderlyingAssetDetails = CreateUnderlyingAssetWithProperties();
            var extrapolationPermitted = ExtrapolationPermittedInput ?? ExtrapolationPermitted;

            PriceableOptionAssets    = PriceableAssetFactory.CreatePriceableRateOptionAssets(logger, cache, nameSpace, curveId.BaseDate, instrumentData, fixingCalendar, rollCalendar);
            BootstrapResults.Results = CapFloorBootstrapper.Bootstrap(PriceableOptionAssets, properties, DiscountCurve, ForecastCurve, curveId.BaseDate, extrapolationPermitted,
                                                                      InterpolationMethod, Tolerance);
            IsBootstrapSuccessful = true;
            InitialiseVolatilities(curveId.BaseDate, BootstrapResults.Results);
            QuoteUnits       = EnumHelper.Parse <QuoteUnitsEnum>(properties.GetValue(CurveProp.QuoteUnits, QuoteUnitsEnum.LogNormalVolatility.ToString()));
            MeasureType      = EnumHelper.Parse <MeasureTypesEnum>(properties.GetValue(CurveProp.MeasureType, MeasureTypesEnum.Volatility.ToString()));
            StrikeQuoteUnits = EnumHelper.Parse <StrikeQuoteUnitsEnum>(properties.GetValue(CurveProp.StrikeQuoteUnits, StrikeQuoteUnitsEnum.ATMFlatMoneyness.ToString()));
            //If there is a strike specified for the curve, use it!
            IsATMBootstrap = true;
            Strike         = curveId.Strike;
            if (Strike != null)
            {
                ValidateStrike((decimal)Strike);
                IsFixedStrikeBootstrap = true;
                IsATMBootstrap         = false;
            }
            if (StrikeQuoteUnits == StrikeQuoteUnitsEnum.ATMFlatMoneyness || StrikeQuoteUnits == StrikeQuoteUnitsEnum.ATMMoneyness)
            {
                IsFixedStrikeBootstrap = false;
            }
            //The points use tenor strings for expiry.
            var termTenors = new List <String>();

            foreach (var daysDifference in VolatilityOffsets)
            {
                termTenors.Add(daysDifference + "D");
            }
            volCurve.point = ProcessRawSurface(termTenors, Strike, VolatilityValues, curveId.StrikeQuoteUnits, curveId.UnderlyingAssetReference);
            // Interpolate the curve based on the respective curve interpolation
            SetInterpolator(volCurve, curveId.Algorithm, curveId.PricingStructureType);
            CreatePricingStructure(curveId, volCurve, instrumentData);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GenericVolatilityCurve"/> class.
        /// This constructor is used to clone perturbed copies of a base curve.
        /// </summary>
        /// <param name="priceableRateOptionAssets">The priceableRateAssets.</param>
        /// <param name="pricingStructureAlgorithmsHolder">The pricingStructureAlgorithmsHolder.</param>
        /// <param name="curveProperties">The Curve Properties.</param>
        /// <param name="discountCurve">The discount rate curve.</param>
        /// <param name="forecastCurve">The forecast rate curve.</param>
        public GenericVolatilityCurve(NamedValueSet curveProperties, List <IPriceableOptionAssetController> priceableRateOptionAssets,
                                      IRateCurve discountCurve, IRateCurve forecastCurve, PricingStructureAlgorithmsHolder pricingStructureAlgorithmsHolder)
            : base(curveProperties, pricingStructureAlgorithmsHolder)
        {
            DiscountCurve = discountCurve;
            ForecastCurve = forecastCurve;
            var curveId  = GetCurveId();
            var volCurve = SetConfigurationData();

            Handle           = curveProperties.GetString(CurveProp.EngineHandle, null);
            BootstrapResults = new VolCurveBootstrapResults();
            //Set the underlying asset information.
            var instrument = curveProperties.GetString(CurveProp.Instrument, true);

            Asset = new AnyAssetReference {
                href = instrument
            };
            UnderlyingAssetDetails   = CreateUnderlyingAssetWithProperties();
            PriceableOptionAssets    = priceableRateOptionAssets;
            BootstrapResults.Results = VolatilityCurveBootstrapper.Bootstrap(PriceableOptionAssets);
            IsBootstrapSuccessful    = true;
            InitialiseVolatilities(curveId.BaseDate, BootstrapResults.Results);
            QuoteUnits       = EnumHelper.Parse <QuoteUnitsEnum>(curveProperties.GetValue(CurveProp.QuoteUnits, QuoteUnitsEnum.LogNormalVolatility.ToString()));
            MeasureType      = EnumHelper.Parse <MeasureTypesEnum>(curveProperties.GetValue(CurveProp.MeasureType, MeasureTypesEnum.Volatility.ToString()));
            StrikeQuoteUnits = EnumHelper.Parse <StrikeQuoteUnitsEnum>(curveProperties.GetValue(CurveProp.StrikeQuoteUnits, StrikeQuoteUnitsEnum.ATMFlatMoneyness.ToString()));
            //If there is a strike specified for the curve, use it!
            Strike = curveId.Strike;
            if (Strike != null)
            {
                ValidateStrike((decimal)Strike);
                IsFixedStrikeBootstrap = true;
            }
            if (StrikeQuoteUnits == StrikeQuoteUnitsEnum.ATMFlatMoneyness || StrikeQuoteUnits == StrikeQuoteUnitsEnum.ATMMoneyness)
            {
                IsATMBootstrap         = true;
                IsFixedStrikeBootstrap = false;
            }
            //The points use tenor strings for expiry.
            var termTenors = new List <String>();

            foreach (var daysDifference in VolatilityOffsets)
            {
                termTenors.Add(daysDifference + "D");
            }
            volCurve.point = ProcessRawSurface(termTenors, Strike, VolatilityValues, curveId.StrikeQuoteUnits, curveId.UnderlyingAssetReference);
            // Interpolate the curve based on the respective curve interpolation
            SetInterpolator(volCurve, curveId.Algorithm, curveId.PricingStructureType);
            CreatePricingStructure(curveId, volCurve, PriceableOptionAssets);
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GenericVolatilityCurve"/> class.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="cache">The cache.</param>
        /// <param name="nameSpace">The nameSpace</param>
        /// <param name="fpmlData">The FPML data.</param>
        /// <param name="properties">The properties for the pricing structure.</param>
        /// <param name="fixingCalendar">The fixingCalendar. If the curve is already bootstrapped, then this can be null.</param>
        /// <param name="rollCalendar">The rollCalendar. If the curve is already bootstrapped, then this can be null.</param>
        public GenericVolatilityCurve(ILogger logger, ICoreCache cache, String nameSpace,
                                      Pair <PricingStructure, PricingStructureValuation> fpmlData, NamedValueSet properties,
                                      IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar)
            : base(logger, cache, nameSpace, fpmlData, properties, fixingCalendar, rollCalendar)
        {
            PricingStructureData = new PricingStructureData(CurveType.Parent, AssetClass.Rates, properties);
            var curveId = GetCurveId();

            Initialize(properties, Holder);
            //Set the underlying asset information.
            if (properties != null)
            {
                var instrument = properties.GetString("Instrument", false);
                Asset = new AnyAssetReference {
                    href = instrument
                };
            }
            if (fpmlData == null)
            {
                return;
            }
            FixingCalendar  = fixingCalendar;
            PaymentCalendar = rollCalendar;
            if (DayCounter == null)
            {
                DayCounter = DayCounterHelper.Parse("ACT/365.FIXED");
                if (Holder != null)
                {
                    string dayCountBasis = Holder.GetValue("DayCounter");
                    DayCounter = DayCounterHelper.Parse(dayCountBasis);
                }
            }
            // the curve is already built, so don't rebuild
            //Process the matrix
            SetInterpolator(((VolatilityMatrix)PricingStructureValuation).dataPoints, curveId.Algorithm, curveId.PricingStructureType);
            SetFpMLData(fpmlData, false);
        }
Beispiel #4
0
        public GenericVolatilityCurve(ILogger logger, ICoreCache cache, string nameSpace, NamedValueSet properties, QuotedAssetSet expiryTenorsWithVols,
                                      IRateCurve discountCurve, IRateCurve forecastCurve, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar)
            : base(logger, cache, nameSpace, new VolatilitySurfaceIdentifier(properties), fixingCalendar, rollCalendar)
        {
            DiscountCurve = discountCurve;
            ForecastCurve = forecastCurve;
            var curveId  = GetCurveId();
            var volCurve = SetConfigurationData();

            if (properties != null)
            {
                var assetClass = properties.GetString(CurveProp.AssetClass, "Rates");
                var asset      = EnumHelper.Parse <AssetClass>(assetClass);
                PricingStructureData = new PricingStructureData(CurveType.Parent, asset, properties);
                var quoteUnits = properties.GetValue(CurveProp.StrikeQuoteUnits, StrikeQuoteUnitsEnum.ATMFlatMoneyness.ToString());
                IsFixedStrikeBootstrap = EnumHelper.Parse <StrikeQuoteUnitsEnum>(quoteUnits) == StrikeQuoteUnitsEnum.ATMFlatMoneyness;
                if (!IsFixedStrikeBootstrap)
                {
                    IsATMBootstrap = true;
                }
                //Set the underlying asset information.
                var instrument = properties.GetString(CurveProp.Instrument, true);
                Asset = new AnyAssetReference {
                    href = instrument
                };
                UnderlyingAssetDetails = CreateUnderlyingAssetWithProperties();
                QuoteUnits             = EnumHelper.Parse <QuoteUnitsEnum>(properties.GetValue(CurveProp.QuoteUnits, QuoteUnitsEnum.LogNormalVolatility.ToString()));
                MeasureType            = EnumHelper.Parse <MeasureTypesEnum>(properties.GetValue(CurveProp.MeasureType, MeasureTypesEnum.Volatility.ToString()));
                StrikeQuoteUnits       = EnumHelper.Parse <StrikeQuoteUnitsEnum>(properties.GetValue(CurveProp.StrikeQuoteUnits, StrikeQuoteUnitsEnum.ATMFlatMoneyness.ToString()));
                IsFixedStrikeBootstrap = true;
                IsATMBootstrap         = false;
                if (StrikeQuoteUnits == StrikeQuoteUnitsEnum.ATMFlatMoneyness || StrikeQuoteUnits == StrikeQuoteUnitsEnum.ATMMoneyness)
                {
                    IsFixedStrikeBootstrap = false;
                    IsATMBootstrap         = true;
                }
                Handle = properties.GetString(CurveProp.EngineHandle, null);
            }
            //If there is a strike specified for the curve, use it!
            Strike = curveId.Strike;
            if (Strike != null)
            {
                ValidateStrike((decimal)Strike);
                IsFixedStrikeBootstrap = true;
                IsATMBootstrap         = false;
            }
            BootstrapResults         = new VolCurveBootstrapResults();
            PriceableOptionAssets    = PriceableAssetFactory.CreatePriceableOptionAssets(logger, cache, nameSpace, curveId.BaseDate, Asset?.href, discountCurve, forecastCurve, Strike, expiryTenorsWithVols, fixingCalendar, rollCalendar);
            BootstrapResults.Results = VolatilityCurveBootstrapper.Bootstrap(PriceableOptionAssets);
            IsBootstrapSuccessful    = true;
            InitialiseVolatilities(curveId.BaseDate, BootstrapResults.Results);
            //The points use tenor strings for expiry.
            var termTenors = new List <String>();

            foreach (var daysDifference in VolatilityOffsets)
            {
                termTenors.Add(daysDifference + "D");
            }
            volCurve.point = ProcessRawSurface(termTenors, Strike, VolatilityValues, curveId.StrikeQuoteUnits, curveId.UnderlyingAssetReference);
            // Interpolate the curve based on the respective curve interpolation
            SetInterpolator(volCurve, curveId.Algorithm, curveId.PricingStructureType);
            CreatePricingStructure(curveId, volCurve, expiryTenorsWithVols);
        }