Beispiel #1
0
 public static double CalculateRelativeVolume(long avgVolume, long volume)
 {
     if (avgVolume == (long)0 || volume == (long)0)
     {
         return(0);
     }
     return((DataTypeConverters.TryConvertToDouble(volume) / DataTypeConverters.TryConvertToDouble(avgVolume)).RoundTwoDecimalPlaces());
 }
Beispiel #2
0
        public static double TryParseChangePercentage(string value)
        {
            double num;

            try
            {
                num = DataTypeConverters.TryConvertToDouble(DataTypeConverters.StringToObject(value));
            }
            catch
            {
                num = 0;
            }
            return(num);
        }
Beispiel #3
0
        public static object StringToObject(string str)
        {
            string str1 = str.Replace("%", "").Replace("\"", "").Replace("<b>", "").Replace("</b>", "").Replace("N/A", "").Trim();

            if (str1 == string.Empty)
            {
                return(string.Empty);
            }
            if (str1 == "-")
            {
                return(string.Empty);
            }
            if (!str1.Contains(" - "))
            {
                double num = 0;
                if (double.TryParse(str1, out num))
                {
                    return(num);
                }
                long num1 = (long)0;
                if (long.TryParse(str1, out num1))
                {
                    return(num1);
                }
                DateTime dateTime = new DateTime();
                if (!DateTime.TryParse(str1, out dateTime))
                {
                    return(str1);
                }
                return(dateTime);
            }
            string[]      strArrays  = new string[] { " - " };
            string[]      strArrays1 = str1.Split(strArrays, StringSplitOptions.RemoveEmptyEntries);
            List <object> objs       = new List <object>();

            string[] strArrays2 = strArrays1;
            for (int i = 0; i < (int)strArrays2.Length; i++)
            {
                objs.Add(DataTypeConverters.StringToObject(strArrays2[i]));
            }
            if (objs.Count == 0)
            {
                return(string.Empty);
            }
            if (objs.Count != 0)
            {
                return(objs.ToArray());
            }
            return(objs[0]);
        }