Add BetaCalc36 to MGMomentum
This commit is contained in:
@@ -54,6 +54,11 @@ namespace MarketData.ModelHelper
|
|||||||
mgParams.UseStochastics=commandArgs.Coalesce<bool>("USESTOCHASTICS",true);
|
mgParams.UseStochastics=commandArgs.Coalesce<bool>("USESTOCHASTICS",true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(commandArgs.Has("USECALCBETA"))
|
||||||
|
{
|
||||||
|
mgParams.UseCalcBeta=commandArgs.Coalesce<bool>("USECALCBETA",true);
|
||||||
|
}
|
||||||
|
|
||||||
// ** M A C D
|
// ** M A C D
|
||||||
if(commandArgs.Has("USEMACD"))
|
if(commandArgs.Has("USEMACD"))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/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
|
export DOTNET_ROOT=/opt/dotnet
|
||||||
RUNDATE="$1"
|
RUNDATE="$1"
|
||||||
#PATHMODEL="/home/pi/ARM64/MarketData/MarketData/Models/MGBACKTEST_BETA.TXT"
|
PATHMODELBETA="/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 /USECALCBETA:FALSE /STARTDATE:12/31/2018 /ENDDATE:04/30/2025 /INITIALCASH:10000 /MAXPOSITIONS:3 /HOLDINGPERIOD:3 /SESSIONFILE:$PATHMODELBETA /QUALITYINDICATORTYPE:SCOREINDICATOR
|
||||||
/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
|
#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
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ namespace MarketData.Generator.Momentum
|
|||||||
public bool UseLowSlopeBetaCheck{get;set;}
|
public bool UseLowSlopeBetaCheck{get;set;}
|
||||||
public int LowSlopeBetaDays{get;set;}
|
public int LowSlopeBetaDays{get;set;}
|
||||||
public double LowSlopeBetaThreshhold{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.
|
// 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;}
|
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
|
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
|
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
|
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
|
UseMACD=true; // true is the default
|
||||||
MACDSetup="(12,26,9)"; // (12,26,9)
|
MACDSetup="(12,26,9)"; // (12,26,9)
|
||||||
MACDSignalDays=12; // 12 is the default
|
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("UseLowSlopeBetaCheck",UseLowSlopeBetaCheck.ToString()));
|
||||||
nvpCollection.Add(new NVP("LowSlopeBetaDays",LowSlopeBetaDays.ToString()));
|
nvpCollection.Add(new NVP("LowSlopeBetaDays",LowSlopeBetaDays.ToString()));
|
||||||
nvpCollection.Add(new NVP("LowSlopeBetaThreshhold",LowSlopeBetaThreshhold.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("UseMACD",UseMACD.ToString()));
|
||||||
nvpCollection.Add(new NVP("MACDSetup",MACDSetup.ToString()));
|
nvpCollection.Add(new NVP("MACDSetup",MACDSetup.ToString()));
|
||||||
nvpCollection.Add(new NVP("MACDSignalDays",MACDSignalDays.ToString()));
|
nvpCollection.Add(new NVP("MACDSignalDays",MACDSignalDays.ToString()));
|
||||||
@@ -166,6 +169,7 @@ namespace MarketData.Generator.Momentum
|
|||||||
mgConfiguration.UseLowSlopeBetaCheck=nvpDictionary["UseLowSlopeBetaCheck"].Get<Boolean>();
|
mgConfiguration.UseLowSlopeBetaCheck=nvpDictionary["UseLowSlopeBetaCheck"].Get<Boolean>();
|
||||||
mgConfiguration.LowSlopeBetaDays=nvpDictionary["LowSlopeBetaDays"].Get<int>();
|
mgConfiguration.LowSlopeBetaDays=nvpDictionary["LowSlopeBetaDays"].Get<int>();
|
||||||
mgConfiguration.LowSlopeBetaThreshhold=nvpDictionary["LowSlopeBetaThreshhold"].Get<double>();
|
mgConfiguration.LowSlopeBetaThreshhold=nvpDictionary["LowSlopeBetaThreshhold"].Get<double>();
|
||||||
|
if(nvpDictionary.ContainsKey("UseCalcBeta"))mgConfiguration.UseCalcBeta=nvpDictionary["UseCalcBeta"].Get<bool>();
|
||||||
mgConfiguration.UseMACD=nvpDictionary["UseMACD"].Get<Boolean>();
|
mgConfiguration.UseMACD=nvpDictionary["UseMACD"].Get<Boolean>();
|
||||||
mgConfiguration.MACDSetup=nvpDictionary["MACDSetup"].Get<String>();
|
mgConfiguration.MACDSetup=nvpDictionary["MACDSetup"].Get<String>();
|
||||||
mgConfiguration.MACDSignalDays=nvpDictionary["MACDSignalDays"].Get<int>();
|
mgConfiguration.MACDSignalDays=nvpDictionary["MACDSignalDays"].Get<int>();
|
||||||
@@ -207,6 +211,7 @@ namespace MarketData.Generator.Momentum
|
|||||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("UseLowSlopeBetaCheck,{0}",UseLowSlopeBetaCheck));
|
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("UseLowSlopeBetaCheck,{0}",UseLowSlopeBetaCheck));
|
||||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("LowSlopeBetaDays,{0}",LowSlopeBetaDays));
|
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("LowSlopeBetaDays,{0}",LowSlopeBetaDays));
|
||||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("LowSlopeBetaThreshhold,{0}",LowSlopeBetaThreshhold));
|
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("UseMACD,{0}",UseMACD));
|
||||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("MACDSetup,{0}",MACDSetup));
|
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("MACDSetup,{0}",MACDSetup));
|
||||||
|
|||||||
@@ -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
|
// 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
|
// 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.
|
// 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)
|
if(config.UseLowSlopeBetaCheck && beta >= config.LowSlopeBetaThreshhold)
|
||||||
{
|
{
|
||||||
Prices benchmarkPrices=GBPriceCache.GetInstance().GetPrices(config.Benchmark,tradeDate,config.LowSlopeBetaDays);
|
Prices benchmarkPrices=GBPriceCache.GetInstance().GetPrices(config.Benchmark,tradeDate,config.LowSlopeBetaDays);
|
||||||
|
|||||||
Reference in New Issue
Block a user