normalization of methods

This commit is contained in:
Miha Kralj
2026-02-10 21:33:16 -08:00
parent 915d7a007b
commit 6d6259a47d
527 changed files with 10525 additions and 2123 deletions
+1 -1
View File
@@ -93,7 +93,7 @@ public class StcTests
var batchStc = CreateDefaultStc();
var tseriesResult = batchStc.Update(series);
Stc.Calculate(input.AsSpan(), output.AsSpan(), kPeriod: CycleLength, dPeriod: CycleLength, fastLength: FastLength, slowLength: SlowLength, smoothing: StcSmoothing.Sigmoid);
Stc.Batch(input.AsSpan(), output.AsSpan(), kPeriod: CycleLength, dPeriod: CycleLength, fastLength: FastLength, slowLength: SlowLength, smoothing: StcSmoothing.Sigmoid);
// Compare last value
Assert.Equal(tseriesResult.Last.Value, output[^1], 1e-9);
+10 -3
View File
@@ -473,7 +473,7 @@ public sealed class Stc : AbstractBase
/// <summary>
/// Static convenience method that creates a new Stc instance and processes the entire series.
/// </summary>
public static TSeries Calculate(TSeries source, int kPeriod = 10, int dPeriod = 3, int fastLength = 23, int slowLength = 50, StcSmoothing smoothing = StcSmoothing.Ema)
public static TSeries Batch(TSeries source, int kPeriod = 10, int dPeriod = 3, int fastLength = 23, int slowLength = 50, StcSmoothing smoothing = StcSmoothing.Ema)
{
var indicator = new Stc(kPeriod, dPeriod, fastLength, slowLength, smoothing);
return indicator.Update(source);
@@ -483,7 +483,7 @@ public sealed class Stc : AbstractBase
// replicate the full STC state machine inline for zero-allocation performance.
// The sequential MACD→Stoch1→Stoch2→Smoothing pipeline cannot be decomposed
// without introducing heap allocations or sacrificing inlining opportunities.
public static void Calculate(ReadOnlySpan<double> source, Span<double> output,
public static void Batch(ReadOnlySpan<double> source, Span<double> output,
int kPeriod = 10, int dPeriod = 3, int fastLength = 23, int slowLength = 50, StcSmoothing smoothing = StcSmoothing.Ema)
{
if (source.Length != output.Length)
@@ -665,4 +665,11 @@ public sealed class Stc : AbstractBase
}
}
}
}
public static (TSeries Results, Stc Indicator) Calculate(TSeries source, int kPeriod = 10, int dPeriod = 3, int fastLength = 23, int slowLength = 50, StcSmoothing smoothing = StcSmoothing.Ema)
{
var indicator = new Stc(kPeriod, dPeriod, fastLength, slowLength, smoothing);
TSeries results = indicator.Update(source);
return (results, indicator);
}
}