Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the quoted asset set.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="cache">The cache.</param>
        ///  <param name="nameSpace">The client namespace</param>
        /// <param name="fixingCalendar">The fixingCalendar.</param>
        /// <param name="rollCalendar">The rollCalendar.</param>
        /// <returns></returns>
        public override void Build(ILogger logger, ICoreCache cache, string nameSpace, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar)
        {
            var curveId = (VolatilitySurfaceIdentifier)PricingStructureIdentifier;

            //TODO This for backwards compatability. AnalyticalResults is the current interface.
            BootstrapResults      = new VolCurveBootstrapResults();
            PriceableOptionAssets = PriceableAssetFactory.CreatePriceableOptionAssets(logger, cache, nameSpace, GetVolatilityMatrix().baseDate.Value, Asset?.href, DiscountCurve, ForecastCurve, Strike, GetVolatilityMatrix().inputs, fixingCalendar, rollCalendar);
            //GetVolatilityMatrix().dataPoints = null;
            MultiDimensionalPricingData dataPoints = GetVolatilityMatrix().dataPoints;

            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");
            }
            dataPoints.point = ProcessRawSurface(termTenors, Strike, VolatilityValues, curveId.StrikeQuoteUnits, curveId.UnderlyingAssetReference);
            SetInterpolator(dataPoints, curveId.Algorithm, curveId.PricingStructureType);
        }
Exemplo n.º 3
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);
        }