Пример #1
0
        /// <summary>
        /// A helper to extract properties from a named value set.
        /// </summary>
        /// <param name="properties">The collection of properties.</param>
        public static string ExtractCreditSeniority(NamedValueSet properties)
        {
            string creditSeniority;
            Dictionary <string, object> dictionaryKeys = properties.ToDictionary();

            if (dictionaryKeys.ContainsKey(CurveProp.CreditSeniority))
            {
                creditSeniority = properties.Get(CurveProp.CreditSeniority).AsValue <string>();
            }
            else
            {
                string pst = ExtractPricingStructureType(properties).ToString();
                creditSeniority = "Senior";
                if (pst == PricingStructureTypeEnum.DiscountCurve.ToString())
                {
                    var           curveName = properties.Get("CurveName").AsValue <string>();
                    List <string> parts     = curveName.Split('-').ToList();
                    if (parts.Count > 2)
                    {
                        creditSeniority = parts[2];
                    }
                }
            }
            return(creditSeniority);
        }
Пример #2
0
        public void BuildTest()
        {
            string[]      names  = { "CurveType", "ExpiryMins" };
            object[]      values = { "RateCurve", 1 };
            NamedValueSet actual = NamedValueSetHelper.Build(names, values);

            Assert.AreEqual("RateCurve", actual.Get("CurveType").ValueString);
            Assert.AreEqual(1, actual.Get("ExpiryMins").Value);
        }
Пример #3
0
        public void RangeToNamedValueSetTest()
        {
            object[,] properties = new object[, ]
            {
                { "CurveType", "RateCurve" },
                { "ExpiryMins", 1 }
            };
            NamedValueSet actual = new NamedValueSet(properties);

            Assert.AreEqual("RateCurve", actual.Get("CurveType").ValueString);
            Assert.AreEqual(1, actual.Get("ExpiryMins").Value);
        }
Пример #4
0
        public void DistinctInstancesTest()
        {
            object[,] properties = new object[, ]
            {
                { "CurveType", "RateCurve" },
                { "ExpiryMins", 1 },
                { "ExpiryMins", 2 }
            };
            NamedValueSet actual = NamedValueSetHelper.DistinctInstances(properties);

            Assert.AreEqual("RateCurve", actual.Get("CurveType").ValueString);
            Assert.AreEqual(1, ((object[])actual.Get("ExpiryMins").Value)[0]);
            Assert.AreEqual(2, ((object[])actual.Get("ExpiryMins").Value)[1]);
        }
Пример #5
0
        /// <summary>
        /// A helper to extract properties from a named value set..
        /// </summary>
        /// <param name="properties">The collection of properties.</param>
        public static string ExtractDataType(NamedValueSet properties)
        {
            const string dataType       = "Market";
            var          dictionaryKeys = properties.ToDictionary();

            return(dictionaryKeys.ContainsKey("DataType") ? properties.Get("DataType").AsValue <string>() : dataType);
        }
Пример #6
0
        /// <summary>
        /// A helper to extract properties from a named value set..
        /// </summary>
        /// <param name="properties">The collection of properties.</param>
        public static string ExtractAssetRef(NamedValueSet properties)
        {
            const string assetRef       = "Unspecified";
            var          dictionaryKeys = properties.ToDictionary();

            return(dictionaryKeys.ContainsKey("AssetRef") ? properties.Get("AssetRef").AsValue <string>() : assetRef);
        }
Пример #7
0
        /// <summary>
        /// A helper to extract properties from a named value set..
        /// </summary>
        /// <param name="properties">The collection of properties.</param>
        public static string ExtractSourceSystem(NamedValueSet properties)
        {
            const string sourceSystem   = "Orion";
            var          dictionaryKeys = properties.ToDictionary();

            return(dictionaryKeys.ContainsKey("SourceSystem") ? properties.Get("SourceSystem").AsValue <string>() : sourceSystem);
        }
Пример #8
0
        /// <summary>
        /// A helper to extract properties from a named value set.
        /// </summary>
        /// <param name="properties">The collection of properties.</param>
        public static DateTime ExtractBuildDateTime(NamedValueSet properties)
        {
            var      dictionaryKeys = properties.ToDictionary();
            DateTime buildDateTime  = dictionaryKeys.ContainsKey("BuildDateTime") ? properties.Get("BuildDateTime").AsValue <DateTime>() : DateTime.Now;

            return(buildDateTime);
        }
