public static SensitivitySet Add(SensitivitySet sensitivitySet1, SensitivitySet sensitivitySet2)
        {
            SensitivitySet result = SensitivitySetHelper.Copy(sensitivitySet1);//BinarySerializerHelper.Clone(sensitivitySet1);//TODO problem with the binary serializer
            var            proccessedMeasureTypes = new List <string>();

            foreach (Sensitivity bq1 in result.sensitivity)
            {
                proccessedMeasureTypes.Add(bq1.name);
                //var sensitivity = new Sensitivity {name = bq1.name, Value = bq1.Value};
                Sensitivity bq2 = GetSensitivityByName(sensitivitySet2, bq1.name);
                if (null != bq2)
                {
                    bq1.Value += bq2.Value;
                }
            }
            var bqToAddToList = sensitivitySet2.sensitivity.Where(bq2 => - 1 == proccessedMeasureTypes.IndexOf(bq2.name)).ToList();

            bqToAddToList.AddRange(result.sensitivity);
            result.sensitivity = bqToAddToList.ToArray();
            return(result);
        }
Exemple #2
0
        public static Quotation Copy(Quotation baseQuotation)
        {
            Quotation quotation = null;

            if (baseQuotation != null)
            {
                quotation = new Quotation();
                if (baseQuotation.businessCenter != null)
                {
                    quotation.businessCenter = BusinessCentersHelper.Parse(baseQuotation.businessCenter.Value).businessCenter[0];
                }
                if (baseQuotation.currency != null)
                {
                    quotation.currency = CurrencyHelper.Parse(baseQuotation.currency.Value);
                }
                if (baseQuotation.valueSpecified)
                {
                    quotation.value          = baseQuotation.value;
                    quotation.valueSpecified = true;
                }
                if (baseQuotation.valuationDateSpecified)
                {
                    quotation.valuationDate          = baseQuotation.valuationDate;
                    quotation.valuationDateSpecified = true;
                }
                if (baseQuotation.expiryTimeSpecified)
                {
                    quotation.expiryTime          = baseQuotation.expiryTime;
                    quotation.expiryTimeSpecified = true;
                }
                if (baseQuotation.sideSpecified)
                {
                    quotation.side          = baseQuotation.side;
                    quotation.sideSpecified = true;
                }
                if (baseQuotation.timeSpecified)
                {
                    quotation.time          = baseQuotation.time;
                    quotation.timeSpecified = true;
                }
                if (baseQuotation.sensitivitySet != null)
                {
                    quotation.sensitivitySet = SensitivitySetHelper.Copy(baseQuotation.sensitivitySet);
                }
                if (baseQuotation.measureType != null)
                {
                    quotation.measureType = AssetMeasureTypeHelper.Copy(baseQuotation.measureType);
                }
                if (baseQuotation.quoteUnits != null)
                {
                    quotation.quoteUnits = PriceQuoteUnitsHelper.Copy(baseQuotation.quoteUnits);
                }
                if (baseQuotation.informationSource != null)
                {
                    quotation.informationSource = InformationSourceHelper.Copy(baseQuotation.informationSource).ToArray();
                }
                if (baseQuotation.exchangeId != null)
                {
                    quotation.exchangeId = ProductTypeHelper.ExchangeIdHelper.Copy(baseQuotation.exchangeId);
                }
            }
            return(quotation);
        }