Rename strategy to indicators
This commit is contained in:
@@ -8,18 +8,18 @@ namespace Managing.Domain.Scenarios
|
||||
public Scenario(string name, int? loopbackPeriod = 1)
|
||||
{
|
||||
Name = name;
|
||||
Strategies = new List<Strategy>();
|
||||
Indicators = new List<Indicator>();
|
||||
LoopbackPeriod = loopbackPeriod;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public List<Strategy> Strategies { get; set; }
|
||||
public List<Indicator> Indicators { get; set; }
|
||||
public int? LoopbackPeriod { get; set; }
|
||||
public User User { get; set; }
|
||||
|
||||
public void AddStrategy(Strategy strategy)
|
||||
public void AddIndicator(Indicator indicator)
|
||||
{
|
||||
Strategies.Add(strategy);
|
||||
Indicators.Add(indicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,48 +10,48 @@ namespace Managing.Domain.Scenarios;
|
||||
|
||||
public static class ScenarioHelpers
|
||||
{
|
||||
public static IEnumerable<IStrategy> GetStrategiesFromScenario(Scenario scenario)
|
||||
public static IEnumerable<IIndicator> GetIndicatorsFromScenario(Scenario scenario)
|
||||
{
|
||||
var strategies = new List<IStrategy>();
|
||||
foreach (var strategy in scenario.Strategies)
|
||||
var strategies = new List<IIndicator>();
|
||||
foreach (var strategy in scenario.Indicators)
|
||||
{
|
||||
var result = BuildStrategy(strategy);
|
||||
var result = BuildIndicator(strategy);
|
||||
strategies.Add(result);
|
||||
}
|
||||
|
||||
return strategies;
|
||||
}
|
||||
|
||||
public static IStrategy BuildStrategy(Strategy strategy, int size = 600)
|
||||
public static IIndicator BuildIndicator(Indicator indicator, int size = 600)
|
||||
{
|
||||
IStrategy result = strategy.Type switch
|
||||
IIndicator result = indicator.Type switch
|
||||
{
|
||||
StrategyType.StDev => new StDevContext(strategy.Name, strategy.Period.Value),
|
||||
StrategyType.RsiDivergence => new RsiDivergenceStrategy(strategy.Name,
|
||||
strategy.Period.Value),
|
||||
StrategyType.RsiDivergenceConfirm => new RsiDivergenceConfirmStrategy(strategy.Name,
|
||||
strategy.Period.Value),
|
||||
StrategyType.MacdCross => new MacdCrossStrategy(strategy.Name,
|
||||
strategy.FastPeriods.Value, strategy.SlowPeriods.Value, strategy.SignalPeriods.Value),
|
||||
StrategyType.EmaCross => new EmaCrossStrategy(strategy.Name, strategy.Period.Value),
|
||||
StrategyType.DualEmaCross => new DualEmaCrossStrategy(strategy.Name,
|
||||
strategy.FastPeriods.Value, strategy.SlowPeriods.Value),
|
||||
StrategyType.ThreeWhiteSoldiers => new ThreeWhiteSoldiersStrategy(strategy.Name,
|
||||
strategy.Period.Value),
|
||||
StrategyType.SuperTrend => new SuperTrendStrategy(strategy.Name,
|
||||
strategy.Period.Value, strategy.Multiplier.Value),
|
||||
StrategyType.ChandelierExit => new ChandelierExitStrategy(strategy.Name,
|
||||
strategy.Period.Value, strategy.Multiplier.Value),
|
||||
StrategyType.EmaTrend => new EmaTrendStrategy(strategy.Name, strategy.Period.Value),
|
||||
StrategyType.StochRsiTrend => new StochRsiTrendStrategy(strategy.Name,
|
||||
strategy.Period.Value, strategy.StochPeriods.Value, strategy.SignalPeriods.Value,
|
||||
strategy.SmoothPeriods.Value),
|
||||
StrategyType.Stc => new StcStrategy(strategy.Name, strategy.CyclePeriods.Value,
|
||||
strategy.FastPeriods.Value, strategy.SlowPeriods.Value),
|
||||
StrategyType.LaggingStc => new LaggingSTC(strategy.Name, strategy.CyclePeriods.Value,
|
||||
strategy.FastPeriods.Value, strategy.SlowPeriods.Value),
|
||||
StrategyType.SuperTrendCrossEma => new SuperTrendCrossEma(strategy.Name,
|
||||
strategy.Period.Value, strategy.Multiplier.Value),
|
||||
IndicatorType.StDev => new StDevContext(indicator.Name, indicator.Period.Value),
|
||||
IndicatorType.RsiDivergence => new RsiDivergenceIndicator(indicator.Name,
|
||||
indicator.Period.Value),
|
||||
IndicatorType.RsiDivergenceConfirm => new RsiDivergenceConfirmIndicator(indicator.Name,
|
||||
indicator.Period.Value),
|
||||
IndicatorType.MacdCross => new MacdCrossIndicator(indicator.Name,
|
||||
indicator.FastPeriods.Value, indicator.SlowPeriods.Value, indicator.SignalPeriods.Value),
|
||||
IndicatorType.EmaCross => new EmaCrossIndicator(indicator.Name, indicator.Period.Value),
|
||||
IndicatorType.DualEmaCross => new DualEmaCrossIndicator(indicator.Name,
|
||||
indicator.FastPeriods.Value, indicator.SlowPeriods.Value),
|
||||
IndicatorType.ThreeWhiteSoldiers => new ThreeWhiteSoldiersIndicator(indicator.Name,
|
||||
indicator.Period.Value),
|
||||
IndicatorType.SuperTrend => new SuperTrendIndicator(indicator.Name,
|
||||
indicator.Period.Value, indicator.Multiplier.Value),
|
||||
IndicatorType.ChandelierExit => new ChandelierExitIndicator(indicator.Name,
|
||||
indicator.Period.Value, indicator.Multiplier.Value),
|
||||
IndicatorType.EmaTrend => new EmaTrendIndicator(indicator.Name, indicator.Period.Value),
|
||||
IndicatorType.StochRsiTrend => new StochRsiTrendIndicator(indicator.Name,
|
||||
indicator.Period.Value, indicator.StochPeriods.Value, indicator.SignalPeriods.Value,
|
||||
indicator.SmoothPeriods.Value),
|
||||
IndicatorType.Stc => new StcIndicator(indicator.Name, indicator.CyclePeriods.Value,
|
||||
indicator.FastPeriods.Value, indicator.SlowPeriods.Value),
|
||||
IndicatorType.LaggingStc => new LaggingSTC(indicator.Name, indicator.CyclePeriods.Value,
|
||||
indicator.FastPeriods.Value, indicator.SlowPeriods.Value),
|
||||
IndicatorType.SuperTrendCrossEma => new SuperTrendCrossEma(indicator.Name,
|
||||
indicator.Period.Value, indicator.Multiplier.Value),
|
||||
_ => throw new NotImplementedException(),
|
||||
};
|
||||
|
||||
@@ -59,8 +59,8 @@ public static class ScenarioHelpers
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Strategy BuildStrategy(
|
||||
StrategyType type,
|
||||
public static Indicator BuildIndicator(
|
||||
IndicatorType type,
|
||||
string name,
|
||||
int? period = null,
|
||||
int? fastPeriods = null,
|
||||
@@ -71,98 +71,98 @@ public static class ScenarioHelpers
|
||||
int? smoothPeriods = null,
|
||||
int? cyclePeriods = null)
|
||||
{
|
||||
var strategy = new Strategy(name, type);
|
||||
var indicator = new Indicator(name, type);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case StrategyType.RsiDivergence:
|
||||
case StrategyType.RsiDivergenceConfirm:
|
||||
case StrategyType.EmaTrend:
|
||||
case StrategyType.EmaCross:
|
||||
case StrategyType.StDev:
|
||||
case IndicatorType.RsiDivergence:
|
||||
case IndicatorType.RsiDivergenceConfirm:
|
||||
case IndicatorType.EmaTrend:
|
||||
case IndicatorType.EmaCross:
|
||||
case IndicatorType.StDev:
|
||||
if (!period.HasValue)
|
||||
{
|
||||
throw new Exception($"Missing period for {strategy.Type} strategy type");
|
||||
throw new Exception($"Missing period for {indicator.Type} strategy type");
|
||||
}
|
||||
else
|
||||
{
|
||||
strategy.Period = period.Value;
|
||||
indicator.Period = period.Value;
|
||||
}
|
||||
|
||||
break;
|
||||
case StrategyType.MacdCross:
|
||||
case IndicatorType.MacdCross:
|
||||
if (!fastPeriods.HasValue || !slowPeriods.HasValue || !signalPeriods.HasValue)
|
||||
{
|
||||
throw new Exception(
|
||||
$"Missing fastPeriods or slowPeriods or signalPeriods, for {strategy.Type} strategy type");
|
||||
$"Missing fastPeriods or slowPeriods or signalPeriods, for {indicator.Type} strategy type");
|
||||
}
|
||||
else
|
||||
{
|
||||
strategy.FastPeriods = fastPeriods;
|
||||
strategy.SlowPeriods = slowPeriods;
|
||||
strategy.SignalPeriods = signalPeriods;
|
||||
indicator.FastPeriods = fastPeriods;
|
||||
indicator.SlowPeriods = slowPeriods;
|
||||
indicator.SignalPeriods = signalPeriods;
|
||||
}
|
||||
|
||||
break;
|
||||
case StrategyType.DualEmaCross:
|
||||
case IndicatorType.DualEmaCross:
|
||||
if (!fastPeriods.HasValue || !slowPeriods.HasValue)
|
||||
{
|
||||
throw new Exception(
|
||||
$"Missing fastPeriods or slowPeriods for {strategy.Type} strategy type");
|
||||
$"Missing fastPeriods or slowPeriods for {indicator.Type} strategy type");
|
||||
}
|
||||
else
|
||||
{
|
||||
strategy.FastPeriods = fastPeriods;
|
||||
strategy.SlowPeriods = slowPeriods;
|
||||
indicator.FastPeriods = fastPeriods;
|
||||
indicator.SlowPeriods = slowPeriods;
|
||||
}
|
||||
|
||||
break;
|
||||
case StrategyType.ThreeWhiteSoldiers:
|
||||
case IndicatorType.ThreeWhiteSoldiers:
|
||||
break;
|
||||
case StrategyType.SuperTrend:
|
||||
case StrategyType.SuperTrendCrossEma:
|
||||
case StrategyType.ChandelierExit:
|
||||
case IndicatorType.SuperTrend:
|
||||
case IndicatorType.SuperTrendCrossEma:
|
||||
case IndicatorType.ChandelierExit:
|
||||
if (!period.HasValue || !multiplier.HasValue)
|
||||
{
|
||||
throw new Exception($"Missing period or multiplier, for {strategy.Type} strategy type");
|
||||
throw new Exception($"Missing period or multiplier, for {indicator.Type} strategy type");
|
||||
}
|
||||
else
|
||||
{
|
||||
strategy.Period = period;
|
||||
strategy.Multiplier = multiplier;
|
||||
indicator.Period = period;
|
||||
indicator.Multiplier = multiplier;
|
||||
}
|
||||
|
||||
break;
|
||||
case StrategyType.StochRsiTrend:
|
||||
case IndicatorType.StochRsiTrend:
|
||||
if (!period.HasValue
|
||||
|| !stochPeriods.HasValue
|
||||
|| !signalPeriods.HasValue
|
||||
|| !smoothPeriods.HasValue)
|
||||
{
|
||||
throw new Exception(
|
||||
$"Missing period, stochPeriods, signalPeriods, smoothPeriods for {strategy.Type} strategy type");
|
||||
$"Missing period, stochPeriods, signalPeriods, smoothPeriods for {indicator.Type} strategy type");
|
||||
}
|
||||
else
|
||||
{
|
||||
strategy.Period = period;
|
||||
strategy.StochPeriods = stochPeriods;
|
||||
strategy.SignalPeriods = signalPeriods;
|
||||
strategy.SmoothPeriods = smoothPeriods;
|
||||
indicator.Period = period;
|
||||
indicator.StochPeriods = stochPeriods;
|
||||
indicator.SignalPeriods = signalPeriods;
|
||||
indicator.SmoothPeriods = smoothPeriods;
|
||||
}
|
||||
|
||||
break;
|
||||
case StrategyType.Stc:
|
||||
case StrategyType.LaggingStc:
|
||||
case IndicatorType.Stc:
|
||||
case IndicatorType.LaggingStc:
|
||||
if (!fastPeriods.HasValue || !slowPeriods.HasValue || !cyclePeriods.HasValue)
|
||||
{
|
||||
throw new Exception(
|
||||
$"Missing fastPeriods or slowPeriods or cyclePeriods, for {strategy.Type} strategy type");
|
||||
$"Missing fastPeriods or slowPeriods or cyclePeriods, for {indicator.Type} strategy type");
|
||||
}
|
||||
else
|
||||
{
|
||||
strategy.FastPeriods = fastPeriods;
|
||||
strategy.SlowPeriods = slowPeriods;
|
||||
strategy.CyclePeriods = cyclePeriods;
|
||||
indicator.FastPeriods = fastPeriods;
|
||||
indicator.SlowPeriods = slowPeriods;
|
||||
indicator.CyclePeriods = cyclePeriods;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -170,28 +170,28 @@ public static class ScenarioHelpers
|
||||
break;
|
||||
}
|
||||
|
||||
return strategy;
|
||||
return indicator;
|
||||
}
|
||||
|
||||
public static SignalType GetSignalType(StrategyType type)
|
||||
public static SignalType GetSignalType(IndicatorType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
StrategyType.RsiDivergence => SignalType.Signal,
|
||||
StrategyType.RsiDivergenceConfirm => SignalType.Signal,
|
||||
StrategyType.MacdCross => SignalType.Signal,
|
||||
StrategyType.EmaCross => SignalType.Signal,
|
||||
StrategyType.DualEmaCross => SignalType.Signal,
|
||||
StrategyType.ThreeWhiteSoldiers => SignalType.Signal,
|
||||
StrategyType.SuperTrend => SignalType.Signal,
|
||||
StrategyType.ChandelierExit => SignalType.Signal,
|
||||
StrategyType.EmaTrend => SignalType.Trend,
|
||||
StrategyType.Composite => SignalType.Signal,
|
||||
StrategyType.StochRsiTrend => SignalType.Trend,
|
||||
StrategyType.Stc => SignalType.Signal,
|
||||
StrategyType.StDev => SignalType.Context,
|
||||
StrategyType.LaggingStc => SignalType.Signal,
|
||||
StrategyType.SuperTrendCrossEma => SignalType.Signal,
|
||||
IndicatorType.RsiDivergence => SignalType.Signal,
|
||||
IndicatorType.RsiDivergenceConfirm => SignalType.Signal,
|
||||
IndicatorType.MacdCross => SignalType.Signal,
|
||||
IndicatorType.EmaCross => SignalType.Signal,
|
||||
IndicatorType.DualEmaCross => SignalType.Signal,
|
||||
IndicatorType.ThreeWhiteSoldiers => SignalType.Signal,
|
||||
IndicatorType.SuperTrend => SignalType.Signal,
|
||||
IndicatorType.ChandelierExit => SignalType.Signal,
|
||||
IndicatorType.EmaTrend => SignalType.Trend,
|
||||
IndicatorType.Composite => SignalType.Signal,
|
||||
IndicatorType.StochRsiTrend => SignalType.Trend,
|
||||
IndicatorType.Stc => SignalType.Signal,
|
||||
IndicatorType.StDev => SignalType.Context,
|
||||
IndicatorType.LaggingStc => SignalType.Signal,
|
||||
IndicatorType.SuperTrendCrossEma => SignalType.Signal,
|
||||
_ => throw new NotImplementedException(),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user