mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-23 21:18:04 +00:00
normalization of methods
This commit is contained in:
@@ -145,7 +145,7 @@ public class WadTests
|
||||
bars.Add(new TBar(time.AddMinutes(1), 100, 115, 92, 110, 2000));
|
||||
bars.Add(new TBar(time.AddMinutes(2), 110, 108, 102, 105, 1500));
|
||||
|
||||
var result = Wad.Calculate(bars);
|
||||
var result = Wad.Batch(bars);
|
||||
|
||||
Assert.Equal(3, result.Count);
|
||||
Assert.Equal(0, result[0].Value);
|
||||
@@ -162,7 +162,7 @@ public class WadTests
|
||||
double[] volume = { 1000, 2000, 1500 };
|
||||
double[] output = new double[3];
|
||||
|
||||
Wad.Calculate(high, low, close, volume, output);
|
||||
Wad.Batch(high, low, close, volume, output);
|
||||
|
||||
Assert.Equal(0, output[0]);
|
||||
Assert.Equal(36000, output[1]);
|
||||
@@ -179,14 +179,14 @@ public class WadTests
|
||||
double[] output = new double[2];
|
||||
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
Wad.Calculate(high, low, close, volume, output));
|
||||
Wad.Batch(high, low, close, volume, output));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Wad_Calculate_EmptySeries_ReturnsEmpty()
|
||||
{
|
||||
var bars = new TBarSeries();
|
||||
var result = Wad.Calculate(bars);
|
||||
var result = Wad.Batch(bars);
|
||||
Assert.Empty(result);
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ public class WadTests
|
||||
volume[i] = 100;
|
||||
}
|
||||
|
||||
Wad.Calculate(high, low, close, volume, output);
|
||||
Wad.Batch(high, low, close, volume, output);
|
||||
|
||||
// First bar should be 0
|
||||
Assert.Equal(0, output[0]);
|
||||
@@ -234,7 +234,7 @@ public class WadTests
|
||||
}
|
||||
|
||||
// Batch calculation
|
||||
var batchResult = Wad.Calculate(bars);
|
||||
var batchResult = Wad.Batch(bars);
|
||||
|
||||
// Streaming calculation
|
||||
var wad = new Wad();
|
||||
|
||||
@@ -13,7 +13,7 @@ public class WadValidationTests
|
||||
public void Wad_BatchMatchesStreaming()
|
||||
{
|
||||
// Batch calculation
|
||||
var batchResult = Wad.Calculate(_data.Bars);
|
||||
var batchResult = Wad.Batch(_data.Bars);
|
||||
|
||||
// Streaming calculation
|
||||
var wad = new Wad();
|
||||
@@ -37,7 +37,7 @@ public class WadValidationTests
|
||||
var spanOutput = new double[high.Length];
|
||||
|
||||
// Span calculation
|
||||
Wad.Calculate(high, low, close, volume, spanOutput);
|
||||
Wad.Batch(high, low, close, volume, spanOutput);
|
||||
|
||||
// Streaming calculation
|
||||
var wad = new Wad();
|
||||
|
||||
+10
-3
@@ -159,7 +159,7 @@ public sealed class Wad : ITValuePublisher
|
||||
return new TSeries(t, v);
|
||||
}
|
||||
|
||||
public static TSeries Calculate(TBarSeries source)
|
||||
public static TSeries Batch(TBarSeries source)
|
||||
{
|
||||
if (source.Count == 0)
|
||||
{
|
||||
@@ -169,13 +169,13 @@ public sealed class Wad : ITValuePublisher
|
||||
var t = source.Open.Times.ToArray();
|
||||
var v = new double[source.Count];
|
||||
|
||||
Calculate(source.High.Values, source.Low.Values, source.Close.Values, source.Volume.Values, v);
|
||||
Batch(source.High.Values, source.Low.Values, source.Close.Values, source.Volume.Values, v);
|
||||
|
||||
return new TSeries(t, v);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Calculate(ReadOnlySpan<double> high, ReadOnlySpan<double> low, ReadOnlySpan<double> close, ReadOnlySpan<double> volume, Span<double> output)
|
||||
public static void Batch(ReadOnlySpan<double> high, ReadOnlySpan<double> low, ReadOnlySpan<double> close, ReadOnlySpan<double> volume, Span<double> output)
|
||||
{
|
||||
if (high.Length != low.Length || high.Length != close.Length || high.Length != volume.Length || high.Length != output.Length)
|
||||
{
|
||||
@@ -225,4 +225,11 @@ public sealed class Wad : ITValuePublisher
|
||||
prevClose = c;
|
||||
}
|
||||
}
|
||||
|
||||
public static (TSeries Results, Wad Indicator) Calculate(TBarSeries source)
|
||||
{
|
||||
var indicator = new Wad();
|
||||
TSeries results = indicator.Update(source);
|
||||
return (results, indicator);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user