Add Bollinger Bands Volatility Protection indicator support

- Introduced BollingerBandsVolatilityProtection indicator in GeneticService with configuration settings for period and standard deviation (stdev).
- Updated ScenarioHelpers to handle creation and validation of the new indicator type.
- Enhanced CustomScenario, backtest, and scenario pages to include BollingerBandsVolatilityProtection in indicator lists and parameter mappings.
- Modified API and types to reflect the addition of the new indicator in relevant enums and mappings.
- Updated frontend components to support new parameters and visualization for Bollinger Bands.
This commit is contained in:
2025-11-25 02:12:57 +07:00
parent 3ec1da531a
commit 6376e13b07
21 changed files with 618 additions and 220 deletions

View File

@@ -155,16 +155,24 @@ public class JobService
{
Indicators = sReq.Indicators?.Select(ind => new LightIndicator(ind.Name, ind.Type)
{
SignalType = ind.SignalType,
MinimumHistory = ind.MinimumHistory,
Period = ind.Period,
FastPeriods = ind.FastPeriods,
SlowPeriods = ind.SlowPeriods,
SignalPeriods = ind.SignalPeriods,
Multiplier = ind.Multiplier,
StDev = ind.StDev,
SmoothPeriods = ind.SmoothPeriods,
StochPeriods = ind.StochPeriods,
CyclePeriods = ind.CyclePeriods
CyclePeriods = ind.CyclePeriods,
KFactor = ind.KFactor,
DFactor = ind.DFactor,
TenkanPeriods = ind.TenkanPeriods,
KijunPeriods = ind.KijunPeriods,
SenkouBPeriods = ind.SenkouBPeriods,
OffsetPeriods = ind.OffsetPeriods,
SenkouOffset = ind.SenkouOffset,
ChikouOffset = ind.ChikouOffset
}).ToList() ?? new List<LightIndicator>()
};
}

View File

@@ -107,7 +107,12 @@ public class GeneticService : IGeneticService
[IndicatorType.BollingerBandsPercentBMomentumBreakout] = new()
{
["period"] = 20.0,
["multiplier"] = 2.0
["stdev"] = 2.0
},
[IndicatorType.BollingerBandsVolatilityProtection] = new()
{
["period"] = 20.0,
["stdev"] = 2.0
},
[IndicatorType.IchimokuKumoTrend] = new()
{
@@ -202,7 +207,12 @@ public class GeneticService : IGeneticService
[IndicatorType.BollingerBandsPercentBMomentumBreakout] = new()
{
["period"] = (5.0, 50.0),
["multiplier"] = (1.0, 5.0)
["stdev"] = (1.0, 5.0)
},
[IndicatorType.BollingerBandsVolatilityProtection] = new()
{
["period"] = (10.0, 50.0),
["stdev"] = (1.5, 3.0)
},
[IndicatorType.IchimokuKumoTrend] = new()
{
@@ -231,7 +241,8 @@ public class GeneticService : IGeneticService
[IndicatorType.StochasticCross] = ["stochPeriods", "signalPeriods", "smoothPeriods", "kFactor", "dFactor"],
[IndicatorType.Stc] = ["cyclePeriods", "fastPeriods", "slowPeriods"],
[IndicatorType.LaggingStc] = ["cyclePeriods", "fastPeriods", "slowPeriods"],
[IndicatorType.BollingerBandsPercentBMomentumBreakout] = ["period", "multiplier"],
[IndicatorType.BollingerBandsPercentBMomentumBreakout] = ["period", "stdev"],
[IndicatorType.BollingerBandsVolatilityProtection] = ["period", "stdev"],
[IndicatorType.IchimokuKumoTrend] = ["tenkanPeriods", "kijunPeriods", "senkouBPeriods", "offsetPeriods"]
};
@@ -860,10 +871,10 @@ public class TradingBotChromosome : ChromosomeBase
indicator.SignalPeriods = Convert.ToInt32(genes[baseIndex + 3].Value);
}
paramName = GetParameterName(4); // multiplier
paramName = GetParameterName(4); // stdev
if (paramName != null && HasParameter(_eligibleIndicators[i], paramName))
{
indicator.Multiplier = Convert.ToDouble(genes[baseIndex + 4].Value);
indicator.StDev = Convert.ToDouble(genes[baseIndex + 4].Value);
}
paramName = GetParameterName(5); // stochPeriods
@@ -983,7 +994,7 @@ public class TradingBotChromosome : ChromosomeBase
1 => "fastPeriods",
2 => "slowPeriods",
3 => "signalPeriods",
4 => "multiplier",
4 => "stdev",
5 => "stochPeriods",
6 => "smoothPeriods",
7 => "cyclePeriods",

View File

@@ -324,7 +324,6 @@ public class BundleBacktestGrain : Grain, IBundleBacktestGrain, IRemindable
{
Indicators = sReq.Indicators?.Select(i => new LightIndicator(i.Name, i.Type)
{
SignalType = i.SignalType,
MinimumHistory = i.MinimumHistory,
Period = i.Period,
FastPeriods = i.FastPeriods,

View File

@@ -229,7 +229,6 @@ public class BundleBacktestWorker : BaseWorker<BundleBacktestWorker>
{
Indicators = sReq.Indicators?.Select(i => new LightIndicator(i.Name, i.Type)
{
SignalType = i.SignalType,
MinimumHistory = i.MinimumHistory,
Period = i.Period,
FastPeriods = i.FastPeriods,