Fix ETF Holdings feed

This commit is contained in:
2025-04-12 20:46:09 -04:00
parent d12b23cad6
commit 761d90a8f5
3 changed files with 26 additions and 16 deletions

View File

@@ -1380,7 +1380,6 @@ namespace MarketData.Helper
ETFHoldings etfHoldings = new ETFHoldings();
try
{
WriteToDisk(responseString,$"{etfSymbol}_etfholdings.txt");
DateTime modified = DateTime.Now;
int groupBy=3;
List<String> sections = Sections.GetAllItemsInSections(responseString,"section");
@@ -1408,15 +1407,37 @@ namespace MarketData.Helper
ETFHolding etfHolding = new ETFHolding();
if(index+2>=spans.Count())continue;
List<String> subSectionsSymbol = Sections.GetSections(spans[index]);
List<String> subSectionsCompanyName = Sections.GetSections(spans[index+1]);
List<String> subSectionsPercentOfAssets = Sections.GetSections(spans[index+2]);
etfHolding.ETFSymbol = etfSymbol;
etfHolding.HoldingSymbolShareClass = null;
etfHolding.HoldingCompanyName = Utility.BetweenString(spans[index+1],">","<");
if(null!=subSectionsSymbol && subSectionsSymbol.Count>0)etfHolding.HoldingSymbol = subSectionsSymbol.Where(x => !String.IsNullOrEmpty(x)).FirstOrDefault();
if (null == etfHolding.HoldingSymbol || "N/A".Equals(etfHolding.HoldingSymbol) || "".Equals(etfHolding.HoldingSymbol)) continue;
if(null!=subSectionsSymbol && subSectionsSymbol.Count>0)
{
etfHolding.HoldingSymbol = subSectionsSymbol.Where(x => !String.IsNullOrEmpty(x)).FirstOrDefault();
}
if (null == etfHolding.HoldingSymbol || "N/A".Equals(etfHolding.HoldingSymbol) || "".Equals(etfHolding.HoldingSymbol))
{
MDTrace.WriteLine(LogLevel.DEBUG,$"ETFHolding Symbol was not provided in the response for {etfSymbol}");
break; // we always expect to have a symbol, otherewise something is wrong with the collection.
}
if(null!=subSectionsCompanyName && subSectionsCompanyName.Count>0)
{
etfHolding.HoldingCompanyName = subSectionsCompanyName.Where(x => !String.IsNullOrEmpty(x)).FirstOrDefault();
}
etfHolding.PercentOfAssets = FeedParser.ParseValue(subSectionsPercentOfAssets.Where(x => !String.IsNullOrEmpty(x)).FirstOrDefault());
if(double.IsNaN(etfHolding.PercentOfAssets))
{
MDTrace.WriteLine(LogLevel.DEBUG,$"ETFHolding Unable to parse PercentOfAssets for Symbol {etfSymbol}.");
}
etfHolding.Modified = modified;
if(FeedParser.IsNumeric(etfHolding.HoldingSymbol))continue;
etfHolding.HoldingSymbol=etfHolding.HoldingSymbol.Trim().ToUpper();
etfHoldings.Add(etfHolding);
}
}

View File

@@ -304,14 +304,6 @@ namespace MarketData.Utils
}
}
public static bool IsNumeric(String strText)
{
strText=strText.Replace("%", "");
strText = strText.Replace("$", "");
double value = 0.00;
return double.TryParse(strText, out value);
}
public static long ParseValueLong(String strText)
{
long value;

View File

@@ -42,9 +42,6 @@ namespace MarketDataLib.Utility
}
return sectionItems;
}
public static List<String> GetSections(String strInput)
{
try