コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RateBasisCurve"/> class.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="cache">The cache.</param>
        /// <param name="nameSpace">The client namespace</param>
        /// <param name="referenceCurveData">The market data. This must contain both the underlying base curve and the spread curve.
        /// Otherwise the RateBasisInterpolator can not instantiate.</param>
        /// <param name="derivedCurveData">The spread Curve Data</param>
        /// <param name="fixingCalendar">The fixingCalendar.</param>
        /// <param name="rollCalendar">The rollCalendar.</param>
        public ClearedRateCurve(ILogger logger, ICoreCache cache, String nameSpace,
                                Triplet <PricingStructure, PricingStructureValuation, NamedValueSet> referenceCurveData,
                                Triplet <PricingStructure, PricingStructureValuation, NamedValueSet> derivedCurveData, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar)
            : base(derivedCurveData.Third, GenerateHolder(logger, cache, nameSpace, derivedCurveData.Third))
        {
            PricingStructureData = new PricingStructureData(CurveType.Child, AssetClass.Rates, derivedCurveData.Third);
            var curveId = GetRateCurveId();
            //Set the identifier.
            var nvs = derivedCurveData.Third;
            var pricingStructureId = GetRateCurveId();
            var refCurveId         = PropertyHelper.ExtractReferenceCurveUniqueId(nvs);

            ReferenceDiscountingCurveId = refCurveId != null ? new Identifier(refCurveId) : ReferenceDiscountingCurveId = null;
            if (pricingStructureId.PricingStructureType != PricingStructureTypeEnum.ClearedRateCurve)
            {
                return;
            }
            //Set the reference curve
            var baseCurveFpml  = new Pair <PricingStructure, PricingStructureValuation>(referenceCurveData.First, referenceCurveData.Second);
            var baseCurveProps = referenceCurveData.Third;

            BaseDiscountingCurve = (IRateCurve)PricingStructureFactory.Create(logger, cache, nameSpace, fixingCalendar, rollCalendar, baseCurveFpml, baseCurveProps);
            //Get the spread Data
            var spreadCurveFpml = new Pair <PricingStructure, PricingStructureValuation>(derivedCurveData.First, derivedCurveData.Second);
            //Override properties.
            //var optimize = PropertyHelper.ExtractOptimizeBuildFlag(properties);
            var bootstrap    = PropertyHelper.ExtractBootStrapOverrideFlag(nvs);
            var tempFpml     = (YieldCurveValuation)spreadCurveFpml.Second;
            var spreadAssets = tempFpml.inputs;
            //This is to catch it when there are no discount factor points.
            var discountsAbsent = tempFpml.discountFactorCurve?.point == null || tempFpml.discountFactorCurve.point.Length == 0;
            var indexTenor      = curveId.ForecastRateIndex?.indexTenor;

            if (bootstrap || discountsAbsent)
            {
                //There must be a valid quoted asset set in order to bootstrap.
                if (!XsdClassesFieldResolver.QuotedAssetSetIsValid(spreadAssets))
                {
                    return;
                }
                PriceableClearedRateAssets =
                    PriceableAssetFactory.CreatePriceableClearedRateAssetsWithBasisSwaps(logger, cache, nameSpace, indexTenor, spreadAssets, pricingStructureId.BaseDate, fixingCalendar, rollCalendar);
                GetYieldCurveValuation().zeroCurve = null;
                TermCurve termCurve = tempFpml.discountFactorCurve ?? SetConfigurationData();
                DateTime  baseDate  = GetYieldCurveValuation().baseDate.Value;
                termCurve.point = ClearedRateBootstrapper.Bootstrap(PriceableClearedRateAssets, BaseDiscountingCurve, baseDate, termCurve.extrapolationPermitted, termCurve.interpolationMethod, Tolerance);
                SetFpMLData(new Pair <PricingStructure, PricingStructureValuation>(PricingStructure, PricingStructureValuation), false);
                SetInterpolator(termCurve);
            }
            else
            {
                // the discount curve is already built, so don't rebuild
                PriceableClearedRateAssets = PriceableAssetFactory.CreatePriceableClearedRateAssetsWithBasisSwaps(logger, cache, nameSpace, indexTenor, spreadAssets, pricingStructureId.BaseDate, fixingCalendar, rollCalendar);
                //Order the assets.
                PriceableClearedRateAssets = PriceableClearedRateAssets.OrderBy(a => a.GetRiskMaturityDate()).ToList();
                CreatePricingStructure(pricingStructureId, tempFpml.discountFactorCurve, spreadAssets);
                // CreatePricingStructure(pricingStructureId, tempFpml.discountFactorCurve, PriceableAssetFactory.Parse(PriceableClearedRateAssets));
                SetInterpolator(GetYieldCurveValuation().discountFactorCurve);
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RateBasisCurve"/> class.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="cache">The cache.</param>
        ///  <param name="nameSpace">The client namespace</param>
        /// <param name="baseDiscountingCurve">The reference curve.</param>
        /// <param name="clearedRateAssets">The cleared rate asset.</param>
        /// <param name="properties">The properties of the new spread curve.</param>
        /// <param name="fixingCalendar">The fixingCalendar.</param>
        /// <param name="rollCalendar">The rollCalendar.</param>
        public ClearedRateCurve(ILogger logger, ICoreCache cache, string nameSpace,
                                IRateCurve baseDiscountingCurve, QuotedAssetSet clearedRateAssets, NamedValueSet properties,
                                IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar)
            : base(logger, cache, nameSpace, new RateCurveIdentifier(properties), fixingCalendar, rollCalendar)
        {
            PricingStructureData        = new PricingStructureData(CurveType.Child, AssetClass.Rates, properties);
            BaseDiscountingCurve        = baseDiscountingCurve;
            ReferenceDiscountingCurveId = BaseDiscountingCurve.GetPricingStructureId();
            if (PricingStructureIdentifier.PricingStructureType != PricingStructureTypeEnum.ClearedRateCurve)
            {
                return;
            }
            var termCurve  = SetConfigurationData();
            var curveId    = GetRateCurveId();
            var indexTenor = curveId.ForecastRateIndex?.indexTenor;

            //Set the priceable assets.
            PriceableClearedRateAssets = PriceableAssetFactory.CreatePriceableClearedRateAssetsWithBasisSwaps(logger, cache, nameSpace, indexTenor, clearedRateAssets, PricingStructureIdentifier.BaseDate, fixingCalendar, rollCalendar);
            termCurve.point            = ClearedRateBootstrapper.Bootstrap(PriceableClearedRateAssets, BaseDiscountingCurve, curveId.BaseDate, termCurve.extrapolationPermitted,
                                                                           termCurve.interpolationMethod, Tolerance);
            CreatePricingStructure(curveId, termCurve, clearedRateAssets);
            // CreatePricingStructure(curveId, termCurve, PriceableAssetFactory.Parse(PriceableClearedRateAssets));
            // Interpolate the DiscountFactor curve based on the respective curve interpolation
            SetInterpolator(termCurve);
        }