Ejemplo n.º 1
0
        /// <summary>Calculates the worst total margin among all the regulations for the specified regulation role and for the entities defined in the specified CRIF file.</summary>
        /// <param name="regulationRole">An enumerator value of type <see cref="T:InitialMargin.Core.RegulationRole"/> that specifies the target regulation role.</param>
        /// <param name="crifPath">The <see cref="T:System.String"/> representing the CRIF file that defines the target entities.</param>
        /// <returns>A <see cref="T:InitialMargin.Core.MarginTotal"/> object representing the worst total margin among all the regulations.</returns>
        /// <exception cref="T:System.ArgumentException">Thrown when <paramref name="crifPath">crifPath</paramref> is invalid or does not refer to a CSV file.</exception>
        /// <exception cref="T:System.ComponentModel.InvalidEnumArgumentException">Thrown when <paramref name="regulationRole">regulationRole</paramref> is undefined.</exception>
        /// <exception cref="T:System.IO.FileNotFoundException">Thrown when <paramref name="crifPath">crifPath</paramref> could not be found.</exception>
        /// <exception cref="T:System.IO.InvalidDataException">Thrown when the CRIF file contains invalid or malformed data.</exception>
        public MarginTotal CalculateDetailedWorstOf(RegulationRole regulationRole, String crifPath)
        {
            ICollection <DataEntity> entities   = CrifManager.Read(crifPath);
            List <DataValue>         values     = entities.OfType <DataValue>().ToList();
            List <DataParameter>     parameters = entities.OfType <DataParameter>().ToList();

            return(CalculateDetailedWorstOf(regulationRole, values, parameters));
        }
Ejemplo n.º 2
0
        /// <summary>Calculates the total margin amount of each regulation for the specified regulation role and for the entities defined in the specified CRIF file.</summary>
        /// <param name="regulationRole">An enumerator value of type <see cref="T:InitialMargin.Core.RegulationRole"/> that specifies the target regulation role.</param>
        /// <param name="crifPath">The <see cref="T:System.String"/> representing the CRIF file that defines the target entities.</param>
        /// <returns>An <see cref="System.Collections.Generic.IDictionary{TKey,TValue}"/> of pairs defined by <see cref="T:InitialMargin.Core.Regulation"/> keys and <see cref="T:InitialMargin.Core.Amount"/> values representing the regulation/amount couples.</returns>
        /// <exception cref="T:System.ArgumentException">Thrown when <paramref name="crifPath">crifPath</paramref> is invalid or does not refer to a CSV file.</exception>
        /// <exception cref="T:System.ComponentModel.InvalidEnumArgumentException">Thrown when <paramref name="regulationRole">regulationRole</paramref> is undefined.</exception>
        /// <exception cref="T:System.IO.FileNotFoundException">Thrown when <paramref name="crifPath">crifPath</paramref> could not be found.</exception>
        /// <exception cref="T:System.IO.InvalidDataException">Thrown when the CRIF file contains invalid or malformed data.</exception>
        public IDictionary <Regulation, Amount> CalculateByRole(RegulationRole regulationRole, String crifPath)
        {
            ICollection <DataEntity> entities   = CrifManager.Read(crifPath);
            List <DataValue>         values     = entities.OfType <DataValue>().ToList();
            List <DataParameter>     parameters = entities.OfType <DataParameter>().ToList();

            return(CalculateByRole(regulationRole, values, parameters));
        }
Ejemplo n.º 3
0
        public void TestInputCrif(String crifFile)
        {
            String        crifFilePath = Utilities.GetStaticFilePath(crifFile);
            List <String> expected     = CrifManager.Read(crifFilePath).Select(x => x.ToString()).ToList();
            List <String> actual       = m_TestsFixture.DataEntities.Select(x => x.ToString()).ToList();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 4
0
        public void TestOutputCrif(String crifFile)
        {
            String crifExpectedFile = Utilities.GetStaticFilePath(crifFile);
            String crifActualFile   = Utilities.GetRandomFilePath(".csv");

            CrifManager.Write(crifActualFile, m_TestsFixture.DataEntities);

            String crifExpectedContent = Regex.Replace(File.ReadAllText(crifExpectedFile), @"\d{4}-\d{2}-\d{2}", String.Empty);
            String expected            = Utilities.ComputeHash(crifExpectedContent);

            String crifActualContent = Regex.Replace(File.ReadAllText(crifActualFile), @"\d{4}-\d{2}-\d{2}", String.Empty);
            String actual            = Utilities.ComputeHash(crifActualContent);

            try
            {
                File.Delete(crifActualFile);
            }
            catch { }

            Assert.Equal(expected, actual);
        }