Fix Morningstar feeds

This commit is contained in:
2025-11-03 21:13:14 -05:00
parent 58e8664176
commit 0fb1d19481
2 changed files with 113 additions and 103 deletions

View File

@@ -1,5 +1,3 @@
using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Extensions.Configuration;
using MarketData.DataAccess;
using MarketData.Generator.CMMomentum;
@@ -12,8 +10,6 @@ using System.Diagnostics;
using System.Net.Http.Headers;
// https://www.google.com/search?q=launch.json+for+debugging+c%23+unit+test&client=firefox-b-1-d&sca_esv=f0447ad3867c1f39&ei=OMQHaYOlB9GFwbkPgJbUiAs&ved=0ahUKEwiDocWOrNSQAxXRQjABHQALFbEQ4dUDCBE&uact=5&oq=launch.json+for+debugging+c%23+unit+test&gs_lp=Egxnd3Mtd2l6LXNlcnAiJmxhdW5jaC5qc29uIGZvciBkZWJ1Z2dpbmcgYyMgdW5pdCB0ZXN0MgUQABjvBTIIEAAYgAQYogQyCBAAGKIEGIkFMgUQABjvBUjvFFDdCFjtDXABeAGQAQCYAX6gAdICqgEDMC4zuAEDyAEA-AEBmAIEoALkAsICChAAGLADGNYEGEfCAgoQIRigARjDBBgKwgIIECEYoAEYwwSYAwCIBgGQBgiSBwMxLjOgB_AHsgcDMC4zuAffAsIHBTAuMi4yyAcJ&sclient=gws-wiz-serp
namespace MarketDataUnitTests;
[TestClass]
@@ -51,6 +47,18 @@ public class MarketDataUnitTestClass
return true;
}
/// <summary>
/// This is not working because the website has changed formats
/// </summary>
[TestMethod]
[Ignore]
public void AnalystRatingsMarketBeatRetrieval()
{
String symbol = "AAPL";
AnalystRatings analystRatings = MarketDataHelper.GetAnalystRatingsMarketBeat(symbol);
Assert.IsTrue(null != analystRatings && analystRatings.Count > 0);
}
[TestMethod]
public void GetDailyPricesYahooRetrieval()
{
@@ -273,18 +281,6 @@ public class MarketDataUnitTestClass
Assert.IsTrue(null != analystRatings && analystRatings.Count > 0);
}
/// <summary>
/// This is not working because the website has changed formats
/// </summary>
[TestMethod]
[Ignore]
public void AnalystRatingsMarketBeatRetrieval()
{
String symbol = "AAPL";
AnalystRatings analystRatings = MarketDataHelper.GetAnalystRatingsMarketBeat(symbol);
Assert.IsTrue(null != analystRatings && analystRatings.Count > 0);
}
[TestMethod]
public void SECCIKRetrieval()
{
@@ -310,7 +306,7 @@ public class MarketDataUnitTestClass
DateTime analysisDate = dateGenerator.FindPrevBusinessDay(DateTime.Now);
YieldCurve yieldCurve = MarketDataHelper.GetYieldCurve(analysisDate.Year);
Assert.IsTrue(null != yieldCurve && yieldCurve.Count > 0);
Assert.IsTrue(yieldCurve[yieldCurve.Count - 1].Date.Month.Equals(analysisDate.Month));
Assert.IsTrue(yieldCurve[yieldCurve.Count - 1].Date.Month>=(analysisDate.Month));
}
[TestMethod]
@@ -344,20 +340,6 @@ public class MarketDataUnitTestClass
Assert.IsTrue(null != companyHeadlines && companyHeadlines.Count > 0);
}
// Test MarketWatch feed
// https://www.marketwatch.com/investing/stock/AAPL?mod=search_symbol
/// <summary>
/// MarketWatch/BigCharts is no longer working
/// </summary>
[TestMethod]
[Ignore]
public void HeadlinesMarketWatchRetrieval()
{
String symbol = "MIDD";
Headlines companyHeadlines = MarketDataHelper.GetCompanyHeadlinesMarketWatch(symbol);
Assert.IsTrue(null != companyHeadlines && companyHeadlines.Count > 0);
}
// Test NASDAQ Headlines feed
[TestMethod]
public void HeadlinesNASDAQRetrieval()
@@ -367,30 +349,6 @@ public class MarketDataUnitTestClass
Assert.IsTrue(null != companyHeadlines && companyHeadlines.Count > 0);
}
// Test SEEKING ALPHA Headlines feed
/// <summary>
/// SeekingAlpha headlines feed is not working
/// </summary>
[TestMethod]
[Ignore]
public void HeadlinesSeekingAlphaRetrieval()
{
String symbol = "GLD";
Headlines companyHeadlines = MarketDataHelper.GetCompanyHeadlinesSeekingAlpha(symbol);
Assert.IsTrue(null != companyHeadlines && companyHeadlines.Count > 0);
}
/// <summary>
/// SeekingAlpha feed is not working
/// </summary>
[TestMethod]
[Ignore]
public void HeadlinesSeekingAlphaV3Retrieval()
{
String symbol = "MIDD";
Headlines companyHeadlines = MarketDataHelper.GetCompanyHeadlinesSeekingAlphaV3(symbol, true);
Assert.IsTrue(null != companyHeadlines && companyHeadlines.Count > 0);
}
[TestMethod]
public void AnalystPriceTargetMarketBeatRetrieval()
@@ -405,7 +363,8 @@ public class MarketDataUnitTestClass
}
/// <summary>
/// Need to figure out why this is not working
/// This is the MorningStar historical value retrieval
/// If this breaks then try updating the salVersion in the helper method
/// </summary>
[TestMethod]
public void HistoricalRetrieval()
@@ -427,6 +386,44 @@ public class MarketDataUnitTestClass
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.OperatingCashflow), "Missing OperatingCashflow");
}
/// <summary>
/// This is the Morningstar Cashflow statement retrieval
/// If this breaks then try updating the salVersion in the helper method
/// </summary>
[TestMethod]
public void CashflowStatementMorningStarRetrieval()
{
String[] symbols = { "AZEK", "CPRT", "DOCU", "ESTC", "HLNE" };
Dictionary<String, List<CashflowStatement>> cashflowStatementsDict = new Dictionary<String, List<CashflowStatement>>();
foreach (String symbol in symbols)
{
List<CashflowStatement> cashflowStatements = MarketDataHelper.GetCashflowStatement(symbol, CashflowStatement.PeriodType.Annual);
if (null == cashflowStatements) continue;
cashflowStatementsDict.Add(symbol, cashflowStatements);
}
Assert.IsTrue(cashflowStatementsDict.Count != 0, "Error retrieving cashflow statements.");
List<String> keys = cashflowStatementsDict.Keys.ToList();
foreach (String key in keys)
{
List<CashflowStatement> cashflowStatements = cashflowStatementsDict[key];
CashflowStatement cashflowStatement = cashflowStatements[0];
Assert.IsTrue(!double.IsNaN(cashflowStatement.DepreciationAndAmortization), $"DepreciationAndAmortization for {key}");
Assert.IsTrue(!double.IsNaN(cashflowStatement.DeferredIncomeTaxes), $"DeferredIncomeTaxes for {key}");
Assert.IsTrue(!double.IsNaN(cashflowStatement.StockBasedCompensation), $"StockBasedCompensation for {key}");
Assert.IsTrue(!double.IsNaN(cashflowStatement.AccountsReceivable), $"AccountsReceivable for {key}");
Assert.IsTrue(!double.IsNaN(cashflowStatement.Inventory), $"Inventory for {key}");
Assert.IsTrue(!double.IsNaN(cashflowStatement.AccountsPayable), $"AccountsPayable for {key}");
Assert.IsTrue(!double.IsNaN(cashflowStatement.AccruedLiabilities), $"AccruedLiabilities for {key}");
Assert.IsTrue(!double.IsNaN(cashflowStatement.OperatingCashflow), $"OperatingCashflow for {key}");
Assert.IsTrue(!double.IsNaN(cashflowStatement.FreeCashflow), $"FreeCashflow for {key}");
}
}
[TestMethod]
public void IncomeStatementNASDAQRetrieval()
{
@@ -465,44 +462,6 @@ public class MarketDataUnitTestClass
Assert.IsTrue(!double.IsNaN(balanceSheet.TotalLiabilities), "TotalLiabilities");
}
/// <summary>
/// Need to figure out why this is not working.
/// </summary>
[TestMethod]
public void CashflowStatementMorningStarRetrieval()
{
String[] symbols = { "AZEK", "CPRT", "DOCU", "ESTC", "HLNE" };
Dictionary<String, List<CashflowStatement>> cashflowStatementsDict = new Dictionary<String, List<CashflowStatement>>();
foreach (String symbol in symbols)
{
List<CashflowStatement> cashflowStatements = MarketDataHelper.GetCashflowStatement(symbol, CashflowStatement.PeriodType.Annual);
if (null == cashflowStatements) continue;
cashflowStatementsDict.Add(symbol, cashflowStatements);
}
Assert.IsTrue(cashflowStatementsDict.Count != 0, "Error retrieving cashflow statements.");
List<String> keys = cashflowStatementsDict.Keys.ToList();
foreach (String key in keys)
{
List<CashflowStatement> cashflowStatements = cashflowStatementsDict[key];
CashflowStatement cashflowStatement = cashflowStatements[0];
Assert.IsTrue(!double.IsNaN(cashflowStatement.DepreciationAndAmortization), $"DepreciationAndAmortization for {key}");
Assert.IsTrue(!double.IsNaN(cashflowStatement.DeferredIncomeTaxes), $"DeferredIncomeTaxes for {key}");
Assert.IsTrue(!double.IsNaN(cashflowStatement.StockBasedCompensation), $"StockBasedCompensation for {key}");
Assert.IsTrue(!double.IsNaN(cashflowStatement.AccountsReceivable), $"AccountsReceivable for {key}");
Assert.IsTrue(!double.IsNaN(cashflowStatement.Inventory), $"Inventory for {key}");
Assert.IsTrue(!double.IsNaN(cashflowStatement.AccountsPayable), $"AccountsPayable for {key}");
Assert.IsTrue(!double.IsNaN(cashflowStatement.AccruedLiabilities), $"AccruedLiabilities for {key}");
Assert.IsTrue(!double.IsNaN(cashflowStatement.OperatingCashflow), $"OperatingCashflow for {key}");
Assert.IsTrue(!double.IsNaN(cashflowStatement.FreeCashflow), $"FreeCashflow for {key}");
}
}
[TestMethod]
public void CurrencyConversionXERetrieval()
{
@@ -553,5 +512,43 @@ public class MarketDataUnitTestClass
Assert.IsTrue(!double.IsNaN(fundamental.DebtToEquity), "DebtToEquity");
}
// Test SEEKING ALPHA Headlines feed
/// <summary>
/// SeekingAlpha headlines feed is not working
/// </summary>
[TestMethod]
[Ignore]
public void HeadlinesSeekingAlphaRetrieval()
{
String symbol = "GLD";
Headlines companyHeadlines = MarketDataHelper.GetCompanyHeadlinesSeekingAlpha(symbol);
Assert.IsTrue(null != companyHeadlines && companyHeadlines.Count > 0);
}
/// <summary>
/// SeekingAlpha feed is not working
/// </summary>
[TestMethod]
[Ignore]
public void HeadlinesSeekingAlphaV3Retrieval()
{
String symbol = "MIDD";
Headlines companyHeadlines = MarketDataHelper.GetCompanyHeadlinesSeekingAlphaV3(symbol, true);
Assert.IsTrue(null != companyHeadlines && companyHeadlines.Count > 0);
}
// Test MarketWatch feed
// https://www.marketwatch.com/investing/stock/AAPL?mod=search_symbol
/// <summary>
/// MarketWatch/BigCharts is no longer working
/// </summary>
[TestMethod]
[Ignore]
public void HeadlinesMarketWatchRetrieval()
{
String symbol = "MIDD";
Headlines companyHeadlines = MarketDataHelper.GetCompanyHeadlinesMarketWatch(symbol);
Assert.IsTrue(null != companyHeadlines && companyHeadlines.Count > 0);
}
}