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
+6 -6
View File
@@ -209,7 +209,7 @@ public class HighestTests
}
// Batch
var batch = Highest.Calculate(source, period);
var batch = Highest.Batch(source, period);
// Compare last values (after warmup)
for (int i = period; i < source.Count; i++)
@@ -228,12 +228,12 @@ public class HighestTests
var source = bars.Close;
// TSeries batch
var batchResult = Highest.Calculate(source, period);
var batchResult = Highest.Batch(source, period);
// Span calculation
var values = source.Values.ToArray();
var output = new double[count];
Highest.Calculate(values, output, period);
Highest.Batch(values, output, period);
for (int i = 0; i < source.Count; i++)
{
@@ -247,21 +247,21 @@ public class HighestTests
Assert.Throws<ArgumentException>(() =>
{
Span<double> output = stackalloc double[10];
Highest.Calculate(ReadOnlySpan<double>.Empty, output, 5);
Highest.Batch(ReadOnlySpan<double>.Empty, output, 5);
});
Assert.Throws<ArgumentException>(() =>
{
ReadOnlySpan<double> source = stackalloc double[10];
Span<double> output = stackalloc double[5];
Highest.Calculate(source, output, 5);
Highest.Batch(source, output, 5);
});
Assert.Throws<ArgumentException>(() =>
{
ReadOnlySpan<double> source = stackalloc double[10];
Span<double> output = stackalloc double[10];
Highest.Calculate(source, output, 0);
Highest.Batch(source, output, 0);
});
}
@@ -103,7 +103,7 @@ public sealed class HighestValidationTests : IDisposable
{
// Calculate QuanTAlib Highest (Span API)
double[] qOutput = new double[sourceData.Length];
Highest.Calculate(sourceData.AsSpan(), qOutput.AsSpan(), period);
Highest.Batch(sourceData.AsSpan(), qOutput.AsSpan(), period);
// Calculate TA-Lib MAX
var retCode = TALib.Functions.Max<double>(sourceData, 0..^0, talibOutput, out var outRange, period);
+10 -3
View File
@@ -106,7 +106,7 @@ public sealed class Highest : AbstractBase
}
}
public static TSeries Calculate(TSeries source, int period)
public static TSeries Batch(TSeries source, int period)
{
var indicator = new Highest(period);
return indicator.Update(source);
@@ -115,7 +115,7 @@ public sealed class Highest : AbstractBase
/// <summary>
/// Calculates rolling maximum over a span of values.
/// </summary>
public static void Calculate(ReadOnlySpan<double> source, Span<double> output, int period)
public static void Batch(ReadOnlySpan<double> source, Span<double> output, int period)
{
if (source.Length == 0)
{
@@ -238,6 +238,13 @@ public sealed class Highest : AbstractBase
}
}
public static (TSeries Results, Highest Indicator) Calculate(TSeries source, int period)
{
var indicator = new Highest(period);
TSeries results = indicator.Update(source);
return (results, indicator);
}
public override void Reset()
{
_buffer.Clear();
@@ -245,4 +252,4 @@ public sealed class Highest : AbstractBase
_p_state = default;
Last = default;
}
}
}