public static AssetMeasureType Copy(AssetMeasureType assetMeasure)
        {
            var assetMeasureType = new AssetMeasureType {
                Value = assetMeasure.Value
            };

            return(assetMeasureType);
        }
        public static AssetMeasureType Create(AssetMeasureEnum assetMeasure)
        {
            var assetMeasureType = new AssetMeasureType {
                Value = assetMeasure.ToString()
            };

            return(assetMeasureType);
        }
Exemplo n.º 3
0
 public static BasicQuotation Create(AssetMeasureType measureType, PriceQuoteUnits priceUnits, string sideAsString)
 {
     ParseQuotationSideEnum(sideAsString, out var sideSpecified, out var side);
     return(new BasicQuotation
     {
         valueSpecified = false,
         measureType = measureType,
         quoteUnits = priceUnits,
         sideSpecified = sideSpecified,
         side = side
     });
 }
        public static AssetMeasureType Parse(string measureTypeAsString)
        {
            // ensures value is valid enum string
            AssetMeasureEnum assetMeasureEnum = AssetMeasureEnum.Undefined;

            if (measureTypeAsString != null)
            {
                assetMeasureEnum = AssetMeasureScheme.ParseEnumString(measureTypeAsString);
            }
            AssetMeasureType assetMeasureType = Create(assetMeasureEnum);

            return(assetMeasureType);
        }
        /// <summary>
        /// A helper to extract properties from a namedvalueset..
        /// </summary>
        /// <param name="propertyCollection">The collection of properties.</param>
        public static AssetMeasureType ExtractMeasureType(NamedValueSet propertyCollection)
        {
            AssetMeasureType measureType = null;
            var dictionaryKeys           = propertyCollection.ToDictionary();

            if (dictionaryKeys.ContainsKey("MeasureType"))
            {
                var result = propertyCollection.Get("MeasureType").AsValue <string>();
                measureType = new AssetMeasureType {
                    Value = result
                };
            }
            return(measureType);
        }
Exemplo n.º 6
0
        ///<summary>
        /// A swaption ppd grid.
        ///</summary>
        ///<param name="rows"></param>
        ///<param name="cols"></param>
        ///<param name="data"></param>
        public SwaptionPPDGrid(string[] rows, string[] cols, object[][] data)
            : this()
        {
            measureType = new AssetMeasureType {
                Value = "PPD"
            };
            quoteUnits = new PriceQuoteUnits {
                Value = "points"
            };
            // build the co-ordinate tree.. data[row][column]
            // row = expiry, column = tenor
            var points = new List <PricingStructurePoint>();

            for (int row = 0; row < rows.Length; row++)
            {
                for (int col = 0; col < cols.Length; col++)
                {
                    if (data[row][col] != null)
                    {
                        var currentPoint = new PricingStructurePoint {
                            coordinate = new PricingDataPointCoordinate[1]
                        };
                        // Set up the coordinate for this point
                        currentPoint.coordinate[0] = new PricingDataPointCoordinate {
                            expiration = new TimeDimension[1]
                        };
                        // The row - Expiry
                        currentPoint.coordinate[0].expiration[0] = new TimeDimension
                        {
                            Items =
                                new object[] { PeriodHelper.Parse(rows[row]) }
                        };
                        // The column - Tenor
                        currentPoint.coordinate[0].term    = new TimeDimension[1];
                        currentPoint.coordinate[0].term[0] = new TimeDimension
                        {
                            Items = new object[] { PeriodHelper.Parse(cols[col]) }
                        };
                        // The data value
                        currentPoint.valueSpecified = true;
                        currentPoint.value          = Convert.ToDecimal(data[row][col]);
                        points.Add(currentPoint);
                    }
                }
            }
            point = points.ToArray();
        }
        /// <summary>
        /// Aggregates the coupon metric.
        /// </summary>
        /// <param name="childValuations">The metrics.</param>
        /// <param name="controllerMetrics">The controller metrics</param>
        /// <returns></returns>
        protected static AssetValuation AggregateMetrics(List <AssetValuation> childValuations, List <string> controllerMetrics)
        {
            var result = new AssetValuation();
            var quotes = new List <Quotation>();

            foreach (var metric in controllerMetrics)
            {
                var quote   = new Quotation();
                var measure = new AssetMeasureType {
                    Value = metric
                };
                quote.measureType    = measure;
                quote.value          = Aggregator.SumDecimals(childValuations.Select(valuation => Aggregator.SumDecimals(GetMetricResults(valuation, metric))).ToArray());
                quote.valueSpecified = true;
                quotes.Add(quote);
            }
            result.quote = quotes.ToArray();
            return(result);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Creates the asset valuation.
        /// </summary>
        /// <param name="metrics">The metrics.</param>
        /// <param name="baseDate">The base date.</param>
        /// <returns></returns>
        static public AssetValuation CreateAssetValuation(IEnumerable <string> metrics, DateTime baseDate)
        {
            var av     = new AssetValuation();
            var quotes = new List <Quotation>();

            foreach (string metric in metrics)
            {
                var quotation   = new Quotation();
                var measureType = new AssetMeasureType {
                    Value = metric
                };
                quotation.value                  = 0.0m;
                quotation.valueSpecified         = true;
                quotation.measureType            = measureType;
                quotation.valuationDate          = baseDate;
                quotation.valuationDateSpecified = true;
                quotes.Add(quotation);
            }
            av.quote = quotes.ToArray();
            return(av);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates the asset valuation.
        /// </summary>
        /// <param name="metrics">The metrics.</param>
        /// <param name="baseDate">The base date.</param>
        /// <returns></returns>
        public static AssetValuation CreateAssetValuation(string[] metrics, DateTime baseDate)
        {
            var av     = new AssetValuation();
            var quotes = new Quotation[metrics.Length];
            int index  = 0;

            foreach (string metric in metrics)
            {
                var quotation   = new Quotation();
                var measureType = new AssetMeasureType {
                    Value = metric
                };
                quotation.value                  = 0.0m;
                quotation.measureType            = measureType;
                quotation.valuationDate          = baseDate;
                quotation.valuationDateSpecified = true;
                quotes[index] = quotation;
                index++;
            }
            av.quote = quotes;
            return(av);
        }