Example #1
0
        /// <summary>
        /// Parses the contents as a FactorFile, if error returns a new empty factor file
        /// </summary>
        public static FactorFile SafeRead(string filename, IEnumerable <string> contents)
        {
            var permtick = Path.GetFileNameWithoutExtension(filename);

            try
            {
                DateTime?minimumDate;
                // FactorFileRow.Parse handles entries with 'inf' and exponential notation and provides the associated minimum tradeable date for these cases
                // previously these cases were not handled causing an exception and returning an empty factor file
                return(new FactorFile(permtick, FactorFileRow.Parse(contents, out minimumDate), minimumDate));
            }
            catch
            {
                return(new FactorFile(permtick, Enumerable.Empty <FactorFileRow>()));
            }
        }