Пример #9
0
        /// <summary>
        /// A helper to extract properties from a named value set..
        /// </summary>
        /// <param name="propertyName">THe property name.</param>
        /// <param name="properties">The collection of properties.</param>
        public static string ExtractStringProperty(string propertyName, NamedValueSet properties)
        {
            const string error          = "Unknown Property.";
            var          dictionaryKeys = properties.ToDictionary();

            return(dictionaryKeys.ContainsKey(propertyName) ? properties.Get(propertyName).AsValue <string>() : error);
        }
        /// <summary>
        /// A helper to extract properties from a namedvalueset..
        /// </summary>
        /// <param name="propertyCollection">The collection of properties.</param>
        public static QuotedCurrencyPair ExtractQuotedCurrencyPair(NamedValueSet propertyCollection)
        {
            var dictionaryKeys = propertyCollection.ToDictionary();

            string currencyPair = "AUD-USD";

            if (dictionaryKeys.ContainsKey(CurveProp.CurrencyPair))
            {
                currencyPair = propertyCollection.Get(CurveProp.CurrencyPair).AsValue <string>();
            }
            else
            {
                if (dictionaryKeys.ContainsKey(CurveProp.CurveName))
                {
                    var curveName = ExtractCurveName(propertyCollection);

                    try
                    {
                        currencyPair = curveName;
                    }
                    catch (System.Exception)
                    {
                        throw new System.Exception("CurveName property is not valid.");
                    }
                }
            }
            var pair = currencyPair.Split('-');

            var quoteBasis = ExtractQuoteBasis(propertyCollection);

            return(QuotedCurrencyPair.Create(pair[0], pair[1], quoteBasis));
        }
        /// <summary>
        /// A helper to extract properties from a named value set.
        /// </summary>
        /// <param name="propertyCollection">The collection of properties.</param>
        public static string ExtractMarketEnvironment(NamedValueSet propertyCollection)
        {
            var dictionaryKeys = propertyCollection.ToDictionary();

            if (dictionaryKeys.ContainsKey("MarketEnvironment"))
            {
                return(propertyCollection.Get("MarketEnvironment").AsValue <string>());
            }
            throw new System.Exception("Mandatory 'MarketEnvironment' property has not been specified. Please specify.");
        }
        /// <summary>
        /// A helper to extract properties from a named value set.
        /// </summary>
        /// <param name="propertyCollection">The collection of properties.</param>
        public static string ExtractIndexTenor(NamedValueSet propertyCollection)
        {
            var dictionaryKeys = propertyCollection.ToDictionary();

            if (dictionaryKeys.ContainsKey(CurveProp.IndexTenor))
            {
                return(propertyCollection.Get(CurveProp.IndexTenor).AsValue <string>());
            }
            throw new System.Exception("Mandatory 'IndexTenor' property has not been specified. Please specify.");
        }
Пример #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VolatilitySurfaceTerms"/> class.
        /// </summary>
        /// <param name="terms">The terms.</param>
        public VolatilitySurfaceTerms(IDictionary <string, object> terms)
        {
            Terms = terms;
            var nvs = new NamedValueSet();

            nvs.Add(terms);
            if (nvs.Get(CurveProp.Market, false) != null)
            {
                Market = nvs.GetValue <string>(CurveProp.Market, null);
            }
            else if (nvs.Get("Market", false) != null)
            {
                Market = nvs.GetValue <string>("Market", null);
            }
            Currency     = nvs.GetValue <string>(CurveProp.Currency1, null);
            BaseDate     = nvs.GetValue(CurveProp.BaseDate, DateTime.MinValue);
            ReferenceKey = BuildKey();
            SurfaceReferenceIdentifier = null;
        }
        /// <summary>
        /// A helper to extract properties from a named value set.
        /// </summary>
        /// <param name="propertyCollection">The collection of properties.</param>
        public static Boolean ExtractLPMCopy(NamedValueSet propertyCollection)
        {
            var lpmCopy        = false;
            var dictionaryKeys = propertyCollection.ToDictionary();

            if (dictionaryKeys.ContainsKey("LPMCopy"))
            {
                lpmCopy = propertyCollection.Get("LPMCopy").AsValue <Boolean>();
            }
            return(lpmCopy);
        }
