Ejemplo n.º 1
0
        public QdpMarket TestMarket(string valueDate, BondMktData bondMktData)
        {
            var historiclIndexRates = HistoricalDataLoadHelper.HistoricalIndexRates;

            var curveConvention = new CurveConvention("fr007CurveConvention",
                                                      "CNY",
                                                      "ModifiedFollowing",
                                                      "Chn_ib",
                                                      "Act365",
                                                      "Continuous",
                                                      "CubicHermiteMonotic");

            var fr007CurveName      = "Fr007";
            var fr007RateDefinition = new[]
            {
                new RateMktData("1D", 0.035, "Spot", "None", fr007CurveName),
                new RateMktData("5Y", 0.035, "Spot", "None", fr007CurveName),
            };


            var curveDefinition = new[]
            {
                new InstrumentCurveDefinition(fr007CurveName, curveConvention, fr007RateDefinition, "SpotCurve"),
            };

            var marketInfo = new MarketInfo("tmpMarket", valueDate, curveDefinition)
            {
                BondMktDatas         = new[] { bondMktData },
                HistoricalIndexRates = historiclIndexRates
            };
            QdpMarket market;

            MarketFunctions.BuildMarket(marketInfo, out market);
            return(market);
        }
Ejemplo n.º 2
0
        private IMarketCondition GenerateMarketConditionFromPrebuilt(PrebuiltQdpMarket prebuiltMarket)
        {
            var         valuationParameter = TradeInfo.ValuationParamters;
            BondMktData bondMktData        = null;

            if (prebuiltMarket.BondPrices.ContainsKey(TradeInfo.TradeId))
            {
                bondMktData = prebuiltMarket.BondPrices[TradeInfo.TradeId];
            }
            if (valuationParameter == null)
            {
                return(new MarketCondition(
                           x => x.ValuationDate.Value = prebuiltMarket.ReferenceDate,
                           x => x.DiscountCurve.Value = null,
                           x => x.FixingCurve.Value = null,
                           x => x.RiskfreeCurve.Value = null,
                           x => x.MktQuote.Value = new Dictionary <string, Tuple <PriceQuoteType, double> > {
                    { TradeInfo.TradeId, Tuple.Create((bondMktData == null || string.IsNullOrEmpty(bondMktData.PriceQuoteType)) ? PriceQuoteType.None : bondMktData.PriceQuoteType.ToPriceQuoteType(), (bondMktData == null ? 100.0 : bondMktData.Quote)) }
                },
                           x => x.HistoricalIndexRates.Value = prebuiltMarket.HistoricalIndexRates));
            }

            var fixingCurveName = string.IsNullOrEmpty(valuationParameter.FixingCurveName)
                ? valuationParameter.DiscountCurveName
                : valuationParameter.FixingCurveName;

            return(new MarketCondition(
                       x => x.ValuationDate.Value = prebuiltMarket.ReferenceDate,
                       x => x.DiscountCurve.Value = prebuiltMarket.YieldCurves[valuationParameter.DiscountCurveName],
                       x => x.FixingCurve.Value = prebuiltMarket.YieldCurves[fixingCurveName],
                       x => x.RiskfreeCurve.Value = prebuiltMarket.YieldCurves[valuationParameter.RiskfreeCurveName],
                       x => x.MktQuote.Value = new Dictionary <string, Tuple <PriceQuoteType, double> > {
                { TradeInfo.TradeId, Tuple.Create((bondMktData == null || string.IsNullOrEmpty(bondMktData.PriceQuoteType)) ? PriceQuoteType.None : bondMktData.PriceQuoteType.ToPriceQuoteType(), (bondMktData == null ? 100.0 : bondMktData.Quote)) }
            },
                       x => x.HistoricalIndexRates.Value = prebuiltMarket.HistoricalIndexRates
                       ));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Add bond market data definition to an existing market.
        /// </summary>
        /// <param name="marketName">The Existing Market Name</param>
        /// <param name="bondId">The Bond Id</param>
        /// <param name="quoteType">The Price quote type(Clean, Dirty, Ytm, YtmExecution)</param>
        /// <param name="quote">The quote of bond</param>
        /// <param name="isOverride">if true, then add or override. if false, then ignore(default true)</param>
        /// <returns>if succeeded, return true. if failed, return error message : "Market {market object name} is not available!"</returns>
        public static object xl_MktAddBondData(string marketName, string bondId, string quoteType, double quote, bool isOverride = true)
        {
            var marketData = new BondMktData(bondId, quoteType, quote);

            return(XlManager.MergeMarketInfo(marketName, marketData, isOverride));
        }
Ejemplo n.º 4
0
        private IMarketCondition GenerateMarketConditionFromPrebuilt(PrebuiltQdpMarket prebuiltMarket)
        {
            var valuationParameter = TradeInfo.ValuationParamters;
            var mktQuote           = new Dictionary <string, Tuple <PriceQuoteType, double> >();

            try
            {
                if (prebuiltMarket.BondFuturePrices.ContainsKey(TradeInfo.TradeId))
                {
                    var futurePrice = prebuiltMarket.BondFuturePrices[TradeInfo.TradeId];
                    mktQuote[TradeInfo.TradeId] = Tuple.Create(PriceQuoteType.Dirty, futurePrice);
                }
                else
                {
                    mktQuote[TradeInfo.TradeId] = null;
                }
                foreach (var deliverableBondInfo in TradeInfo.DeliverableBondInfos)
                {
                    //var bondMktData =
                    BondMktData bondMktData = null;
                    if (prebuiltMarket.BondPrices.ContainsKey(deliverableBondInfo.TradeId))
                    {
                        bondMktData = prebuiltMarket.BondPrices[deliverableBondInfo.TradeId];
                    }
                    if (bondMktData != null)
                    {
                        mktQuote[deliverableBondInfo.TradeId] = Tuple.Create(bondMktData.PriceQuoteType.ToPriceQuoteType(), bondMktData.Quote);
                    }
                    var         tfBondId  = TradeInfo.TradeId + "_" + deliverableBondInfo.TradeId;
                    BondMktData tfMktData = null;
                    if (prebuiltMarket.BondPrices.ContainsKey(tfBondId))
                    {
                        tfMktData = prebuiltMarket.BondPrices[tfBondId];
                    }
                    if (tfMktData != null)
                    {
                        mktQuote[tfBondId] = Tuple.Create(tfMktData.PriceQuoteType.ToPriceQuoteType(), tfMktData.Quote);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new PricingBaseException(string.Format("Market price is missing, detailed message: {0}", ex.Message));
            }

            var fixingCurveName = valuationParameter.FixingCurveName;

            if (string.IsNullOrEmpty(fixingCurveName))
            {
                fixingCurveName = valuationParameter.DiscountCurveName;
            }

            return(new MarketCondition(
                       x => x.ValuationDate.Value = prebuiltMarket.ReferenceDate,
                       x => x.DiscountCurve.Value = prebuiltMarket.YieldCurves[valuationParameter.DiscountCurveName],
                       x => x.FixingCurve.Value = prebuiltMarket.YieldCurves[fixingCurveName],
                       x => x.RiskfreeCurve.Value = prebuiltMarket.YieldCurves[valuationParameter.RiskfreeCurveName],
                       x => x.MktQuote.Value = mktQuote,
                       x => x.HistoricalIndexRates.Value = prebuiltMarket.HistoricalIndexRates
                       ));
        }