Remove BigCharts pricing feed. Add Robinhood price feed

This commit is contained in:
2025-10-17 18:04:13 -04:00
parent a864a49cb3
commit 20cdbfa942
7 changed files with 678 additions and 965 deletions

View File

@@ -14,16 +14,16 @@ namespace MarketData.Utils
private FeedParser()
{
}
public static TimeSeriesCollection ParseTimeSeries(String symbol, List<DateTime> reportDates, TimeSeriesElement.ElementType elementType,String strLine)
public static TimeSeriesCollection ParseTimeSeries(String symbol, List<DateTime> reportDates, TimeSeriesElement.ElementType elementType, String strLine)
{
TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection();
Dictionary<DateTime,DateTime> dates = new Dictionary<DateTime,DateTime>();
Dictionary<DateTime, DateTime> dates = new Dictionary<DateTime, DateTime>();
try
{
if (null == reportDates || 0 == reportDates.Count) return null;
String[] lineItems = CSVLineHelper.ParseLine(strLine);
if (null == lineItems) return null;
for (int index = 0; index < reportDates.Count;index++)
for (int index = 0; index < reportDates.Count; index++)
{
TimeSeriesElement timeSeriesElement = new TimeSeriesElement();
timeSeriesElement.Type = elementType;
@@ -46,11 +46,11 @@ namespace MarketData.Utils
}
catch (Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,exception.ToString());
MDTrace.WriteLine(LogLevel.DEBUG, exception.ToString());
return null;
}
}
//"Book Value Per Share USD,3.31,3.22,2.64,2.58,2.28,2.10,1.39,2.64,3.88,3.94,3.94"
//"Book Value Per Share USD,3.31,3.22,2.64,2.58,2.28,2.10,1.39,2.64,3.88,3.94,3.94"
public static List<DateTime> ParsePeriodEndingDates(String periodEnding)
{
List<DateTime> periodEndingDates = new List<DateTime>();
@@ -58,7 +58,7 @@ namespace MarketData.Utils
periodEnding = periodEnding.Replace("Period Ending", "");
int length = periodEnding.Length;
int index = 0;
while (index<length)
while (index < length)
{
String strMonth = periodEnding.Substring(index, 3);
char ch;
@@ -69,7 +69,7 @@ namespace MarketData.Utils
sb = new StringBuilder();
for (int yIndex = 0; yIndex < 5; yIndex++) sb.Append(periodEnding[index++]);
String strYear = sb.ToString().Trim();
DateTime periodEndingDate=DateTime.ParseExact(strMonth+Utility.Pad(strDay,'0',2)+strYear, "MMMddyyyy", new System.Globalization.CultureInfo("en-US"));
DateTime periodEndingDate = DateTime.ParseExact(strMonth + Utility.Pad(strDay, '0', 2) + strYear, "MMMddyyyy", new System.Globalization.CultureInfo("en-US"));
periodEndingDates.Add(periodEndingDate);
}
return periodEndingDates;
@@ -78,11 +78,11 @@ namespace MarketData.Utils
{
try
{
if(strText.Contains("Est"))
if (strText.Contains("Est"))
{
strText=Utility.RemoveAfter(strText,'-');
strText = Utility.RemoveAfter(strText, '-');
strText = strText.Trim();
strText = strText + " "+DateTime.Now.Year.ToString();
strText = strText + " " + DateTime.Now.Year.ToString();
string[] items = strText.Split(' ');
strText = items[0] + "-" + Utility.Pad(items[1], '0', 2) + "-" + items[2];
return DateTime.ParseExact(strText, "MMM-dd-yyyy", new System.Globalization.CultureInfo("en-US"));
@@ -93,22 +93,22 @@ namespace MarketData.Utils
return DateTime.ParseExact(strText, "dd-MMM-yy", new System.Globalization.CultureInfo("en-US"));
}
}
catch(Exception)
catch (Exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,"[ParseValueDateTime] Error parsing date '"+strText+"'");
MDTrace.WriteLine(LogLevel.DEBUG, "[ParseValueDateTime] Error parsing date '" + strText + "'");
return DateTime.Parse("01-01-0001");
}
}
// "Middleby Corp. Fri, Aug 2, 2013"
// "Middleby Corp. Fri, Aug 2, 2013"
public static DateTime ParseValueDateTimeMonthFormatFromMarketWatch(String strItem)
{
strItem = Utility.RemoveControlChars(strItem.Trim());
String[] strItems = strItem.Split(' ');
if (strItems.Length < 3) return DateTime.Parse("01-01-0001"); ;
if (strItems.Length < 3) return DateTime.Parse("01-01-0001");
String strDate = strItems[strItems.Length - 3] + " " + strItems[strItems.Length - 2] + " " + strItems[strItems.Length - 1];
return ParseValueDateTimeMonthFormat(strDate);
}
public static double ParseValueFromMarketWatch(String identifier,String strItem)
public static double ParseValueFromMarketWatch(String identifier, String strItem)
{
try
{
@@ -146,15 +146,15 @@ namespace MarketData.Utils
{
try
{
if(null==strText)return Utility.Epoch;
if (null == strText) return Utility.Epoch;
String[] strArray = strText.Split(' ');
if (3 != strArray.Length) return DateTime.Parse("01-01-0001");
strArray[1] = strArray[1].Replace(",", "");
return ParseValueDateTime(Utility.Pad(strArray[1],'0',2)+"-"+strArray[0]+"-"+strArray[2].Substring(2,2));
return ParseValueDateTime(Utility.Pad(strArray[1], '0', 2) + "-" + strArray[0] + "-" + strArray[2].Substring(2, 2));
}
catch (Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,"[ParseValueDateTimeMonthFormat] Error parsing date '" + strText + "', "+exception.ToString());
MDTrace.WriteLine(LogLevel.DEBUG, "[ParseValueDateTimeMonthFormat] Error parsing date '" + strText + "', " + exception.ToString());
return DateTime.Parse("01-01-0001");
}
}
@@ -164,23 +164,23 @@ namespace MarketData.Utils
{
try
{
if(null==strText)return DateTime.Parse("01-01-0001");
if (null == strText) return DateTime.Parse("01-01-0001");
if(strText.EndsWith("am") || strText.EndsWith("pm"))
if (strText.EndsWith("am") || strText.EndsWith("pm"))
{
return DateTime.Now;
}
else if(strText.Contains("."))
else if (strText.Contains("."))
{
strText=strText.Replace(".",null);
String[] subItems=strText.Split(' ');
strText = strText.Replace(".", null);
String[] subItems = strText.Split(' ');
DateTime currentDate = DateTime.Now;
StringBuilder sb=new StringBuilder();
StringBuilder sb = new StringBuilder();
sb.Append(subItems[0]).Append(" ");
sb.Append(subItems[1]).Append(",").Append(" ");
sb.Append(currentDate.Year.ToString());
DateTime resultingDate = ParseValueDateTimeMonthFormat(sb.ToString());
if(resultingDate>currentDate)resultingDate = new DateTime(resultingDate.Year-1,resultingDate.Month, resultingDate.Day);
if (resultingDate > currentDate) resultingDate = new DateTime(resultingDate.Year - 1, resultingDate.Month, resultingDate.Day);
return resultingDate;
}
else
@@ -201,16 +201,16 @@ namespace MarketData.Utils
{
try
{
if(null==strText)return Utility.Epoch;
if (null == strText) return Utility.Epoch;
String[] strArray = strText.Split(' ');
if (3 > strArray.Length) return DateTime.Parse("01-01-0001");
strArray[1] = strArray[1].Replace(",", null);
strArray[0] = strArray[0].Replace(".", null);
return ParseValueDateTime(Utility.Pad(strArray[1],'0',2)+"-"+strArray[0]+"-"+strArray[2].Substring(2,2));
return ParseValueDateTime(Utility.Pad(strArray[1], '0', 2) + "-" + strArray[0] + "-" + strArray[2].Substring(2, 2));
}
catch (Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,"[ParseValueDateTimeMonthFormat] Error parsing date '" + strText + "', "+exception.ToString());
MDTrace.WriteLine(LogLevel.DEBUG, "[ParseValueDateTimeMonthFormat] Error parsing date '" + strText + "', " + exception.ToString());
return DateTime.Parse("01-01-0001");
}
}
@@ -219,33 +219,33 @@ namespace MarketData.Utils
{
try
{
DateTime today=DateTime.Now;
if(strDate.Contains("day"))
DateTime today = DateTime.Now;
if (strDate.Contains("day"))
{
DateGenerator dateGenerator=new DateGenerator();
String[] items=strDate.Split(' ');
DateTime relativeDate=dateGenerator.GenerateHistoricalDate(today,int.Parse(items[0])+1);
DateGenerator dateGenerator = new DateGenerator();
String[] items = strDate.Split(' ');
DateTime relativeDate = dateGenerator.GenerateHistoricalDate(today, int.Parse(items[0]) + 1);
return relativeDate;
}
else if(strDate.Contains("hour"))
else if (strDate.Contains("hour"))
{
String[] items=strDate.Split(' ');
TimeSpan timeSpan=new TimeSpan(int.Parse(items[0]),0,0);
DateTime relativeDate=today.Subtract(timeSpan);
String[] items = strDate.Split(' ');
TimeSpan timeSpan = new TimeSpan(int.Parse(items[0]), 0, 0);
DateTime relativeDate = today.Subtract(timeSpan);
return relativeDate;
}
else if(strDate.Contains("minute"))
else if (strDate.Contains("minute"))
{
String[] items=strDate.Split(' ');
TimeSpan timeSpan=new TimeSpan(0,int.Parse(items[0]),0);
DateTime relativeDate=today.Subtract(timeSpan);
String[] items = strDate.Split(' ');
TimeSpan timeSpan = new TimeSpan(0, int.Parse(items[0]), 0);
DateTime relativeDate = today.Subtract(timeSpan);
return relativeDate;
}
return ParseValueDateTimeMonthFormat(strDate);
}
catch(Exception)
catch (Exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Unable to parse date '{0}'",strDate));
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("Unable to parse date '{0}'", strDate));
return null;
}
}
@@ -256,15 +256,15 @@ namespace MarketData.Utils
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.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(")", "");
strText = strText.Replace("(", "");
strText = strText.Replace(")", "");
multiplier = -1.00;
}
if (strText.Equals("-")) return double.NaN;
@@ -286,7 +286,7 @@ namespace MarketData.Utils
value = double.Parse(strText);
value *= 1000000;
}
else if (strText[strText.Length - 1].Equals('K')||strText[strText.Length - 1].Equals('k'))
else if (strText[strText.Length - 1].Equals('K') || strText[strText.Length - 1].Equals('k'))
{
strText = strText.Replace("K", "");
strText = strText.Replace("k", "");
@@ -299,7 +299,7 @@ namespace MarketData.Utils
}
catch (Exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,"[ParseValue] Error parsing '"+strText+"'");
MDTrace.WriteLine(LogLevel.DEBUG, "[ParseValue] Error parsing '" + strText + "'");
return double.NaN;
}
}
@@ -309,8 +309,8 @@ namespace MarketData.Utils
long value;
try
{
if(null==strText)return 0;
strText=strText.Replace("%","");
if (null == strText) return 0;
strText = strText.Replace("%", "");
strText = strText.Replace(",", "");
if (strText.Equals("-")) return 0;
if (strText[strText.Length - 1].Equals('B'))
@@ -336,9 +336,46 @@ namespace MarketData.Utils
}
catch (Exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,"[ParseValueLong] Error parsing '" + strText + "'");
MDTrace.WriteLine(LogLevel.DEBUG, "[ParseValueLong] Error parsing '" + strText + "'");
return 0;
}
}
public static double ParseValueDouble(String strText)
{
double value;
try
{
if(null==strText)return 0;
strText=strText.Replace("%","");
strText = strText.Replace(",", "");
if (strText.Equals("-")) return 0;
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.Replace("K", "");
value = double.Parse(strText);
value *= 1000;
}
else value = double.Parse(strText);
return value;
}
catch (Exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,"[ParseValueDouble] Error parsing '" + strText + "'");
return 0;
}
}
}
}

