コード例 #1
0
        public object[,] Publish(IPricingResult pricingResult)
        {
            var priceResult = pricingResult as PriceResult;

            if (priceResult != null)
            {
                return(PublishPriceResult(priceResult));
            }

            throw new Exception(string.Format("Pricing result publisher do not handle type {0}", pricingResult.GetType()));
        }
コード例 #2
0
        public static void Aggregate(this IPricingResult input, IPricingResult result2)
        {
            var result = (input as PricingResult);

            if (result == null)
            {
                return;
            }
            result.Pv   = Aggregate(result.Pv, result2.Pv);
            result.Dv01 = Aggregate(result.Dv01, result2.Dv01);
            result.Pv01 = Aggregate(result.Pv01, result2.Pv01);
            //result.Ai = result1.Ai  = Aggregate(result2. Ai);
            //result.AiEod = result1.AiEod  = Aggregate(result2. AiEod);
            //result.Ytm = result1.  = Aggregate(result2. );
            //result.DirtyPrice = result1.  = Aggregate(result2. );
            //result.CleanPrice = result1.  = Aggregate(result2. );
            result.Delta            = Aggregate(result.Delta, result2.Delta);
            result.DeltaCash        = Aggregate(result.DeltaCash, result2.DeltaCash);
            result.Gamma            = Aggregate(result.Gamma, result2.Gamma);
            result.GammaCash        = Aggregate(result.GammaCash, result2.GammaCash);
            result.Rho              = Aggregate(result.Rho, result2.Rho);
            result.RhoForeign       = Aggregate(result.RhoForeign, result2.RhoForeign);
            result.Vega             = Aggregate(result.Vega, result2.Vega);
            result.Theta            = Aggregate(result.Theta, result2.Theta);
            result.Dv01Underlying   = Aggregate(result.Dv01Underlying, result2.Dv01Underlying);
            result.MacDuration      = Aggregate(result.MacDuration, result2.MacDuration);
            result.ModifiedDuration = Aggregate(result.ModifiedDuration, result2.ModifiedDuration);
            result.Convexity        = Aggregate(result.Convexity, result2.Convexity);
            result.Carry            = Aggregate(result.Carry, result2.Carry);
            //result.Sp01 = Aggregate(result.Sp01, result2.Sp01);
            //result.ZeroSpread = result1.  = Aggregate(result2. );
            //result.FairQuote = result1.  = Aggregate(result2. );
            result.KeyRateDv01  = Aggregate(result.KeyRateDv01, result2.KeyRateDv01);
            result.Cashflows    = Aggregate(result.Cashflows, result2.Cashflows);
            result.CashflowDict = Aggregate(result.CashflowDict, result2.CashflowDict);
            //result.ComponentPvs = null;
            //result.ProductSpecific = new Dictionary<string, Dictionary<string, RateRecord>>();
            result.Succeeded = true;
            if (string.IsNullOrEmpty(result.ErrorMessage))
            {
                result.ErrorMessage = result2.ErrorMessage;
            }
            else
            {
                result.ErrorMessage += QdpConsts.MsgDelimiter + result2.ErrorMessage;
            }
        }
コード例 #3
0
        public void Apply(IPricingResult result)
        {
            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }
            if (result.Detail == null)
            {
                throw new ArgumentNullException(nameof(result.Detail));
            }

            if (result.Detail.Count() >= this.MinItemsInCart)
            {
                result.TotalDiscount  += result.TotalPrice / 100M * (decimal)this.PercentDiscount;
                result.TotalPriceToPay = result.TotalPrice - result.TotalDiscount;
            }
        }
コード例 #4
0
        private IPricingResult BondCalculate(string quoteBondId, Bond bond, IMarketCondition market)
        {
            var            bondQuote = market.MktQuote.Value.ContainsKey(quoteBondId) ? market.MktQuote.Value[quoteBondId] : null;
            var            executionYieldPricingRequest = PricingRequest.None;
            IPricingResult bondResult = null;

            if (bondQuote != null && bondQuote.Item1 != PriceQuoteType.None)
            {
                if (bondQuote.Item1 == PriceQuoteType.Dirty || bondQuote.Item1 == PriceQuoteType.Clean)
                {
                    executionYieldPricingRequest = PricingRequest.Ytm;
                }
                else if (bondQuote.Item1 == PriceQuoteType.Ytm || bondQuote.Item1 == PriceQuoteType.YtmExecution)
                {
                    executionYieldPricingRequest = PricingRequest.CleanPrice;
                }

                bondResult = CalcBond(bond, market, executionYieldPricingRequest | PricingRequest.YtmExecution);
            }

            return(bondResult);
        }