Code enhancements

This commit is contained in:
2025-03-27 18:55:13 -04:00
parent c7ef8a04c9
commit 6504f1d2c2
2 changed files with 14 additions and 23 deletions

2
.gitignore vendored
View File

@@ -153,3 +153,5 @@ MarketData/MarketDataLib/obj/project.assets.json
MarketData/MarketDataLib/obj/project.nuget.cache
MarketData/MarketData/*.log
MarketData/MarketData/marketdata.log
MarketData/MarketData/logs/marketdata_echo.log
MarketData/MarketData/logs/marketdata_loadheadlineswatchlist.log

View File

@@ -44,7 +44,7 @@ namespace MarketData.Services
}
string arg = args[0].ToUpper();
CreateLogging(arg); // log files are now of the form market_data+task.log. Also log files will expire daily
MDTrace.WriteLine(LogLevel.DEBUG,$"[RunService] Started @ {Utility.DateTimeToStringYYYYHMMHDDHHMMSSTT(currentDate)}");
@@ -189,25 +189,13 @@ namespace MarketData.Services
// Sanity check. If the given date is not today then ask the user to confirm
if (currentDate != startDate.Date)
{
Console.WriteLine(String.Format("Run date is not today, please confirm Y/N:{0}?",startDate.ToShortDateString()));
String result=Console.ReadLine();
if(null==result||!(result.ToUpper().Equals("Y")||result.ToUpper().Equals("YES")))return;
MDTrace.WriteLine(LogLevel.DEBUG,$"Run date is not today: Current Date:{currentDate.ToShortDateString()} Run Date: {startDate.ToShortDateString()}");
return;
}
if(!dateGenerator.IsMarketOpen(currentDate))
if(!CheckRunCriteria())
{
String description="";
if(HolidayDA.IsMarketHoliday(currentDate)) description=HolidayDA.GetHolidayDescription(currentDate);
else description=Utility.DayOfWeekToString(currentDate.DayOfWeek);
Console.WriteLine(String.Format("Market is closed today ({0}), please confirm Y/N:{1}?",description,startDate.ToShortDateString()));
String result=Console.ReadLine();
if(null==result||!(result.ToUpper().Equals("Y")||result.ToUpper().Equals("YES"))) return;
return;
}
if(!NetworkStatus.IsInternetConnected())
{
Console.WriteLine(String.Format("The internet is not connected, continue anyway Y/N:?"));
String result=Console.ReadLine();
if(null==result||!(result.ToUpper().Equals("Y")||result.ToUpper().Equals("YES")))return;
}
MDTrace.WriteLine(LogLevel.DEBUG,$"UPDATEDAILY2 DATE:{startDate.ToShortDateString()}");
int STAGE_1=0,STAGE_2=1,STAGE_3=2,STAGE_4=3,STAGE_5=4,STAGE_6=5,STAGE_7=6,STAGE_8=7,STAGE_9=8,STAGE_10=9,STAGE_11=10,STAGE_12=11,STAGE_FINAL=12;
DeletePriceWatchList("valuations",startDate.ToShortDateString());
@@ -460,6 +448,7 @@ namespace MarketData.Services
{
try
{
if(!CheckRunCriteria())return;
DateGenerator dateGenerator = new DateGenerator();
MDTrace.WriteLine(LogLevel.DEBUG, "[UPDATELATESTANALYSTRATINGS]");
AnalystRatings analystRatings = MarketDataHelper.GetLatestAnalystRatings();
@@ -626,6 +615,7 @@ namespace MarketData.Services
{
try
{
if(!CheckRunCriteria())return;
MDTrace.WriteLine(LogLevel.DEBUG, "[UPDATEANALYSTRATINGS]");
List<String> symbols = new List<String>();
if (paramSymbol == null) symbols = PricingDA.GetSymbols();
@@ -750,16 +740,15 @@ namespace MarketData.Services
String description="";
if(HolidayDA.IsMarketHoliday(currentDate)) description=HolidayDA.GetHolidayDescription(currentDate);
else description=Utility.DayOfWeekToString(currentDate.DayOfWeek);
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Market is closed today {0} ({1}), please confirm Y/N:?",currentDate.ToShortDateString(),description));
MDTrace.WriteLine(LogLevel.DEBUG,$"Market is closed today {currentDate.ToShortDateString()} for {description}.");
return false;
}
if(!NetworkStatus.IsInternetConnected())
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("The internet is not connected."));
if(!NetworkStatus.IsInternetConnected())
{
MDTrace.WriteLine(LogLevel.DEBUG,$"The internet is not connected.");
return false;
}
}
return true;
}
}
}