Exemple #1
0
        /// <summary>
        /// Creates the pricing structure.
        /// </summary>
        protected void CreatePricingStructure(EquityCurveIdentifier curveId, TermCurve termCurve, FxRateSet quotedAssetSet)
        {
            FpML.V5r10.Reporting.FxCurve fxCurve          = CreateEquityCurve(curveId);
            FxCurveValuation             fxCurveValuation = CreateEquityCurveValuation(curveId, quotedAssetSet, termCurve);
            var fpmlData = new Pair <PricingStructure, PricingStructureValuation>(fxCurve, fxCurveValuation);

            SetFpMLData(fpmlData, false);
        }
Exemple #2
0
        /////<summary>
        /////</summary>
        /////<returns></returns>
        //public decimal GetSpotRate()
        //{
        //    var fxVal = (FxCurveValuation)GetFpMLData().Second;
        //    BasicAssetValuation spotRateAsset = (from spotRateAssets in fxVal.spotRate.assetQuote
        //                                         where spotRateAssets.objectReference.href.EndsWith("-Equity-SP", StringComparison.InvariantCultureIgnoreCase)//TODO FIX This!
        //                                         select spotRateAssets).Single();
        //    decimal spotRate = spotRateAsset.quote[0].value;
        //    return spotRate;
        //}

        /// <summary>
        ///
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="cache"></param>
        /// <param name="nameSpace">THe client namespace</param>
        /// <param name="equityId">THe curve asset.</param>
        /// <param name="fixingCalendar"></param>
        /// <param name="rollCalendar"></param>
        /// <param name="baseDate"></param>
        /// <returns></returns>
        protected static DateTime GetSettlementDate(ILogger logger, ICoreCache cache, string nameSpace,
                                                    EquityCurveIdentifier equityId, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar, DateTime baseDate)
        {
            BasicAssetValuation bav = BasicAssetValuationHelper.Create(BasicQuotationHelper.Create(0, "MarketQuote", PriceQuoteUnitsEnum.Price.ToString()));
            var assetId             = BuildSpotAssetId(equityId);
            var priceableAsset      = (IPriceableEquityAssetController)PriceableAssetFactory.Create(logger, cache, nameSpace, assetId, baseDate, bav, fixingCalendar, rollCalendar);

            return(priceableAsset.GetRiskMaturityDate());
        }
Exemple #3
0
        /// <summary>
        /// Creates the equity curve.
        /// </summary>
        /// <param name="curveId">The curve id.</param>
        /// <returns></returns>
        protected static FpML.V5r10.Reporting.FxCurve CreateEquityCurve(EquityCurveIdentifier curveId)
        {
            var fxCurve = new FpML.V5r10.Reporting.FxCurve
            {
                id       = curveId.Id,
                name     = curveId.CurveName,
                currency = curveId.Currency,
            };

            return(fxCurve);
        }
Exemple #4
0
        /// <summary>
        /// </summary>
        /// <param name="fxRates">The spot rate.</param>
        /// <param name="curveId">The curve id.</param>
        /// <param name="termCurve">The bootstrapped term curve.</param>
        /// <returns></returns>
        private FxCurveValuation CreateEquityCurveValuation(EquityCurveIdentifier curveId, FxRateSet fxRates,
                                                            TermCurve termCurve)
        {
            var fxCurveValuation = new FxCurveValuation
            {
                baseDate               = IdentifiedDateHelper.Create(curveId.BaseDate),
                buildDateTime          = curveId.BaseDate,
                buildDateTimeSpecified = true,
                spotRate               = fxRates,
                id             = curveId.UniqueIdentifier,
                fxForwardCurve = termCurve,
                spotDate       = IdentifiedDateHelper.Create("SettlementDate", SettlementDate),
            };

            return(fxCurveValuation);
        }
