Пример #1
0
        /// <summary>
        /// Creates a PricingDataPointCoordinate.
        /// </summary>
        /// <param name="expiryDate"></param>
        /// <param name="maturityDate"></param>
        /// <param name="maturityTerm"></param>
        /// <param name="strike"></param>
        /// <param name="generic"></param>
        /// <returns></returns>
        public static PricingDataPointCoordinate Create(DateTime expiryDate,
                                                        DateTime maturityDate, Period maturityTerm, decimal strike, string generic)
        {
            var coordinate            = new PricingDataPointCoordinate();
            var pMaturityTerm         = maturityTerm;
            var pStrike               = strike;
            GenericDimension pGeneric = null;

            if (generic != null)
            {
                pGeneric = new GenericDimension {
                    name = generic, Value = generic
                };
            }
            coordinate.expiration    = new TimeDimension[1];
            coordinate.expiration[0] = TimeDimensionFactory.Create(expiryDate);
            coordinate.term          = new TimeDimension[1];
            coordinate.term[0]       = TimeDimensionFactory.Create(maturityDate, pMaturityTerm);
            coordinate.strike        = new[] { pStrike };
            if (pGeneric != null)
            {
                coordinate.generic = new[] { pGeneric }
            }
            ;
            return(coordinate);
        }
    }
Пример #2
0
        /// <summary>
        /// Creates a PricingDataPointCoordinate.
        /// </summary>
        /// <param name="expiry"></param>
        /// <param name="term"></param>
        /// <param name="strike"></param>
        /// <param name="generic"></param>
        /// <returns></returns>
        public static PricingDataPointCoordinate Create(string expiry, string term, decimal strike, string generic)
        {
            var coordinate = new PricingDataPointCoordinate();
            var pExpiry    = expiry != null?PeriodHelper.Parse(expiry) : null;

            var pTerm = term != null?PeriodHelper.Parse(term) : null;

            var pStrike = strike;
            GenericDimension pGeneric = null;

            if (generic != null)
            {
                pGeneric = new GenericDimension {
                    name = generic, Value = generic
                };
            }
            coordinate.expiration    = new TimeDimension[1];
            coordinate.expiration[0] = new TimeDimension {
                Items = new object[] { pExpiry }
            };
            if (pTerm != null)
            {
                coordinate.term    = new TimeDimension[1];
                coordinate.term[0] = new TimeDimension {
                    Items = new object[] { pTerm }
                };
            }
            coordinate.strike = new[] { pStrike };
            if (pGeneric != null)
            {
                coordinate.generic = new[] { pGeneric }
            }
            ;
            return(coordinate);
        }