Additional changes for MGSH

This commit is contained in:
2025-04-08 22:27:47 -04:00
parent f4511419ba
commit 531fd61575
4 changed files with 29 additions and 15 deletions

View File

@@ -12,7 +12,7 @@ namespace MarketData
{
if(!commandArgs.Has("SESSIONFILE"))
{
MDTrace.WriteLine(LogLevel.DEBUG,"Missing SESSIONFILE");
MDTrace.WriteLine(LogLevel.DEBUG,ConsoleColor.Red,"Missing SESSIONFILE");
return;
}
MGSHMomentumBacktest momentumBacktest = new MGSHMomentumBacktest();
@@ -24,14 +24,14 @@ namespace MarketData
DateGenerator dateGenerator = new DateGenerator();
if(!commandArgs.Has("SESSIONFILE,TRADEDATE"))
{
MDTrace.WriteLine(LogLevel.DEBUG,"SESSIONFILE and TRADEDATE are required parameters.");
MDTrace.WriteLine(LogLevel.DEBUG,ConsoleColor.Red,"SESSIONFILE and TRADEDATE are required parameters.");
return;
}
DateTime tradeDate = commandArgs.Get<DateTime>("TRADEDATE");
if(!dateGenerator.IsMarketOpen(tradeDate))
{
MDTrace.WriteLine(LogLevel.DEBUG,$"TRADEDATE {tradeDate.ToShortDateString()} is not a trading date.");
MDTrace.WriteLine(LogLevel.DEBUG,ConsoleColor.Red,$"TRADEDATE {tradeDate.ToShortDateString()} is not a trading date.");
return;
}
@@ -41,7 +41,7 @@ namespace MarketData
pathSessionFile = pathSessionFile.Trim();
if(!File.Exists(pathSessionFile))
{
MDTrace.WriteLine(LogLevel.DEBUG,$"The specified file '{pathSessionFile}' does not exist.");
MDTrace.WriteLine(LogLevel.DEBUG,ConsoleColor.Red,$"The specified file '{pathSessionFile}' does not exist.");
return;
}
@@ -49,7 +49,7 @@ namespace MarketData
if(!dateGenerator.IsMarketOpen(tradeDate))
{
Console.WriteLine(String.Format("The market is closed today, please confirm Y/N:{0}?",tradeDate.ToShortDateString()));
MDTrace.WriteLine(LogLevel.DEBUG,ConsoleColor.Red,String.Format("The market is closed today, please confirm Y/N:{0}?",tradeDate.ToShortDateString()));
String result=Console.ReadLine();
if(null==result||!(result.ToUpper().Equals("Y")||result.ToUpper().Equals("YES")))return;
}
@@ -62,10 +62,10 @@ namespace MarketData
MGSHConfiguration mgParams=new MGSHConfiguration();
if (!commandArgs.Has("STARTDATE,MAXPOSITIONS,INITIALCASH,HOLDINGPERIOD"))
{
if (!commandArgs.Has("STARTDATE")) MDTrace.WriteLine(LogLevel.DEBUG, "Missing STARTDATE");
if (!commandArgs.Has("MAXPOSITIONS")) MDTrace.WriteLine(LogLevel.DEBUG, "Missing MAXPOSITIONS");
if (!commandArgs.Has("INITIALCASH")) MDTrace.WriteLine(LogLevel.DEBUG, "Missing INITIALCASH");
if (!commandArgs.Has("HOLDINGPERIOD")) MDTrace.WriteLine(LogLevel.DEBUG, "Missing HOLDINGPERIOD");
if (!commandArgs.Has("STARTDATE")) MDTrace.WriteLine(LogLevel.DEBUG,ConsoleColor.Red, "Missing STARTDATE");
if (!commandArgs.Has("MAXPOSITIONS")) MDTrace.WriteLine(LogLevel.DEBUG,ConsoleColor.Red, "Missing MAXPOSITIONS");
if (!commandArgs.Has("INITIALCASH")) MDTrace.WriteLine(LogLevel.DEBUG,ConsoleColor.Red, "Missing INITIALCASH");
if (!commandArgs.Has("HOLDINGPERIOD")) MDTrace.WriteLine(LogLevel.DEBUG,ConsoleColor.Red, "Missing HOLDINGPERIOD");
return;
}
mgParams.MaxPositions=commandArgs.Coalesce<int>("MAXPOSITIONS");
@@ -141,18 +141,18 @@ namespace MarketData
DateGenerator dateGenerator = new DateGenerator();
if(!dateGenerator.IsMarketOpen(startDate))
{
MDTrace.WriteLine(LogLevel.DEBUG,$"STARTDATE {startDate.ToShortDateString()} is not a trading date.");
MDTrace.WriteLine(LogLevel.DEBUG,ConsoleColor.Red,$"STARTDATE {startDate.ToShortDateString()} is not a trading date.");
return;
}
if(!dateGenerator.IsMarketOpen(endDate))
{
MDTrace.WriteLine(LogLevel.DEBUG,$"ENDDATE {endDate.ToShortDateString()} is not a trading date.");
MDTrace.WriteLine(LogLevel.DEBUG,ConsoleColor.Red,$"ENDDATE {endDate.ToShortDateString()} is not a trading date.");
return;
}
if(!commandArgs.Has("SESSIONFILE"))
{
MDTrace.WriteLine(LogLevel.DEBUG,$"SESSIONFILE is a required parameter.");
MDTrace.WriteLine(LogLevel.DEBUG,ConsoleColor.Red,$"SESSIONFILE is a required parameter.");
return;
}

View File

@@ -1,5 +1,5 @@
#!/bin/bash
echo "THIS IS THE PRDUCTION FILE FOR MGSHMOMENTUM"
echo "THIS IS THE PRODUCTION FILE FOR MGSHMOMENTUM"
echo "THIS MODEL STARTS TRADING 03/31/2025"
echo "RUNMGSHMOMENTUM MODE{DAILY|MONTHLY} TRADEDATE"

View File

@@ -536,8 +536,8 @@ namespace MarketData.Generator.MGSHMomentum
AnalysisDate=analysisDate;
if(startDate != TradeDate)
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Unexpectd StartDate. Start Date:{startDate.ToShortDateString()} Trade Date:{TradeDate.ToShortDateString()}");
{
MDTrace.WriteLine(LogLevel.DEBUG,ConsoleColor.Red,$"Unexpectd StartDate. Start Date:{startDate.ToShortDateString()} Trade Date:{TradeDate.ToShortDateString()}");
return new MGSHBacktestResult(false, CashBalance);
}

View File

@@ -72,6 +72,20 @@ namespace MarketData
Console.WriteLine(message);
Flush();
}
/// <summary>WriteLine - Writes a line of text to trace log.</summary>
/// <param name="message">string content of message to write.</param>
/// <returns>void</returns>
public static void WriteLine(LogLevel logLevel,ConsoleColor consoleColor,string message)
{
if(MDTrace.logLevel<logLevel)return;
Trace.WriteLine(GetCallerIP()+GetThreadRep()+GetLogLevelRep()+"["+DateTime.Now.ToString()+"]"+" "+GetMethodInfo()+message);
ConsoleColor currentColor=Console.ForegroundColor;
Console.ForegroundColor = consoleColor;
Console.WriteLine(message);
Console.ForegroundColor=currentColor;
Flush();
}
/// <summary>Indent - set trace log indentation.</summary>
/// <returns>void</returns>
public static void Indent()