|
|
|
|
@@ -12,6 +12,8 @@ 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]
|
|
|
|
|
@@ -50,6 +52,87 @@ public class MarketDataUnitTestClass
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// public static Price GetLatestPriceBarChart(string symbol);
|
|
|
|
|
// public static Price GetLatestPriceGoogle(string symbol);
|
|
|
|
|
// public static Price GetLatestPriceRobinhood(string symbol);
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void GetDailyPricesYahooRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol = "MIDD";
|
|
|
|
|
DateTime analysisDate = DateTime.Now;
|
|
|
|
|
DateGenerator dateGenerator = new DateGenerator();
|
|
|
|
|
analysisDate = dateGenerator.FindPrevBusinessDay(analysisDate);
|
|
|
|
|
Prices prices = MarketDataHelper.GetDailyPrices(symbol, analysisDate, analysisDate);
|
|
|
|
|
Assert.IsTrue(null != prices && prices.Count > 0, "No Price");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void LatestPriceRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol = "AAPL";
|
|
|
|
|
Price price = MarketDataHelper.GetLatestPrice(symbol);
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(null != price && price.IsValid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void LatestPriceGoogleRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol = "AAPL";
|
|
|
|
|
Price price = MarketDataHelper.GetLatestPriceGoogle(symbol);
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(null != price && price.IsValid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The GetLatestPriceYahoo feed may return a price that only contains the previous close.
|
|
|
|
|
// This can happen after market hours and does not mean that the feed is broken.
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void LatestPriceYahooRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol = "AAPL";
|
|
|
|
|
Price price = MarketDataHelper.GetLatestPriceYahoo(symbol);
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(null != price, "No Price from Yahoo");
|
|
|
|
|
Assert.IsTrue(price.IsValid || !double.IsNaN(price.PrevClose), "The feed is not working.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void LatestPriceBarChartRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol = "AAPL";
|
|
|
|
|
Price price = MarketDataHelper.GetLatestPriceBarChart(symbol);
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(null != price, "No Price from BarChart");
|
|
|
|
|
Assert.IsTrue(price.IsValid || !double.IsNaN(price.PrevClose), "The feed is not working.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void LatestPriceRobinhoodRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol = "AAPL";
|
|
|
|
|
Price price = MarketDataHelper.GetLatestPriceRobinhood(symbol);
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(null != price, "No Price from Robinhood");
|
|
|
|
|
Assert.IsTrue(price.IsValid || !double.IsNaN(price.PrevClose), "The feed is not working.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void DailyPricesYahoo()
|
|
|
|
|
{
|
|
|
|
|
String symbol = "AAPL";
|
|
|
|
|
DateGenerator dateGenerator = new DateGenerator();
|
|
|
|
|
DateTime lastBusinessDate = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
lastBusinessDate = dateGenerator.GetPrevBusinessDay(lastBusinessDate);
|
|
|
|
|
|
|
|
|
|
DateTime startDate = lastBusinessDate;
|
|
|
|
|
DateTime endDate = startDate;
|
|
|
|
|
|
|
|
|
|
Prices prices = MarketDataHelper.GetDailyPrices(symbol, startDate, endDate);
|
|
|
|
|
Assert.IsTrue(null != prices, "No Price from DailyPricesYahoo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void CNNPredictionTest()
|
|
|
|
|
{
|
|
|
|
|
@@ -70,6 +153,13 @@ public class MarketDataUnitTestClass
|
|
|
|
|
Assert.IsTrue(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void PremarketRetrieval()
|
|
|
|
|
{
|
|
|
|
|
PremarketElements premarketElements = MarketDataHelper.GetPremarketData();
|
|
|
|
|
Assert.IsTrue(null != premarketElements && premarketElements.Count > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void ETFHoldingsYahooRetrieval()
|
|
|
|
|
{
|
|
|
|
|
@@ -91,53 +181,6 @@ public class MarketDataUnitTestClass
|
|
|
|
|
Assert.IsTrue(result, String.Format("{0} items failed.", etfSymbols.Length));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void LatestPriceRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol = "AAPL";
|
|
|
|
|
Price price = MarketDataHelper.GetLatestPrice(symbol);
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(null != price && price.IsValid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void LatestPriceGoogleRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol = "AAPL";
|
|
|
|
|
Price price = MarketDataHelper.GetLatestPriceGoogle(symbol);
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(null != price && price.IsValid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The GetLatestPriceYahoo feed may return a price that only contains the previous close.
|
|
|
|
|
// This can happen after market hours and does not mean that the feed is broken.
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void LatestPriceYahooRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol = "JFNNX";
|
|
|
|
|
Price price = MarketDataHelper.GetLatestPriceYahoo(symbol);
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(null != price, "No Price from Yahoo");
|
|
|
|
|
Assert.IsTrue(price.IsValid || !double.IsNaN(price.PrevClose), "The feed is not working.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void DailyPricesYahoo()
|
|
|
|
|
{
|
|
|
|
|
String symbol = "AAPL";
|
|
|
|
|
DateGenerator dateGenerator = new DateGenerator();
|
|
|
|
|
DateTime lastBusinessDate = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
lastBusinessDate = dateGenerator.GetPrevBusinessDay(lastBusinessDate);
|
|
|
|
|
|
|
|
|
|
DateTime startDate = lastBusinessDate;
|
|
|
|
|
DateTime endDate = startDate;
|
|
|
|
|
|
|
|
|
|
Prices prices = MarketDataHelper.GetDailyPrices(symbol, startDate, endDate);
|
|
|
|
|
Assert.IsTrue(null != prices, "No Price from DailyPricesYahoo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void ConsumerPriceIndexBureauOfLaborStatisticsRetrieval()
|
|
|
|
|
{
|
|
|
|
|
@@ -198,19 +241,12 @@ public class MarketDataUnitTestClass
|
|
|
|
|
(null != dividendHistory3 && dividendHistory3.Count > 0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void PremarketRetrieval()
|
|
|
|
|
{
|
|
|
|
|
PremarketElements premarketElements = MarketDataHelper.GetPremarketData();
|
|
|
|
|
Assert.IsTrue(null != premarketElements && premarketElements.Count > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void EarningsAnnouncementsaRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol="MIDD";
|
|
|
|
|
EarningsAnnouncements earningsAnnouncements=MarketDataHelper.GetEarningsAnnouncements(symbol);
|
|
|
|
|
Assert.IsTrue(null!=earningsAnnouncements && earningsAnnouncements.Count>0);
|
|
|
|
|
String symbol = "MIDD";
|
|
|
|
|
EarningsAnnouncements earningsAnnouncements = MarketDataHelper.GetEarningsAnnouncements(symbol);
|
|
|
|
|
Assert.IsTrue(null != earningsAnnouncements && earningsAnnouncements.Count > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
@@ -224,8 +260,8 @@ public class MarketDataUnitTestClass
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void GetSplitsRetrieval()
|
|
|
|
|
{
|
|
|
|
|
Splits splits=MarketDataHelper.GetSplits();
|
|
|
|
|
Assert.IsTrue(null!=splits && splits.Count>0);
|
|
|
|
|
Splits splits = MarketDataHelper.GetSplits();
|
|
|
|
|
Assert.IsTrue(null != splits && splits.Count > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
@@ -238,11 +274,15 @@ public class MarketDataUnitTestClass
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void LatestAnalystRatingsRetrieval()
|
|
|
|
|
{
|
|
|
|
|
AnalystRatings analystRatings=MarketDataHelper.GetLatestAnalystRatings();
|
|
|
|
|
Assert.IsTrue(null!=analystRatings && analystRatings.Count>0);
|
|
|
|
|
AnalystRatings analystRatings = MarketDataHelper.GetLatestAnalystRatings();
|
|
|
|
|
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";
|
|
|
|
|
@@ -253,29 +293,29 @@ public class MarketDataUnitTestClass
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void SECCIKRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol="AAPL";
|
|
|
|
|
String strCik=MarketDataHelper.GetCIK(symbol);
|
|
|
|
|
Assert.IsTrue(null!=strCik);
|
|
|
|
|
String symbol = "AAPL";
|
|
|
|
|
String strCik = MarketDataHelper.GetCIK(symbol);
|
|
|
|
|
Assert.IsTrue(null != strCik);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void SECFilingsRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol="AAPL";
|
|
|
|
|
String strCik=MarketDataHelper.GetCIK(symbol);
|
|
|
|
|
Assert.IsTrue(null!=strCik);
|
|
|
|
|
SECFilings secFilings=MarketDataHelper.GetSECFilings(symbol,strCik,1);
|
|
|
|
|
Assert.IsTrue(null!=secFilings && secFilings.Count>0);
|
|
|
|
|
String symbol = "AAPL";
|
|
|
|
|
String strCik = MarketDataHelper.GetCIK(symbol);
|
|
|
|
|
Assert.IsTrue(null != strCik);
|
|
|
|
|
SECFilings secFilings = MarketDataHelper.GetSECFilings(symbol, strCik, 1);
|
|
|
|
|
Assert.IsTrue(null != secFilings && secFilings.Count > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void YieldCurveRetrieval()
|
|
|
|
|
{
|
|
|
|
|
DateGenerator dateGenerator= new DateGenerator();
|
|
|
|
|
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));
|
|
|
|
|
DateGenerator dateGenerator = new DateGenerator();
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
@@ -284,52 +324,60 @@ public class MarketDataUnitTestClass
|
|
|
|
|
DateTime now = DateTime.Now;
|
|
|
|
|
DateGenerator dateGenerator = new DateGenerator();
|
|
|
|
|
InsiderTransactions insiderTransactions = InsiderTransactionDA.GetLatestInsiderTransactions();
|
|
|
|
|
Assert.IsTrue(null!=insiderTransactions && insiderTransactions.Count>0);
|
|
|
|
|
Assert.IsTrue(null != insiderTransactions && insiderTransactions.Count > 0);
|
|
|
|
|
InsiderTransaction insiderTransaction = insiderTransactions[0];
|
|
|
|
|
int daysBetween = dateGenerator.DaysBetween(now, insiderTransaction.TransactionDate)+1;
|
|
|
|
|
Assert.IsTrue(daysBetween<10);
|
|
|
|
|
InsiderTransactions latestTransactions=MarketDataHelper.GetInsiderTransactions(insiderTransaction.Symbol,daysBetween);
|
|
|
|
|
Assert.IsTrue(null!=latestTransactions && latestTransactions.Count>0);
|
|
|
|
|
int daysBetween = dateGenerator.DaysBetween(now, insiderTransaction.TransactionDate) + 1;
|
|
|
|
|
Assert.IsTrue(daysBetween < 10);
|
|
|
|
|
InsiderTransactions latestTransactions = MarketDataHelper.GetInsiderTransactions(insiderTransaction.Symbol, daysBetween);
|
|
|
|
|
Assert.IsTrue(null != latestTransactions && latestTransactions.Count > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void CompanyProfileRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol="MOD";
|
|
|
|
|
CompanyProfile companyProfile=MarketDataHelper.GetCompanyProfile(symbol);
|
|
|
|
|
Assert.IsTrue(null!=companyProfile);
|
|
|
|
|
String symbol = "MOD";
|
|
|
|
|
CompanyProfile companyProfile = MarketDataHelper.GetCompanyProfile(symbol);
|
|
|
|
|
Assert.IsTrue(null != companyProfile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test all feeds
|
|
|
|
|
// Test all feeds
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void HeadlinesRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol="AAPL";
|
|
|
|
|
String symbol = "AAPL";
|
|
|
|
|
Headlines companyHeadlines = HeadlinesMarketDataHelper.GetHeadlinesEx(symbol);
|
|
|
|
|
Assert.IsTrue(null!=companyHeadlines && companyHeadlines.Count>0);
|
|
|
|
|
Assert.IsTrue(null != companyHeadlines && companyHeadlines.Count > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test MarketWatch feed
|
|
|
|
|
// https://www.marketwatch.com/investing/stock/AAPL?mod=search_symbol
|
|
|
|
|
// 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";
|
|
|
|
|
String symbol = "MIDD";
|
|
|
|
|
Headlines companyHeadlines = MarketDataHelper.GetCompanyHeadlinesMarketWatch(symbol);
|
|
|
|
|
Assert.IsTrue(null!=companyHeadlines && companyHeadlines.Count>0);
|
|
|
|
|
Assert.IsTrue(null != companyHeadlines && companyHeadlines.Count > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test NASDAQ Headlines feed
|
|
|
|
|
// Test NASDAQ Headlines feed
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void HeadlinesNASDAQRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol="AAPL";
|
|
|
|
|
String symbol = "AAPL";
|
|
|
|
|
Headlines companyHeadlines = MarketDataHelper.GetCompanyHeadlinesNASDAQ(symbol);
|
|
|
|
|
Assert.IsTrue(null!=companyHeadlines && companyHeadlines.Count>0);
|
|
|
|
|
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";
|
|
|
|
|
@@ -337,103 +385,113 @@ public class MarketDataUnitTestClass
|
|
|
|
|
Assert.IsTrue(null != companyHeadlines && companyHeadlines.Count > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// SeekingAlpha feed is not working
|
|
|
|
|
/// </summary>
|
|
|
|
|
[TestMethod]
|
|
|
|
|
[Ignore]
|
|
|
|
|
public void HeadlinesSeekingAlphaV3Retrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol="MIDD";
|
|
|
|
|
String symbol = "MIDD";
|
|
|
|
|
Headlines companyHeadlines = MarketDataHelper.GetCompanyHeadlinesSeekingAlphaV3(symbol, true);
|
|
|
|
|
Assert.IsTrue(null!=companyHeadlines && companyHeadlines.Count>0);
|
|
|
|
|
Assert.IsTrue(null != companyHeadlines && companyHeadlines.Count > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void AnalystPriceTargetMarketBeatRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol="MGPI";
|
|
|
|
|
AnalystPriceTarget analystPriceTarget=MarketDataHelper.GetAnalystPriceTargetMarketBeat(symbol);
|
|
|
|
|
Assert.IsTrue(null!=analystPriceTarget);
|
|
|
|
|
String symbol = "MGPI";
|
|
|
|
|
AnalystPriceTarget analystPriceTarget = MarketDataHelper.GetAnalystPriceTargetMarketBeat(symbol);
|
|
|
|
|
Assert.IsTrue(null != analystPriceTarget);
|
|
|
|
|
Assert.IsTrue(!Double.IsNaN(analystPriceTarget.HighTargetPrice));
|
|
|
|
|
Assert.IsTrue(!Double.IsNaN(analystPriceTarget.LowTargetPrice));
|
|
|
|
|
Assert.IsTrue(!Double.IsNaN(analystPriceTarget.MeanTargetPrice));
|
|
|
|
|
Assert.IsTrue(!Double.IsNaN(analystPriceTarget.MedianTargetPrice));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Need to figure out why this is not working
|
|
|
|
|
/// </summary>
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void HistoricalRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol="AAPL";
|
|
|
|
|
Dictionary<TimeSeriesElement.ElementType, TimeSeriesCollection> timeSeries=MarketDataHelper.GetHistoricalValues(symbol);
|
|
|
|
|
Assert.IsTrue(null!=timeSeries);
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.ROA),"Missing ROA");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.ROIC),"Missing ROIC");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.BVPS),"Missing BVPS");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.Inventory),"Missing Inventory");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.AccountsReceivable),"Missing AccountsReceivable");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.COGS),"Missing COGS");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.OperatingIncome),"Missing OperatingIncome");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.InterestExpense),"Missing InterestExpense");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.TaxRate),"Missing TaxRate");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.Revenue),"Missing Revenue");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.NetIncomeAvailableToCommonShareholders),"Missing NetIncomeAvailableToCommonShareholders");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.OperatingCashflow),"Missing OperatingCashflow");
|
|
|
|
|
String symbol = "AAPL";
|
|
|
|
|
Dictionary<TimeSeriesElement.ElementType, TimeSeriesCollection> timeSeries = MarketDataHelper.GetHistoricalValues(symbol);
|
|
|
|
|
Assert.IsTrue(null != timeSeries);
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.ROA), "Missing ROA");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.ROIC), "Missing ROIC");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.BVPS), "Missing BVPS");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.Inventory), "Missing Inventory");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.AccountsReceivable), "Missing AccountsReceivable");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.COGS), "Missing COGS");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.OperatingIncome), "Missing OperatingIncome");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.InterestExpense), "Missing InterestExpense");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.TaxRate), "Missing TaxRate");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.Revenue), "Missing Revenue");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.NetIncomeAvailableToCommonShareholders), "Missing NetIncomeAvailableToCommonShareholders");
|
|
|
|
|
Assert.IsTrue(timeSeries.ContainsKey(TimeSeriesElement.ElementType.OperatingCashflow), "Missing OperatingCashflow");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void IncomeStatementNASDAQRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol="MIDD";
|
|
|
|
|
List<IncomeStatement> incomeStatements=MarketDataHelper.GetIncomeStatementNASDAQ(symbol,IncomeStatement.PeriodType.Annual);
|
|
|
|
|
Assert.IsTrue(null!=incomeStatements && incomeStatements.Count>0);
|
|
|
|
|
String symbol = "MIDD";
|
|
|
|
|
List<IncomeStatement> incomeStatements = MarketDataHelper.GetIncomeStatementNASDAQ(symbol, IncomeStatement.PeriodType.Annual);
|
|
|
|
|
Assert.IsTrue(null != incomeStatements && incomeStatements.Count > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void IncomeStatementFinVizRetrievsl()
|
|
|
|
|
public void IncomeStatementFinVizRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol="MIDD";
|
|
|
|
|
List<IncomeStatement> incomeStatements=MarketDataHelper.GetIncomeStatementFinViz(symbol,IncomeStatement.PeriodType.Annual);
|
|
|
|
|
Assert.IsTrue(null!=incomeStatements && incomeStatements.Count>0);
|
|
|
|
|
String symbol = "MIDD";
|
|
|
|
|
List<IncomeStatement> incomeStatements = MarketDataHelper.GetIncomeStatementFinViz(symbol, IncomeStatement.PeriodType.Annual);
|
|
|
|
|
Assert.IsTrue(null != incomeStatements && incomeStatements.Count > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void BalanceSheetNASDAQRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol="MIDD";
|
|
|
|
|
String symbol = "MIDD";
|
|
|
|
|
List<BalanceSheet> balanceSheets = MarketDataHelper.GetBalanceSheetNASDAQ(symbol, BalanceSheet.PeriodType.Annual);
|
|
|
|
|
Assert.IsTrue(null != balanceSheets && balanceSheets.Count > 0);
|
|
|
|
|
BalanceSheet balanceSheet = balanceSheets[0];
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.CashAndCashEquivalents),"CashAndCashEquivalents");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.DeferredLongTermLiabilities),"DeferredLongTermLiabilities");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.IntangibleAssets),"IntangibleAssets");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.Inventory),"Inventory");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.LongTermDebt),"LongTermDebt");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.NetCurrentAssetValue),"NetCurrentAssetValue");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.NetFixedAssets),"NetFixedAssets");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.OtherLiabilities),"OtherLiabilities");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.PropertyPlantAndEquipment),"PropertyPlantAndEquipment");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.TotalAssets),"TotalAssets");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.TotalCurrentAssets),"TotalCurrentAssets");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.TotalCurrentLiabilities),"TotalCurrentLiabilities");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.TotalLiabilities),"TotalLiabilities");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.CashAndCashEquivalents), "CashAndCashEquivalents");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.DeferredLongTermLiabilities), "DeferredLongTermLiabilities");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.IntangibleAssets), "IntangibleAssets");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.Inventory), "Inventory");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.LongTermDebt), "LongTermDebt");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.NetCurrentAssetValue), "NetCurrentAssetValue");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.NetFixedAssets), "NetFixedAssets");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.OtherLiabilities), "OtherLiabilities");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.PropertyPlantAndEquipment), "PropertyPlantAndEquipment");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.TotalAssets), "TotalAssets");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.TotalCurrentAssets), "TotalCurrentAssets");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(balanceSheet.TotalCurrentLiabilities), "TotalCurrentLiabilities");
|
|
|
|
|
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"};
|
|
|
|
|
String[] symbols = { "AZEK", "CPRT", "DOCU", "ESTC", "HLNE" };
|
|
|
|
|
|
|
|
|
|
Dictionary<String,List<CashflowStatement>> cashflowStatementsDict = new Dictionary<String,List<CashflowStatement>>();
|
|
|
|
|
Dictionary<String, List<CashflowStatement>> cashflowStatementsDict = new Dictionary<String, List<CashflowStatement>>();
|
|
|
|
|
|
|
|
|
|
foreach(String symbol in symbols)
|
|
|
|
|
foreach (String symbol in symbols)
|
|
|
|
|
{
|
|
|
|
|
List<CashflowStatement> cashflowStatements = MarketDataHelper.GetCashflowStatement(symbol, CashflowStatement.PeriodType.Annual);
|
|
|
|
|
if(null == cashflowStatements)continue;
|
|
|
|
|
if (null == cashflowStatements) continue;
|
|
|
|
|
cashflowStatementsDict.Add(symbol, cashflowStatements);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue(cashflowStatementsDict.Count!=0,"Error retrieving cashflow statements.");
|
|
|
|
|
Assert.IsTrue(cashflowStatementsDict.Count != 0, "Error retrieving cashflow statements.");
|
|
|
|
|
|
|
|
|
|
List<String> keys = cashflowStatementsDict.Keys.ToList();
|
|
|
|
|
|
|
|
|
|
foreach(String key in keys)
|
|
|
|
|
foreach (String key in keys)
|
|
|
|
|
{
|
|
|
|
|
List<CashflowStatement> cashflowStatements = cashflowStatementsDict[key];
|
|
|
|
|
CashflowStatement cashflowStatement = cashflowStatements[0];
|
|
|
|
|
@@ -454,58 +512,51 @@ public class MarketDataUnitTestClass
|
|
|
|
|
public void CurrencyConversionXERetrieval()
|
|
|
|
|
{
|
|
|
|
|
DateGenerator dateGenerator = new DateGenerator();
|
|
|
|
|
String sourceCurrency="USD";
|
|
|
|
|
String sourceCurrency = "USD";
|
|
|
|
|
DateTime analysisDate = DateTime.Now;
|
|
|
|
|
analysisDate = dateGenerator.FindPrevBusinessDay(analysisDate);
|
|
|
|
|
CurrencyConversionCollection currencyConversionCollection = MarketDataHelper.GetCurrencyConversion(sourceCurrency,analysisDate);
|
|
|
|
|
Assert.IsTrue(null!=currencyConversionCollection && currencyConversionCollection.Count>0);
|
|
|
|
|
CurrencyConversionCollection currencyConversionCollection = MarketDataHelper.GetCurrencyConversion(sourceCurrency, analysisDate);
|
|
|
|
|
Assert.IsTrue(null != currencyConversionCollection && currencyConversionCollection.Count > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Need to figure out why we are missing EBITDA, OperatingCashflow, LeveragedFreeCashflow
|
|
|
|
|
///
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void FundamentalFinVizRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol = "MIDD";
|
|
|
|
|
Fundamental fundamental=MarketDataHelper.GetFundamentalFinViz(symbol);
|
|
|
|
|
Assert.IsTrue(null!=fundamental);
|
|
|
|
|
Assert.IsTrue(!Utility.IsEpoch(fundamental.NextEarningsDate),"NextEarningsDate");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.Beta),"Beta");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.Low52),"Low52");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.High52),"High52");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.Volume),"Volume");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.MarketCap),"MarketCap");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.PE),"PE");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.EPS),"EPS");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.PEG),"PEG");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.ReturnOnAssets),"ReturnOnAssets");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.ReturnOnEquity),"ReturnOnEquity");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.TotalCash),"TotalCash");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.TotalDebt),"TotalDebt");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.SharesOutstanding),"SharesOutstanding");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.Revenue),"Revenue");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.RevenuePerShare),"RevenuePerShare");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.QtrlyRevenueGrowth),"QtrlyRevenueGrowth");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.GrossProfit),"GrossProfit");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.EBITDA),"EBITDA");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.NetIncomeAvailableToCommon),"NetIncomeAvailableToCommon");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.BookValuePerShare),"BookValuePerShare");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.OperatingCashflow),"OperatingCashflow");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.LeveragedFreeCashflow),"LeveragedFreeCashflow");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.Equity),"Equity");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.TrailingPE),"TrailingPE");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.EnterpriseValue),"EnterpriseValue");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.EBIT),"EBIT");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.DebtToEquity),"DebtToEquity");
|
|
|
|
|
Fundamental fundamental = MarketDataHelper.GetFundamentalFinViz(symbol);
|
|
|
|
|
Assert.IsTrue(null != fundamental);
|
|
|
|
|
Assert.IsTrue(!Utility.IsEpoch(fundamental.NextEarningsDate), "NextEarningsDate");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.Beta), "Beta");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.Low52), "Low52");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.High52), "High52");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.Volume), "Volume");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.MarketCap), "MarketCap");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.PE), "PE");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.EPS), "EPS");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.PEG), "PEG");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.ReturnOnAssets), "ReturnOnAssets");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.ReturnOnEquity), "ReturnOnEquity");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.TotalCash), "TotalCash");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.TotalDebt), "TotalDebt");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.SharesOutstanding), "SharesOutstanding");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.Revenue), "Revenue");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.RevenuePerShare), "RevenuePerShare");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.QtrlyRevenueGrowth), "QtrlyRevenueGrowth");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.GrossProfit), "GrossProfit");
|
|
|
|
|
// Assert.IsTrue(!double.IsNaN(fundamental.EBITDA), "EBITDA");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.NetIncomeAvailableToCommon), "NetIncomeAvailableToCommon");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.BookValuePerShare), "BookValuePerShare");
|
|
|
|
|
// Assert.IsTrue(!double.IsNaN(fundamental.OperatingCashflow), "OperatingCashflow");
|
|
|
|
|
// Assert.IsTrue(!double.IsNaN(fundamental.LeveragedFreeCashflow), "LeveragedFreeCashflow");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.Equity), "Equity");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.TrailingPE), "TrailingPE");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.EnterpriseValue), "EnterpriseValue");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.EBIT), "EBIT");
|
|
|
|
|
Assert.IsTrue(!double.IsNaN(fundamental.DebtToEquity), "DebtToEquity");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void GetDailyPricesYahooRetrieval()
|
|
|
|
|
{
|
|
|
|
|
String symbol="MIDD";
|
|
|
|
|
DateTime analysisDate=DateTime.Now;
|
|
|
|
|
DateGenerator dateGenerator = new DateGenerator();
|
|
|
|
|
analysisDate=dateGenerator.FindPrevBusinessDay(analysisDate);
|
|
|
|
|
Prices prices=MarketDataHelper.GetDailyPrices(symbol,analysisDate,analysisDate);
|
|
|
|
|
Assert.IsTrue(null!=prices && prices.Count>0,"No Price");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|