Пример #15
0
        /// <summary>
        /// A helper to extract properties from a named value set..
        /// </summary>
        /// <param name="propertyName">THe property name.</param>
        /// <param name="properties">The collection of properties.</param>
        public static int?ExtractIntegerProperty(string propertyName, NamedValueSet properties)
        {
            int?result         = null;
            var dictionaryKeys = properties.ToDictionary();

            if (dictionaryKeys.ContainsKey(propertyName))
            {
                result = properties.Get(propertyName).AsValue <int>();
            }
            return(result);
        }
Пример #16
0
        /// <summary>
        /// A helper to extract properties from a named value set.
        /// </summary>
        /// <param name="properties">The collection of properties.</param>
        public static Boolean ExtractIsBaseCurveFlag(NamedValueSet properties)
        {
            var dictionaryKeys = properties.ToDictionary();

            if (dictionaryKeys.ContainsKey("IsBaseCurve"))
            {
                var isBaseCurve = properties.Get("IsBaseCurve").AsValue <bool>();
                return(isBaseCurve);
            }
            return(true);
        }
Пример #17
0
        /// <summary>
        /// A helper to extract properties from a named value set.
        /// </summary>
        /// <param name="properties">The collection of properties.</param>
        public static string ExtractReferenceVolCurveName(NamedValueSet properties)
        {
            var curveName      = "Unknown";
            var dictionaryKeys = properties.ToDictionary();

            if (dictionaryKeys.ContainsKey("ReferenceVolCurveName"))
            {
                curveName = properties.Get("ReferenceVolCurveName").AsValue <string>();
            }
            return(curveName);
        }
Пример #18
0
        /// <summary>
        /// A helper to extract properties from a named value set.
        /// </summary>
        /// <param name="properties">The collection of properties.</param>
        public static Boolean ExtractOptimizeBuildFlag(NamedValueSet properties)
        {
            bool flag           = true;
            var  dictionaryKeys = properties.ToDictionary();

            if (dictionaryKeys.ContainsKey("OptimizeBuild"))
            {
                flag = properties.Get("OptimizeBuild").AsValue <bool>();
            }
            return(flag);
        }
Пример #19
0
        /// <summary>
        /// A helper to extract properties from a named value set..
        /// </summary>
        /// <param name="propertyName">THe property name.</param>
        /// <param name="properties">The collection of properties.</param>
        public static DateTime?ExtractDateTimeProperty(string propertyName, NamedValueSet properties)
        {
            DateTime?date           = null;
            var      dictionaryKeys = properties.ToDictionary();

            if (dictionaryKeys.ContainsKey(propertyName))
            {
                date = properties.Get(propertyName).AsValue <DateTime>();
            }
            return(date);
        }
Пример #20
0
        /// <summary>
        /// A helper to extract properties from a named value set.
        /// </summary>
        /// <param name="properties">The collection of properties.</param>
        public static DateTime?ExtractTime(NamedValueSet properties)
        {
            DateTime?time           = null;
            var      dictionaryKeys = properties.ToDictionary();

            if (dictionaryKeys.ContainsKey("Time"))
            {
                time = properties.Get("Time").AsValue <DateTime>();
            }
            return(time);
        }
Пример #21
0
        /// <summary>
        /// A helper to extract properties from a named value set.
        /// </summary>
        /// <param name="properties">The collection of properties.</param>
        public static Boolean ExtractBootStrapOverrideFlag(NamedValueSet properties)
        {
            bool flag           = false;
            var  dictionaryKeys = properties.ToDictionary();

            if (dictionaryKeys.ContainsKey("BootStrap"))
            {
                flag = properties.Get("BootStrap").AsValue <bool>();
            }
            return(flag);
        }
        /// <summary>
        /// A helper to extract properties from a named value set.
        /// </summary>
        /// <param name="propertyCollection">The collection of properties.</param>
        public static string ExtractInflationLag(NamedValueSet propertyCollection)
        {
            var dictionaryKeys = propertyCollection.ToDictionary();

            if (dictionaryKeys.ContainsKey("InflationLag"))
            {
                return(propertyCollection.Get("InflationLag").AsValue <string>());
            }
            //throw new Exception("Mandatory 'InflationLag' property has not been specified. Please specify.");
            return("Unknown");
        }
        /// <summary>
        /// A helper to extract properties from a namedvalueset..
        /// </summary>
        /// <param name="propertyCollection">The collection of properties.</param>
        public static DateTime?ExtractExpiryTime(NamedValueSet propertyCollection)
        {
            DateTime?expiryTime     = null;
            var      dictionaryKeys = propertyCollection.ToDictionary();

            if (dictionaryKeys.ContainsKey("ExpiryTime"))
            {
                expiryTime = propertyCollection.Get("ExpiryTime").AsValue <DateTime>();
            }
            return(expiryTime);
        }
        /// <summary>
        /// A helper to extract properties from a namedvalueset..
        /// </summary>
        /// <param name="propertyCollection">The collection of properties.</param>
        public static DateTime?ExtractValuationDate(NamedValueSet propertyCollection)
        {
            DateTime?valuationDate  = null;
            var      dictionaryKeys = propertyCollection.ToDictionary();

            if (dictionaryKeys.ContainsKey("ValuationDate"))
            {
                valuationDate = propertyCollection.Get("ValuationDate").AsValue <DateTime>();
            }
            return(valuationDate);
        }
