Ejemplo n.º 1
0
        private static void UpdateEntry(EntryObject entry, IEnumerable <string> properties)
        {
            var entryType = entry.GetType();

            foreach (var name in properties)
            {
                var property  = entryType.GetProperty(name);
                var attribute = GetAttribute(property);

                if (attribute == null || attribute.IsReadOnly)
                {
                    continue;
                }

                var value = GetPropertyValue(entry, property);

                if (value != null)
                {
                    entry.Entry.Properties[attribute.Name].Value = value;
                }
                else
                {
                    entry.Entry.Properties[attribute.Name].Clear();
                }
            }
        }
Ejemplo n.º 2
0
        private static AddOnNotionalFactor ReadAddOnNotionalFactor(EntryObject o)
        {
            foreach (String property in s_Properties.Except(s_PropertiesCommon.Union(s_PropertiesScalar)))
            {
                if (!String.IsNullOrEmpty((String)o.GetType().GetProperty(property)?.GetValue(o)))
                {
                    throw new InvalidDataException($"The CRIF file cannot specify the {property} property for Param_AddOnNotionalFactor entries.");
                }
            }

            if (!DataValidator.IsValidNotionalQualifier(o.Qualifier))
            {
                throw new InvalidDataException("The CRIF file contains a Param_AddOnNotionalFactor entry with an invalid Qualifier property.");
            }

            if (!Decimal.TryParse(o.Amount, NumberStyles.Any, CultureInfo.InvariantCulture, out Decimal factor))
            {
                throw new InvalidDataException("The CRIF file contains a Param_AddOnNotionalFactor entry with an invalid Amount property.");
            }

            factor /= 100m;

            if ((factor <= 0m) || (factor > 1m))
            {
                throw new InvalidDataException("The CRIF file contains a Param_AddOnNotionalFactor entry whose factor is not between 0 and 100.");
            }

            RegulationsInfo regulationsInfo = ReadRegulationsInfo(o);

            return(AddOnNotionalFactor.OfUnchecked(o.Qualifier, factor, regulationsInfo));
        }
Ejemplo n.º 3
0
        private static AddOnProductMultiplier ReadProductMultiplier(EntryObject o)
        {
            foreach (String property in s_Properties.Except(s_PropertiesCommon.Union(s_PropertiesScalar)))
            {
                if (!String.IsNullOrEmpty((String)o.GetType().GetProperty(property)?.GetValue(o)))
                {
                    throw new InvalidDataException($"The CRIF file cannot specify the {property} property for Param_ProductClassMultiplier entries.");
                }
            }

            if (!Enum.TryParse(o.Qualifier, out Model.Product product))
            {
                throw new InvalidDataException("The CRIF file contains a Param_ProductClassMultiplier entry with an invalid Qualifier property.");
            }

            if (!Decimal.TryParse(o.Amount, NumberStyles.Any, CultureInfo.InvariantCulture, out Decimal multiplier))
            {
                throw new InvalidDataException("The CRIF file contains a Param_ProductClassMultiplier entry with an invalid Amount property.");
            }

            multiplier -= 1m;

            if (multiplier <= 0m)
            {
                throw new InvalidDataException("The CRIF file contains a Param_ProductClassMultiplier entry with a multiplier less than 1.");
            }

            RegulationsInfo regulationsInfo = ReadRegulationsInfo(o);

            return(AddOnProductMultiplier.OfUnchecked(product, multiplier, regulationsInfo));
        }
Ejemplo n.º 4
0
        private List <string> GetAllPropertyNames(EntryObject entryObject)
        {
            var type          = entryObject.GetType();
            var propertyNames = new List <string>();

            foreach (var item in type.GetProperties())
            {
                var attribute = GetAttribute(item);

                if (attribute == null || string.IsNullOrEmpty(attribute.Name) || attribute.IsReadOnly)
                {
                    continue;
                }

                propertyNames.Add(item.Name);
            }

            return(propertyNames);
        }
Ejemplo n.º 5
0
        private static AddOnFixedAmount ReadAddOnFixedAmount(EntryObject o)
        {
            if (o.InitialMarginModel != "SIMM")
            {
                throw new InvalidDataException("The CRIF file contains a Param_AddOnFixedAmount entry with the IMModel property not set to \"SIMM\".");
            }

            foreach (String property in s_Properties.Except(s_PropertiesAmount.Union(s_PropertiesCommon)))
            {
                if (!String.IsNullOrEmpty((String)o.GetType().GetProperty(property)?.GetValue(o)))
                {
                    throw new InvalidDataException($"The CRIF file cannot specify the {property} property for Param_AddOnFixedAmount entries.");
                }
            }

            Amount          amount          = ReadAmount(o);
            RegulationsInfo regulationsInfo = ReadRegulationsInfo(o);

            return(AddOnFixedAmount.OfUnchecked(amount, regulationsInfo));
        }
Ejemplo n.º 6
0
        private static AddOnNotional ReadAddOnNotional(EntryObject o)
        {
            foreach (String property in s_Properties.Except(s_PropertiesAmount.Union(s_PropertiesCommon).Union(s_PropertiesTrade)))
            {
                if (!String.IsNullOrEmpty((String)o.GetType().GetProperty(property)?.GetValue(o)))
                {
                    throw new InvalidDataException($"The CRIF file cannot specify the {property} property for Notional entries.");
                }
            }

            if (!DataValidator.IsValidNotionalQualifier(o.Qualifier))
            {
                throw new InvalidDataException("The CRIF file contains a Notional entry with an invalid Qualifier property.");
            }

            Amount          amount          = ReadAmount(o);
            RegulationsInfo regulationsInfo = ReadRegulationsInfo(o);
            TradeInfo       tradeInfo       = ReadTradeInfo(o);

            return(AddOnNotional.OfUnchecked(o.Qualifier, amount, regulationsInfo, tradeInfo));
        }
Ejemplo n.º 7
0
        private static PresentValue ReadPresentValue(EntryObject o)
        {
            foreach (String property in s_Properties.Except(s_PropertiesAmount.Union(s_PropertiesCommon).Union(s_PropertiesTrade).Union(s_PropertiesModel)))
            {
                if (!String.IsNullOrEmpty((String)o.GetType().GetProperty(property)?.GetValue(o)))
                {
                    throw new InvalidDataException($"The CRIF file cannot specify the {property} property for PV entries.");
                }
            }

            if (!Enum.TryParse(o.ProductClass, out Schedule.Product product))
            {
                throw new InvalidDataException("The CRIF file contains a PV entry with an invalid ProductClass property.");
            }

            Amount          amount          = ReadAmount(o);
            RegulationsInfo regulationsInfo = ReadRegulationsInfo(o);
            TradeInfo       tradeInfo       = ReadTradeInfo(o);

            return(PresentValue.OfUnchecked(product, amount, regulationsInfo, tradeInfo));
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RelationshipManager"/> class.
 /// </summary>
 /// <param name="entryParent">The entry parent.</param>
 public RelationshipManager(EntryObject entryParent)
 {
     EntryObject = entryParent;
     _parentType = entryParent.GetType();
 }