mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-20 03:28:05 +00:00
normalization of methods
This commit is contained in:
@@ -207,7 +207,7 @@ public class LowestTests
|
||||
}
|
||||
|
||||
// Batch
|
||||
var batch = Lowest.Calculate(source, period);
|
||||
var batch = Lowest.Batch(source, period);
|
||||
|
||||
// Compare last values (after warmup)
|
||||
for (int i = period; i < source.Count; i++)
|
||||
@@ -226,12 +226,12 @@ public class LowestTests
|
||||
var source = bars.Close;
|
||||
|
||||
// TSeries batch
|
||||
var batchResult = Lowest.Calculate(source, period);
|
||||
var batchResult = Lowest.Batch(source, period);
|
||||
|
||||
// Span calculation
|
||||
var values = source.Values.ToArray();
|
||||
var output = new double[count];
|
||||
Lowest.Calculate(values, output, period);
|
||||
Lowest.Batch(values, output, period);
|
||||
|
||||
for (int i = 0; i < source.Count; i++)
|
||||
{
|
||||
@@ -245,21 +245,21 @@ public class LowestTests
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
{
|
||||
Span<double> output = stackalloc double[10];
|
||||
Lowest.Calculate(ReadOnlySpan<double>.Empty, output, 5);
|
||||
Lowest.Batch(ReadOnlySpan<double>.Empty, output, 5);
|
||||
});
|
||||
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
{
|
||||
ReadOnlySpan<double> source = stackalloc double[10];
|
||||
Span<double> output = stackalloc double[5];
|
||||
Lowest.Calculate(source, output, 5);
|
||||
Lowest.Batch(source, output, 5);
|
||||
});
|
||||
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
{
|
||||
ReadOnlySpan<double> source = stackalloc double[10];
|
||||
Span<double> output = stackalloc double[10];
|
||||
Lowest.Calculate(source, output, 0);
|
||||
Lowest.Batch(source, output, 0);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public sealed class LowestValidationTests : IDisposable
|
||||
{
|
||||
// Calculate QuanTAlib Lowest (Span API)
|
||||
double[] qOutput = new double[sourceData.Length];
|
||||
Lowest.Calculate(sourceData.AsSpan(), qOutput.AsSpan(), period);
|
||||
Lowest.Batch(sourceData.AsSpan(), qOutput.AsSpan(), period);
|
||||
|
||||
// Calculate TA-Lib MIN
|
||||
var retCode = TALib.Functions.Min<double>(sourceData, 0..^0, talibOutput, out var outRange, period);
|
||||
|
||||
@@ -106,7 +106,7 @@ public sealed class Lowest : AbstractBase
|
||||
}
|
||||
}
|
||||
|
||||
public static TSeries Calculate(TSeries source, int period)
|
||||
public static TSeries Batch(TSeries source, int period)
|
||||
{
|
||||
var indicator = new Lowest(period);
|
||||
return indicator.Update(source);
|
||||
@@ -115,7 +115,7 @@ public sealed class Lowest : AbstractBase
|
||||
/// <summary>
|
||||
/// Calculates rolling minimum 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)
|
||||
{
|
||||
@@ -217,6 +217,13 @@ public sealed class Lowest : AbstractBase
|
||||
}
|
||||
}
|
||||
|
||||
public static (TSeries Results, Lowest Indicator) Calculate(TSeries source, int period)
|
||||
{
|
||||
var indicator = new Lowest(period);
|
||||
TSeries results = indicator.Update(source);
|
||||
return (results, indicator);
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
_buffer.Clear();
|
||||
@@ -224,4 +231,4 @@ public sealed class Lowest : AbstractBase
|
||||
_p_state = default;
|
||||
Last = default;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user