Пример #25
0
        /// <summary>
        /// A helper to extract properties from a named value set..
        /// </summary>
        /// <param name="propertyName">THe property name.</param>
        /// <param name="properties">The collection of properties.</param>
        public static decimal?ExtractDecimalProperty(string propertyName, NamedValueSet properties)
        {
            decimal?result         = null;
            var     dictionaryKeys = properties.ToDictionary();

            if (dictionaryKeys.ContainsKey(propertyName))
            {
                result = properties.Get(propertyName).AsValue <decimal>();
            }
            return(result);
        }
Пример #26
0
        /// <summary>
        /// A helper to extract properties from a named value set..
        /// </summary>
        /// <param name="propertyName">THe property name.</param>
        /// <param name="properties">The collection of properties.</param>
        public static bool?ExtractBooleanProperty(string propertyName, NamedValueSet properties)
        {
            bool?boolean        = null;
            var  dictionaryKeys = properties.ToDictionary();

            if (dictionaryKeys.ContainsKey(propertyName))
            {
                boolean = properties.Get(propertyName).AsValue <bool>();
            }
            return(boolean);
        }
        /// <summary>
        /// A helper to extract properties from a namedvalueset..
        /// </summary>
        /// <param name="propertyCollection">The collection of properties.</param>
        public static string ExtractCurrency(NamedValueSet propertyCollection)
        {
            var currency       = "AUD";
            var dictionaryKeys = propertyCollection.ToDictionary();

            if (dictionaryKeys.ContainsKey("Currency"))
            {
                currency = propertyCollection.Get("Currency").AsValue <string>();
            }
            return(currency);
        }
Пример #28
0
        /// <summary>
        /// A helper to extract properties from a named value set.
        /// </summary>
        /// <param name="properties">The collection of properties.</param>
        public static Decimal?ExtractStrike(NamedValueSet properties)
        {
            Decimal?strike         = null;
            var     dictionaryKeys = properties.ToDictionary();

            if (dictionaryKeys.ContainsKey("Strike"))
            {
                strike = properties.Get("Strike").AsValue <Decimal>();
            }
            return(strike);
        }
Пример #29
0
        public T GetSetValue <T>(string valueName, T defaultValue)
        {
            NamedValue nv = _currentSettings.Get(valueName, false);

            if ((nv == null) || (nv.ValueType != typeof(T)))
            {
                _currentSettings.Set(valueName, defaultValue);
                _unsavedSettings.Set(valueName, defaultValue);
            }
            return(_currentSettings.GetValue(valueName, defaultValue));
        }
Пример #30
0
        /// <summary>
        /// A helper to extract properties from a named value set..
        /// </summary>
        /// <param name="properties">The collection of properties.</param>
        public static string ExtractUniqueCurveIdentifier(NamedValueSet properties)
        {
            var domain         = ExtractDomain(properties);
            var market         = ExtractMarketAndDate(properties);
            var pst            = ExtractPricingStructureType(properties);
            var curveName      = ExtractCurveName(properties);
            var identifier     = domain + '.' + market + '.' + pst + '.' + curveName;
            var dictionaryKeys = properties.ToDictionary();

            return(dictionaryKeys.ContainsKey(CurveProp.UniqueIdentifier) ? properties.Get(CurveProp.UniqueIdentifier).AsValue <string>() : identifier);
        }