mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-21 12:08:05 +00:00
normalization of methods
This commit is contained in:
@@ -204,7 +204,7 @@ public class VaTests
|
||||
}
|
||||
|
||||
// Batch
|
||||
var batchResult = Va.Calculate(bars);
|
||||
var batchResult = Va.Batch(bars);
|
||||
|
||||
Assert.Equal(bars.Count, batchResult.Count);
|
||||
for (int i = 0; i < bars.Count; i++)
|
||||
@@ -243,7 +243,7 @@ public class VaTests
|
||||
|
||||
// Span
|
||||
var output = new double[count];
|
||||
Va.Calculate(high, low, close, volume, output);
|
||||
Va.Batch(high, low, close, volume, output);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
@@ -260,7 +260,7 @@ public class VaTests
|
||||
var volume = new double[99]; // Different length
|
||||
var output = new double[100];
|
||||
|
||||
Assert.Throws<ArgumentException>(() => Va.Calculate(high, low, close, volume, output));
|
||||
Assert.Throws<ArgumentException>(() => Va.Batch(high, low, close, volume, output));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -272,7 +272,7 @@ public class VaTests
|
||||
var volume = Array.Empty<double>();
|
||||
var output = Array.Empty<double>();
|
||||
|
||||
Va.Calculate(high, low, close, volume, output);
|
||||
Va.Batch(high, low, close, volume, output);
|
||||
|
||||
Assert.Empty(output);
|
||||
}
|
||||
|
||||
+10
-3
@@ -184,7 +184,7 @@ public sealed class Va : ITValuePublisher
|
||||
/// </summary>
|
||||
/// <param name="source">The bar series.</param>
|
||||
/// <returns>The result series.</returns>
|
||||
public static TSeries Calculate(TBarSeries source)
|
||||
public static TSeries Batch(TBarSeries source)
|
||||
{
|
||||
if (source.Count == 0)
|
||||
{
|
||||
@@ -194,7 +194,7 @@ public sealed class Va : 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);
|
||||
}
|
||||
@@ -209,7 +209,7 @@ public sealed class Va : ITValuePublisher
|
||||
/// <param name="output">The output VA span.</param>
|
||||
/// <exception cref="ArgumentException">Thrown when span lengths don't match.</exception>
|
||||
[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)
|
||||
{
|
||||
@@ -266,4 +266,11 @@ public sealed class Va : ITValuePublisher
|
||||
output[i] = va;
|
||||
}
|
||||
}
|
||||
|
||||
public static (TSeries Results, Va Indicator) Calculate(TBarSeries source)
|
||||
{
|
||||
var indicator = new Va();
|
||||
TSeries results = indicator.Update(source);
|
||||
return (results, indicator);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user