Refactoring TradingBotBase.cs + clean architecture (#38)
* Refactoring TradingBotBase.cs + clean architecture * Fix basic tests * Fix tests * Fix workers * Fix open positions * Fix closing position stucking the grain * Fix comments * Refactor candle handling to use IReadOnlyList for chronological order preservation across various components
This commit is contained in:
@@ -28,7 +28,7 @@ public class StochasticCrossIndicator : IndicatorBase
|
||||
DFactor = dFactor;
|
||||
}
|
||||
|
||||
public override List<LightSignal> Run(HashSet<Candle> candles)
|
||||
public override List<LightSignal> Run(IReadOnlyList<Candle> candles)
|
||||
{
|
||||
if (candles.Count <= 10 * StochPeriods.Value + 50)
|
||||
{
|
||||
@@ -55,7 +55,7 @@ public class StochasticCrossIndicator : IndicatorBase
|
||||
}
|
||||
}
|
||||
|
||||
public override List<LightSignal> Run(HashSet<Candle> candles, IndicatorsResultBase preCalculatedValues)
|
||||
public override List<LightSignal> Run(IReadOnlyList<Candle> candles, IndicatorsResultBase preCalculatedValues)
|
||||
{
|
||||
if (candles.Count <= 10 * StochPeriods.Value + 50)
|
||||
{
|
||||
@@ -95,7 +95,7 @@ public class StochasticCrossIndicator : IndicatorBase
|
||||
/// Long signals: %K crosses above %D when both lines are below 20 (oversold)
|
||||
/// Short signals: %K crosses below %D when both lines are above 80 (overbought)
|
||||
/// </summary>
|
||||
private void ProcessStochasticSignals(List<StochResult> stochResults, HashSet<Candle> candles)
|
||||
private void ProcessStochasticSignals(List<StochResult> stochResults, IReadOnlyList<Candle> candles)
|
||||
{
|
||||
var stochCandles = MapStochToCandle(stochResults, candles.TakeLast(StochPeriods.Value));
|
||||
|
||||
@@ -132,7 +132,7 @@ public class StochasticCrossIndicator : IndicatorBase
|
||||
}
|
||||
}
|
||||
|
||||
public override IndicatorsResultBase GetIndicatorValues(HashSet<Candle> candles)
|
||||
public override IndicatorsResultBase GetIndicatorValues(IReadOnlyList<Candle> candles)
|
||||
{
|
||||
return new IndicatorsResultBase()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user