View File

@@ -36,7 +36,7 @@ namespace MarketDataLib.Utility
while (true)
{
String itemsInSection = GetItemsInSection(strInput, sectionName, ref searchIndex);
if(null==itemsInSection)break;
if (null == itemsInSection) break;
sectionItems.Add(itemsInSection);
searchIndex++;
}
@@ -106,18 +106,19 @@ namespace MarketDataLib.Utility
}
return false;
}
public static bool FindInSectionsReverse(List<String> sections,String startsWith,int startingIndex,ref int indexOfItem,bool findExact=true)
public static bool FindInSectionsReverse(List<String> sections, String startsWith, int startingIndex, ref int indexOfItem, bool findExact = true)
{
for(int index=startingIndex;index>=0;index--)
for (int index = startingIndex; index >= 0; index--)
{
if(!findExact &&sections[index].StartsWith(startsWith))
if (!findExact && sections[index].StartsWith(startsWith))
{
indexOfItem=index;
indexOfItem = index;
return true;
}
else if(sections[index].Equals(startsWith))
else if (sections[index].Equals(startsWith))
{
indexOfItem=index;
indexOfItem = index;
return true;
}
}

View File

@@ -609,7 +609,8 @@ namespace MarketData.Utils
public static DateTime ParseDate(String strDate)
{
System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("en-US");
String[] formats=new[] { "MM/dd/yyyy HH:MM tt", "yyyy-MM-dd","yy-MM-dd","yyyy-MM-dd hh:mm:ss tt","dddd, MMMM dd","MMM dd yyyy","yyyy-MM","ddd, MMM. d","ddd, MMM. dd","yyyy/MM/dd","M-d-yyyy","dd-MM-yyyy","MM-dd-yyyy","M.d.yyyy","dd.MM.yyyy","MM.dd.yyyy","yyyyMMdd" }.Union(cultureInfo.DateTimeFormat.GetAllDateTimePatterns()).ToArray();
String[] formats=new[] { "MMMM dd,yyyy" ,"yyyy-MM-dd HH:mm:ss","MM/dd/yyyy HH:MM tt", "yyyy-MM-dd","yy-MM-dd","yyyy-MM-dd hh:mm:ss tt","dddd, MMMM dd","MMM dd yyyy","yyyy-MM","ddd, MMM. d","ddd, MMM. dd","yyyy/MM/dd","M-d-yyyy","dd-MM-yyyy","MM-dd-yyyy","M.d.yyyy","dd.MM.yyyy","MM.dd.yyyy","yyyyMMdd" }.Union(cultureInfo.DateTimeFormat.GetAllDateTimePatterns()).ToArray();
strDate = strDate.Trim();
DateTime dateTime=DateTime.ParseExact(strDate, formats, cultureInfo, DateTimeStyles.AssumeLocal);
return dateTime;