Exemple #5
0
        private void InitialiseInstance(ILogger logger, ICoreCache cache, string nameSpace,
                                        NamedValueSet properties, FxRateSet assetSet, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar)
        {
            PricingStructureData = new PricingStructureData(CurveType.Parent, AssetClass.Equity, properties);
            var curveId = new EquityCurveIdentifier(properties);

            PricingStructureIdentifier = curveId;
            Holder = new PricingStructureAlgorithmsHolder(logger, cache, nameSpace, curveId.PricingStructureType, curveId.Algorithm);
            DateTime baseDate = PricingStructureIdentifier.BaseDate;

            //Set the spot date;
            SettlementDate = GetSettlementDate(logger, cache, nameSpace, GetEquityCurveId(), fixingCalendar, rollCalendar, baseDate);
            //TODO
            //FixingCalendar = null;
            //RollCalendar = null;
            // The bootstrapper to use
            BootstrapperName = Holder.GetValue("Bootstrapper");
            Tolerance        = double.Parse(Holder.GetValue("Tolerance"));
            bool extrapolationPermitted             = bool.Parse(Holder.GetValue("ExtrapolationPermitted"));
            InterpolationMethod interpolationMethod = InterpolationMethodHelper.Parse(Holder.GetValue("BootstrapperInterpolation"));
            var termCurve = new TermCurve
            {
                extrapolationPermitted          = extrapolationPermitted,
                extrapolationPermittedSpecified = true,
                interpolationMethod             = interpolationMethod
            };

            PriceableEquityAssets = PriceableAssetFactory.CreatePriceableEquityAssets(logger, cache, nameSpace, baseDate, assetSet, fixingCalendar, rollCalendar);
            termCurve.point       = EquityBootstrapper.Bootstrap(PriceableEquityAssets, baseDate, termCurve.extrapolationPermitted,
                                                                 termCurve.interpolationMethod, Tolerance);
            // Pull out the fx curve and fx curve valuation
            Pair <PricingStructure, PricingStructureValuation> fpmlData
                = CreateFpmlPair(logger, cache, nameSpace, baseDate, (EquityCurveIdentifier)PricingStructureIdentifier, assetSet, termCurve, fixingCalendar, rollCalendar);

            SetFpmlData(fpmlData);
            // Interpolate the DiscountFactor curve based on the respective curve interpolation
            SetInterpolator(baseDate);
        }
Exemple #6
0
        /// <summary>
        /// Creates the pricing structure.
        /// </summary>
        protected void CreatePricingStructure(EquityCurveIdentifier curveId, TermCurve termCurve, IEnumerable <IPriceableEquityAssetController> priceableEquityAssets)
        {
            FxRateSet quotedAssetSet = priceableEquityAssets != null?PriceableAssetFactory.Parse(priceableEquityAssets) : null;

            CreatePricingStructure(curveId, termCurve, quotedAssetSet);
        }
Exemple #7
0
 private static string BuildSpotAssetId(EquityCurveIdentifier equityId)
 {
     return(equityId.Currency.Value + "-Equity-" + equityId.EquityAsset);
 }
Exemple #8
0
        /// <summary>
        /// Creates the equity curve.
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="cache">The cache.</param>
        /// <param name="nameSpace">THe client namespace</param>
        /// <param name="equityId">THe underlying curve asset.</param>
        /// <param name="fixingCalendar"></param>
        /// <param name="rollCalendar"></param>
        /// <param name="baseDate">The base date.</param>
        /// <param name="fxRates">The spot rate.</param>
        /// <param name="curveId">The curve id.</param>
        /// <param name="termCurve">The bootstrapped term curve.</param>
        /// <returns></returns>
        private static FxCurveValuation CreateEquityCurveValuation(ILogger logger, ICoreCache cache, string nameSpace, EquityCurveIdentifier equityId,
                                                                   IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar, DateTime baseDate, FxRateSet fxRates, string curveId,
                                                                   TermCurve termCurve)
        {
            DateTime settlementDate   = GetSettlementDate(logger, cache, nameSpace, equityId, fixingCalendar, rollCalendar, baseDate);
            var      fxCurveValuation = new FxCurveValuation
            {
                baseDate               = IdentifiedDateHelper.Create(baseDate),
                buildDateTime          = baseDate,
                buildDateTimeSpecified = true,
                spotRate               = fxRates,
                id             = curveId,
                fxForwardCurve = termCurve,
                spotDate       = IdentifiedDateHelper.Create("SettlementDate", settlementDate)
            };

            return(fxCurveValuation);
        }
Exemple #9
0
        private static Pair <PricingStructure, PricingStructureValuation> CreateFpmlPair(ILogger logger, ICoreCache cache, string nameSpace, DateTime baseDate,
                                                                                         EquityCurveIdentifier curveId, FxRateSet assetSet, TermCurve termCurve, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar)
        {
            FpML.V5r10.Reporting.FxCurve fxCurve          = CreateEquityCurve(curveId.Id, curveId.CurveName, curveId.Currency);
            FxCurveValuation             fxCurveValuation = CreateEquityCurveValuation(logger, cache, nameSpace, curveId, fixingCalendar, rollCalendar, baseDate, assetSet, fxCurve.id, termCurve);

            return(new Pair <PricingStructure, PricingStructureValuation>(fxCurve, fxCurveValuation));
        }