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

@@ -52,7 +52,11 @@ namespace MarketData.Helper
{
public static int DEFAULT_TIMEOUT_MS=30000;
public static String SEC_BASE_URL="https://www.sec.gov";
public static String SAL_VERSION="4.71.0"; // This is for morningstar and may have to be changed periodically until I find a way to get automatically
private MarketDataHelper()
{
}
public static bool GetWorldTime()
{
@@ -2127,8 +2131,7 @@ namespace MarketData.Helper
String nasdaq = "xnas";
String nyse = "xnyse";
String nys="xnys";
String salVersion="4.30.0";
String salVerson45100="4.51.0";
String strDefinition = default;
String strColumnDefinition = default;
int TIMEOUT_BETWEEN_REQUESTS_MS=500;
@@ -2182,7 +2185,7 @@ namespace MarketData.Helper
// PROFITABILITY AND EFFICIENCY - SOURCES ROA AND ROIC
sb=new StringBuilder();
sb.Append("https://api-global.morningstar.com/sal-service/v1/stock/keyMetrics/profitabilityAndEfficiency/").Append(securityId).Append("?languageId=en&locale=en&clientId=MDC&component=sal-eqsv-key-metrics-profitability-efficiency&version=").Append(salVerson45100);
sb.Append("https://api-global.morningstar.com/sal-service/v1/stock/keyMetrics/profitabilityAndEfficiency/").Append(securityId).Append("?languageId=en&locale=en&clientId=MDC&component=sal-eqsv-key-metrics-profitability-efficiency&version=").Append(SAL_VERSION);
strRequest=sb.ToString();
MDTrace.WriteLine(LogLevel.DEBUG,strRequest);
try{Thread.Sleep(TIMEOUT_BETWEEN_REQUESTS_MS);}catch{;}
@@ -2190,6 +2193,7 @@ namespace MarketData.Helper
if(!httpNetResponse.Success || String.IsNullOrEmpty(httpNetResponse.ResponseString))
{
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("[GetHistoricalValues::OperatingPerformance] Request:{0} failed with status {1}", httpNetResponse.Request, httpNetResponse.StatusCode));
MDTrace.WriteLine(LogLevel.DEBUG,$"**** CHECK MORNINGSTAR SALVERSION = {SAL_VERSION} *****");
return null;
}
List<List<String>> profitabilityItems=LocateJSONItems(httpNetResponse.ResponseString);
@@ -2198,7 +2202,7 @@ namespace MarketData.Helper
// KETSTATS - FINANCIALHEALTH
sb=new StringBuilder();
sb.Append("https://api-global.morningstar.com/sal-service/v1/stock/keyStats/financialHealth/").Append(securityId).Append("?languageId=en&locale=en&clientId=MDC&component=sal-components-key-stats-financial-health&version=").Append(salVersion);
sb.Append("https://api-global.morningstar.com/sal-service/v1/stock/keyStats/financialHealth/").Append(securityId).Append("?languageId=en&locale=en&clientId=MDC&component=sal-components-key-stats-financial-health&version=").Append(SAL_VERSION);
strRequest=sb.ToString();
MDTrace.WriteLine(LogLevel.DEBUG,strRequest);
try{Thread.Sleep(TIMEOUT_BETWEEN_REQUESTS_MS);}catch{;}
@@ -2206,6 +2210,7 @@ namespace MarketData.Helper
if(!httpNetResponse.Success || String.IsNullOrEmpty(httpNetResponse.ResponseString))
{
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("[GetHistoricalValues::FinancialHeath] Request:{0} failed with status {1}", httpNetResponse.Request, httpNetResponse.StatusCode));
MDTrace.WriteLine(LogLevel.DEBUG,$"**** CHECK MORNINGSTAR SALVERSION = {SAL_VERSION} *****");
return null;
}
List<List<String>> items=LocateJSONItems(httpNetResponse.ResponseString);
@@ -2214,7 +2219,7 @@ namespace MarketData.Helper
// NEWFINANCIALS - ANNUAL/SUMMARY
sb=new StringBuilder();
sb.Append("https://api-global.morningstar.com/sal-service/v1/stock/newfinancials/").Append(securityId).Append("/annual/summary?reportType=A&languageId=en&locale=en&clientId=MDC&component=sal-components-equity-financials-summary&version=").Append(salVersion);
sb.Append("https://api-global.morningstar.com/sal-service/v1/stock/newfinancials/").Append(securityId).Append("/annual/summary?reportType=A&languageId=en&locale=en&clientId=MDC&component=sal-components-equity-financials-summary&version=").Append(SAL_VERSION);
strRequest=sb.ToString();
MDTrace.WriteLine(LogLevel.DEBUG,strRequest);
try{Thread.Sleep(TIMEOUT_BETWEEN_REQUESTS_MS);}catch{;}
@@ -2222,6 +2227,7 @@ namespace MarketData.Helper
if(!httpNetResponse.Success || String.IsNullOrEmpty(httpNetResponse.ResponseString))
{
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("[GetHistoricalValues::AnnualSummary] Request:{0} failed with status {1}", httpNetResponse.Request, httpNetResponse.StatusCode));
MDTrace.WriteLine(LogLevel.DEBUG,$"**** CHECK MORNINGSTAR SALVERSION = {SAL_VERSION} *****");
return null;
}
Dictionary<String,MStarDataSet> dataSetsAnnuals=GetData(httpNetResponse.ResponseString);
@@ -2229,7 +2235,7 @@ namespace MarketData.Helper
// NEWFINANCIALS - INCOMESTATEMENT
sb=new StringBuilder();
sb.Append("https://api-global.morningstar.com/sal-service/v1/stock/newfinancials/").Append(securityId).Append("/incomeStatement/detail?dataType=A&reportType=A&locale=en&languageId=en&locale=en&clientId=MDC&component=sal-components-equity-financials-details&version=").Append(salVersion);
sb.Append("https://api-global.morningstar.com/sal-service/v1/stock/newfinancials/").Append(securityId).Append("/incomeStatement/detail?dataType=A&reportType=A&locale=en&languageId=en&locale=en&clientId=MDC&component=sal-components-equity-financials-details&version=").Append(SAL_VERSION);
strRequest=sb.ToString();
MDTrace.WriteLine(LogLevel.DEBUG,strRequest);
try{Thread.Sleep(TIMEOUT_BETWEEN_REQUESTS_MS);}catch{;}
@@ -2237,6 +2243,7 @@ namespace MarketData.Helper
if(!httpNetResponse.Success || String.IsNullOrEmpty(httpNetResponse.ResponseString))
{
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("[GetHistoricalValues::IncomeStatement] Request:{0} failed with status {1}", httpNetResponse.Request, httpNetResponse.StatusCode));
MDTrace.WriteLine(LogLevel.DEBUG,$"**** CHECK MORNINGSTAR SALVERSION = {SAL_VERSION} *****");
return null;
}
Dictionary<String,MStarDataSet> dataSetsIncomeStatement=GetData(httpNetResponse.ResponseString);
@@ -2244,7 +2251,7 @@ namespace MarketData.Helper
// NEWFINANCIALS - CASHFLOW
sb=new StringBuilder();
sb.Append("https://api-global.morningstar.com/sal-service/v1/stock/newfinancials/").Append(securityId).Append("/cashFlow/detail?dataType=A&reportType=A&locale=en&languageId=en&locale=en&clientId=MDC&component=sal-components-equity-financials-details&version=").Append(salVersion);
sb.Append("https://api-global.morningstar.com/sal-service/v1/stock/newfinancials/").Append(securityId).Append("/cashFlow/detail?dataType=A&reportType=A&locale=en&languageId=en&locale=en&clientId=MDC&component=sal-components-equity-financials-details&version=").Append(SAL_VERSION);
strRequest=sb.ToString();
MDTrace.WriteLine(LogLevel.DEBUG,strRequest);
try{Thread.Sleep(TIMEOUT_BETWEEN_REQUESTS_MS);}catch{;}
@@ -2252,6 +2259,7 @@ namespace MarketData.Helper
if(!httpNetResponse.Success || String.IsNullOrEmpty(httpNetResponse.ResponseString))
{
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("[GetHistoricalValues::Cashflow] Request:{0} failed with status {1}", httpNetResponse.Request, httpNetResponse.StatusCode));
MDTrace.WriteLine(LogLevel.DEBUG,$"**** CHECK MORNINGSTAR SALVERSION = {SAL_VERSION} *****");
return null;
}
Dictionary<String,MStarDataSet> dataSetsCashflowStatement=GetData(httpNetResponse.ResponseString);
@@ -2259,7 +2267,7 @@ namespace MarketData.Helper
//NEWFINANCIALS - BALANCESHEET
sb=new StringBuilder();
sb.Append("https://api-global.morningstar.com/sal-service/v1/stock/newfinancials/").Append(securityId).Append("/balanceSheet/detail?dataType=A&reportType=A&locale=en&languageId=en&locale=en&clientId=MDC&component=sal-components-equity-financials-details&version=").Append(salVersion);
sb.Append("https://api-global.morningstar.com/sal-service/v1/stock/newfinancials/").Append(securityId).Append("/balanceSheet/detail?dataType=A&reportType=A&locale=en&languageId=en&locale=en&clientId=MDC&component=sal-components-equity-financials-details&version=").Append(SAL_VERSION);
strRequest=sb.ToString();
MDTrace.WriteLine(LogLevel.DEBUG,strRequest);
try{Thread.Sleep(TIMEOUT_BETWEEN_REQUESTS_MS);}catch{;}
@@ -2267,11 +2275,13 @@ namespace MarketData.Helper
if(!httpNetResponse.Success || String.IsNullOrEmpty(httpNetResponse.ResponseString))
{
MDTrace.WriteLine(LogLevel.DEBUG, String.Format("[GetHistoricalValues::BalanceSheet] Request:{0} failed with status {1}", httpNetResponse.Request, httpNetResponse.StatusCode));
MDTrace.WriteLine(LogLevel.DEBUG,$"**** CHECK MORNINGSTAR SALVERSION = {SAL_VERSION} *****");
return null;
}
Dictionary<String,MStarDataSet> dataSetsBalanceSheet=GetData(httpNetResponse.ResponseString);
httpNetResponse.Dispose();
// ASSEMBLE DATA SETS
// RETURN ON ASSETS
strDefinition="roa";
strColumnDefinition="columnDefs";
@@ -3014,7 +3024,9 @@ namespace MarketData.Helper
int waitBetweenAttemptsMS=500;
StringBuilder sb=new StringBuilder();
sb.Append("https://api-global.morningstar.com/sal-service/v1/stock/newfinancials/").Append(securityId).Append("/cashFlow/detail?dataType=A&reportType=A&locale=en&languageId=en&locale=en&clientId=MDC&component=sal-components-equity-financials-details&version=3.74.0");
sb.Append("https://api-global.morningstar.com/sal-service/v1/stock/newfinancials/").Append(securityId).Append("/cashFlow/detail?dataType=A&reportType=A&locale=en&languageId=en&locale=en&clientId=MDC&component=sal-components-equity-financials-details");
sb.Append("&version=").Append(SAL_VERSION);
String strRequest=sb.ToString();
try
{
@@ -3029,6 +3041,7 @@ namespace MarketData.Helper
retry++;
}
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Request failed : {0}",strRequest));
MDTrace.WriteLine(LogLevel.DEBUG,$"**** CHECK MORNINGSTAR SALVERSION = {SAL_VERSION} *****");
return httpNetResponse;
}
catch(Exception exception)