Add BetaCalc36 to MGMomentum

This commit is contained in:
2025-05-09 13:40:13 -04:00
parent 3d58fa94e2
commit 316173b711
4 changed files with 16 additions and 7 deletions

View File

@@ -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<Boolean>();
mgConfiguration.LowSlopeBetaDays=nvpDictionary["LowSlopeBetaDays"].Get<int>();
mgConfiguration.LowSlopeBetaThreshhold=nvpDictionary["LowSlopeBetaThreshhold"].Get<double>();
if(nvpDictionary.ContainsKey("UseCalcBeta"))mgConfiguration.UseCalcBeta=nvpDictionary["UseCalcBeta"].Get<bool>();
mgConfiguration.UseMACD=nvpDictionary["UseMACD"].Get<Boolean>();
mgConfiguration.MACDSetup=nvpDictionary["MACDSetup"].Get<String>();
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("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));

View File

@@ -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);