Fixed problem with MG and CMM when running EOM on a weekend. The Trade date and Analysis date have been corrected to reflect the previous business day. Monthly updates.

This commit is contained in:
2025-05-31 11:58:48 -04:00
parent 7061395694
commit bbbaff3095
11 changed files with 461 additions and 441 deletions

View File

@@ -211,6 +211,7 @@ namespace MarketData.DataAccess
try
{
if (null == symbols || 0 == symbols.Count) return analystRatings;
StringBuilder sb = new StringBuilder();
sqlConnection = SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("market_data"));
sb.Append("SELECT B.date, B.symbol,B.company, B.brokerage_firm, B.type, B.ratings_change, B.price_target from ");

View File

@@ -79,6 +79,7 @@ namespace MarketData.DataAccess
try
{
if (null == symbols || 0 == symbols.Count) return companyProfiles;
StringBuilder sb = new StringBuilder();
sqlConnection = SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("market_data"));
sb.Append("select sm.symbol,sm.sector,sm.industry,sm.security_type,sm.company,cp.description,cp.pricing_source,cp.can_roll_previous,cp.freeze_pricing from securitymaster sm left outer join companyprofile cp on sm.symbol=cp.symbol").Append(" ");
@@ -106,6 +107,10 @@ namespace MarketData.DataAccess
catch (Exception exception)
{
MDTrace.WriteLine(LogLevel.DEBUG,exception);
if (null != strQuery)
{
MDTrace.WriteLine(LogLevel.DEBUG, $"Query was '{strQuery}'");
}
return null;
}
finally

View File

@@ -25,7 +25,7 @@ namespace MarketData.DataAccess
try
{
if (null == symbols || 0 == symbols.Count) return zacksRanks;
StringBuilder sb = new StringBuilder();
sqlConnection = SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("market_data"));
sb.Append("SELECT B.symbol, B.zacks_rank, B.date, B.type ");

View File

@@ -331,8 +331,9 @@ namespace MarketData.Generator.CMMomentum
CMSessionParams sessionParams = null;
Cycle = 0;
if (Utility.IsEpoch(AnalysisDate)) AnalysisDate = dateGenerator.GetPrevBusinessDay(Today());
else AnalysisDate = dateGenerator.GetPrevBusinessDay(AnalysisDate);
if (AnalysisDate.Date > Today().Date) return backTestResult;
if (Utility.IsEpoch(AnalysisDate)) AnalysisDate = Today();
TradeDate = dateGenerator.GetCurrentMonthEnd(StartDate);
if (TradeDate > AnalysisDate)
{

View File

@@ -333,8 +333,8 @@ namespace MarketData.Generator.Momentum
Cycle=0;
if(AnalysisDate.Date>Today().Date)return backTestResult;
if(Utility.IsEpoch(AnalysisDate))AnalysisDate=Today();
TradeDate=dateGenerator.GetCurrentMonthEnd(StartDate);
if(Utility.IsEpoch(AnalysisDate))AnalysisDate=dateGenerator.GetPrevBusinessDay(Today()); // Ensure AnalysisDate is not a weekend or holiday
TradeDate =dateGenerator.GetCurrentMonthEnd(StartDate);
if(TradeDate>AnalysisDate)
{
int startMonth=StartDate.Month;
@@ -662,7 +662,7 @@ namespace MarketData.Generator.Momentum
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Restoring session from '{0}'",PathSessionFileName));
MGSessionParams sessionParams=MGSessionManager.RestoreSession(PathSessionFileName);
TradeDate=sessionParams.TradeDate;
if(TradeDate.Date<AnalysisDate.Date)TradeDate=AnalysisDate;
if(TradeDate.Date<AnalysisDate.Date)TradeDate=AnalysisDate; // AnalysisDate will not fall on a weekend or holiday
StartDate=sessionParams.StartDate;
Configuration=sessionParams.Configuration;
ActivePositions=sessionParams.ActivePositions;