diff --git a/MarketData/MarketData/ModelHelper/MGMomentumHelper.cs b/MarketData/MarketData/ModelHelper/MGMomentumHelper.cs index 8dd4243..2bc78e5 100755 --- a/MarketData/MarketData/ModelHelper/MGMomentumHelper.cs +++ b/MarketData/MarketData/ModelHelper/MGMomentumHelper.cs @@ -54,6 +54,11 @@ namespace MarketData.ModelHelper mgParams.UseStochastics=commandArgs.Coalesce("USESTOCHASTICS",true); } + if(commandArgs.Has("USECALCBETA")) + { + mgParams.UseCalcBeta=commandArgs.Coalesce("USECALCBETA",true); + } + // ** M A C D if(commandArgs.Has("USEMACD")) { diff --git a/MarketData/MarketData/Models/runbacktest.sh b/MarketData/MarketData/Models/runbacktest.sh index 356075f..d4eed43 100755 --- a/MarketData/MarketData/Models/runbacktest.sh +++ b/MarketData/MarketData/Models/runbacktest.sh @@ -1,9 +1,7 @@ #!/bin/bash - -# RUN THE BASLINE AND THEN SUBSTITUTE BETACALC36 FOR BETA IN THE MG MODEL AND RERUN THE TEST AND THEN COMPARE THE RESULTS - export DOTNET_ROOT=/opt/dotnet RUNDATE="$1" -#PATHMODEL="/home/pi/ARM64/MarketData/MarketData/Models/MGBACKTEST_BETA.TXT" -PATHMODEL="/home/pi/ARM64/MarketData/MarketData/Models/MGBACKTEST_BETA_CALC36.TXT" -/home/pi/ARM64/MarketData/MarketData/bin/Debug/net8.0/mk RUNBACKTEST /USELOWSLOPEBETACHECK:FALSE /STARTDATE:12/31/2018 /ENDDATE:03/31/2025 /INITIALCASH:10000 /MAXPOSITIONS:3 /HOLDINGPERIOD:3 /SESSIONFILE:$PATHMODEL /QUALITYINDICATORTYPE:SCOREINDICATOR +PATHMODELBETA="/home/pi/ARM64/MarketData/MarketData/Models/MGBACKTEST_BETA.TXT" +/home/pi/ARM64/MarketData/MarketData/bin/Debug/net8.0/mk RUNBACKTEST /USECALCBETA:FALSE /STARTDATE:12/31/2018 /ENDDATE:04/30/2025 /INITIALCASH:10000 /MAXPOSITIONS:3 /HOLDINGPERIOD:3 /SESSIONFILE:$PATHMODELBETA /QUALITYINDICATORTYPE:SCOREINDICATOR +#PATHMODELCALCBETA="/home/pi/ARM64/MarketData/MarketData/Models/MGBACKTEST_BETA_CALC36.TXT" +#/home/pi/ARM64/MarketData/MarketData/bin/Debug/net8.0/mk RUNBACKTEST /USECALCBETA:TRUE /STARTDATE:12/31/2018 /ENDDATE:04/30/2025 /INITIALCASH:10000 /MAXPOSITIONS:3 /HOLDINGPERIOD:3 /SESSIONFILE:$PATHMODELCALCBETA /QUALITYINDICATORTYPE:SCOREINDICATOR diff --git a/MarketData/MarketDataLib/Generator/Momentum/MGConfiguration.cs b/MarketData/MarketDataLib/Generator/Momentum/MGConfiguration.cs index b67976e..d792e3a 100755 --- a/MarketData/MarketDataLib/Generator/Momentum/MGConfiguration.cs +++ b/MarketData/MarketDataLib/Generator/Momentum/MGConfiguration.cs @@ -31,6 +31,7 @@ namespace MarketData.Generator.Momentum public bool UseLowSlopeBetaCheck{get;set;} public int LowSlopeBetaDays{get;set;} public double LowSlopeBetaThreshhold{get;set;} + public bool UseCalcBeta{get;set;} // if this is set then use the betaCalc36 values from the beta generator that have been added to fundamentals, otherwise use the Beta from fundamentals (Yahoo/FinViz) // MACD Settings : If MACD is being used then the process configures the MACD as per setup and eliminates candidates with a weak sell/strong sell signal in the signal days setting. public bool UseMACD{get;set;} @@ -84,6 +85,7 @@ namespace MarketData.Generator.Momentum UseLowSlopeBetaCheck=true; // true is the default. this yields the most optimal performance in backtests LowSlopeBetaDays=15; // 15 is the default. This yields the most optimal performance in backtests LowSlopeBetaThreshhold=1.00; // (1.00) is the default This yields the most optimal performance in backtests + UseCalcBeta=true; // This is set to false by default UseMACD=true; // true is the default MACDSetup="(12,26,9)"; // (12,26,9) MACDSignalDays=12; // 12 is the default @@ -125,6 +127,7 @@ namespace MarketData.Generator.Momentum nvpCollection.Add(new NVP("UseLowSlopeBetaCheck",UseLowSlopeBetaCheck.ToString())); nvpCollection.Add(new NVP("LowSlopeBetaDays",LowSlopeBetaDays.ToString())); nvpCollection.Add(new NVP("LowSlopeBetaThreshhold",LowSlopeBetaThreshhold.ToString())); + nvpCollection.Add(new NVP("UseCalcBeta",UseCalcBeta.ToString())); nvpCollection.Add(new NVP("UseMACD",UseMACD.ToString())); nvpCollection.Add(new NVP("MACDSetup",MACDSetup.ToString())); nvpCollection.Add(new NVP("MACDSignalDays",MACDSignalDays.ToString())); @@ -166,6 +169,7 @@ namespace MarketData.Generator.Momentum mgConfiguration.UseLowSlopeBetaCheck=nvpDictionary["UseLowSlopeBetaCheck"].Get(); mgConfiguration.LowSlopeBetaDays=nvpDictionary["LowSlopeBetaDays"].Get(); mgConfiguration.LowSlopeBetaThreshhold=nvpDictionary["LowSlopeBetaThreshhold"].Get(); + if(nvpDictionary.ContainsKey("UseCalcBeta"))mgConfiguration.UseCalcBeta=nvpDictionary["UseCalcBeta"].Get(); mgConfiguration.UseMACD=nvpDictionary["UseMACD"].Get(); mgConfiguration.MACDSetup=nvpDictionary["MACDSetup"].Get(); mgConfiguration.MACDSignalDays=nvpDictionary["MACDSignalDays"].Get(); @@ -207,6 +211,7 @@ namespace MarketData.Generator.Momentum MDTrace.WriteLine(LogLevel.DEBUG,String.Format("UseLowSlopeBetaCheck,{0}",UseLowSlopeBetaCheck)); MDTrace.WriteLine(LogLevel.DEBUG,String.Format("LowSlopeBetaDays,{0}",LowSlopeBetaDays)); MDTrace.WriteLine(LogLevel.DEBUG,String.Format("LowSlopeBetaThreshhold,{0}",LowSlopeBetaThreshhold)); + MDTrace.WriteLine(LogLevel.DEBUG,String.Format("UseCalcBeta,{0}",UseCalcBeta)); MDTrace.WriteLine(LogLevel.DEBUG,String.Format("UseMACD,{0}",UseMACD)); MDTrace.WriteLine(LogLevel.DEBUG,String.Format("MACDSetup,{0}",MACDSetup)); diff --git a/MarketData/MarketDataLib/Generator/Momentum/MomentumGenerator.cs b/MarketData/MarketDataLib/Generator/Momentum/MomentumGenerator.cs index c7a1617..17a2606 100755 --- a/MarketData/MarketDataLib/Generator/Momentum/MomentumGenerator.cs +++ b/MarketData/MarketDataLib/Generator/Momentum/MomentumGenerator.cs @@ -209,7 +209,8 @@ namespace MarketData.Generator.Momentum // The idea behind this check is that a high beta stock will track to the benchmark. So if the benchmark lows are forming a downward pattern then we // assume that this is a somewhat bearish condition. The config has the setting at a 15 day check and the threshold beta set to 1.00 // The BetaCalc36 is calculated as part of the monthly fundamental run. - double beta = fundamental.BetaCalc36; + double beta = fundamental.Beta; + if(config.UseCalcBeta)beta=fundamental.BetaCalc36; if(config.UseLowSlopeBetaCheck && beta >= config.LowSlopeBetaThreshhold) { Prices benchmarkPrices=GBPriceCache.GetInstance().GetPrices(config.Benchmark,tradeDate,config.LowSlopeBetaDays);