Fix GetDailyPrices
Some checks failed
Build .NET Project / build (push) Has been cancelled

This commit is contained in:
2026-03-18 09:38:53 -04:00
parent 516dbd8ffd
commit df899ca293
2 changed files with 151 additions and 21 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -254,51 +255,116 @@ namespace MarketData.Utils
}
}
// public static double ParseValue(String strText)
// {
// double value = double.NaN;
// double multiplier = 1.00;
// try
// {
// if (null == strText || 0 == strText.Length) return double.NaN;
// strText = strText.Trim();
// if (strText.StartsWith("--")) return double.NaN;
// if (strText.Equals("N/A")) return double.NaN;
// strText = strText.Replace("%", "");
// strText = strText.Replace("$", "");
// if (strText.Contains("("))
// {
// strText = strText.Replace("(", "");
// strText = strText.Replace(")", "");
// multiplier = -1.00;
// }
// if (strText.Equals("-")) return double.NaN;
// if (strText[strText.Length - 1].Equals('T'))
// {
// strText = strText.Replace("T", "");
// value = double.Parse(strText);
// value *= 1000000000000;
// }
// if (strText[strText.Length - 1].Equals('B'))
// {
// strText = strText.Replace("B", "");
// value = double.Parse(strText);
// value *= 1000000000;
// }
// else if (strText[strText.Length - 1].Equals('M'))
// {
// strText = strText.Replace("M", "");
// value = double.Parse(strText);
// value *= 1000000;
// }
// else if (strText[strText.Length - 1].Equals('K') || strText[strText.Length - 1].Equals('k'))
// {
// strText = strText.Replace("K", "");
// strText = strText.Replace("k", "");
// value = double.Parse(strText);
// value *= 1000;
// }
// else value = double.Parse(strText);
// value *= multiplier;
// return value;
// }
// catch (Exception)
// {
// MDTrace.WriteLine(LogLevel.DEBUG, "[ParseValue] Error parsing '" + strText + "'");
// return double.NaN;
// }
// }
public static double ParseValue(String strText)
{
double value = double.NaN;
double multiplier = 1.00;
try
{
if (null == strText || 0 == strText.Length) return double.NaN;
strText = strText.Trim();
strText = strText.Replace(",", "");
if (strText.StartsWith("--")) return double.NaN;
if (strText.Equals("N/A")) return double.NaN;
strText = strText.Replace("%", "");
strText = strText.Replace("$", "");
if (strText.Contains("("))
{
strText = strText.Replace("(", "");
strText = strText.Replace(")", "");
multiplier = -1.00;
}
if (strText.Length == 0) return double.NaN;
if (strText.Equals("-")) return double.NaN;
if (strText[strText.Length - 1].Equals('T'))
{
strText = strText.Replace("T", "");
value = double.Parse(strText);
value = double.Parse(strText, CultureInfo.InvariantCulture);
value *= 1000000000000;
}
if (strText[strText.Length - 1].Equals('B'))
else if (strText[strText.Length - 1].Equals('B'))
{
strText = strText.Replace("B", "");
value = double.Parse(strText);
value = double.Parse(strText, CultureInfo.InvariantCulture);
value *= 1000000000;
}
else if (strText[strText.Length - 1].Equals('M'))
{
strText = strText.Replace("M", "");
value = double.Parse(strText);
value = double.Parse(strText, CultureInfo.InvariantCulture);
value *= 1000000;
}
else if (strText[strText.Length - 1].Equals('K') || strText[strText.Length - 1].Equals('k'))
{
strText = strText.Replace("K", "");
strText = strText.Replace("k", "");
value = double.Parse(strText);
value = double.Parse(strText, CultureInfo.InvariantCulture);
value *= 1000;
}
else value = double.Parse(strText);
else value = double.Parse(strText, CultureInfo.InvariantCulture);
value *= multiplier;
return value;
}
@@ -309,6 +375,8 @@ namespace MarketData.Utils
}
}
public static long ParseValueLong(String strText)
{
long value;