mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-22 20:48:04 +00:00
normalization of methods
This commit is contained in:
@@ -265,7 +265,7 @@ public class ObvTests
|
||||
}
|
||||
|
||||
// Batch
|
||||
var batchResult = Obv.Calculate(bars);
|
||||
var batchResult = Obv.Batch(bars);
|
||||
|
||||
Assert.Equal(bars.Count, batchResult.Count);
|
||||
for (int i = 0; i < bars.Count; i++)
|
||||
@@ -298,7 +298,7 @@ public class ObvTests
|
||||
var volume = bars.Volume.Values.ToArray();
|
||||
var output = new double[bars.Count];
|
||||
|
||||
Obv.Calculate(close, volume, output);
|
||||
Obv.Batch(close, volume, output);
|
||||
|
||||
for (int i = 0; i < bars.Count; i++)
|
||||
{
|
||||
@@ -313,7 +313,7 @@ public class ObvTests
|
||||
var volume = new double[99]; // Different length
|
||||
var output = new double[100];
|
||||
|
||||
Assert.Throws<ArgumentException>(() => Obv.Calculate(close, volume, output));
|
||||
Assert.Throws<ArgumentException>(() => Obv.Batch(close, volume, output));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -323,7 +323,7 @@ public class ObvTests
|
||||
var volume = Array.Empty<double>();
|
||||
var output = Array.Empty<double>();
|
||||
|
||||
Obv.Calculate(close, volume, output);
|
||||
Obv.Batch(close, volume, output);
|
||||
|
||||
Assert.Empty(output);
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class ObvValidationTests
|
||||
}
|
||||
|
||||
// Batch
|
||||
var batchResult = Obv.Calculate(_data.Bars);
|
||||
var batchResult = Obv.Batch(_data.Bars);
|
||||
var batchValues = batchResult.Values.ToArray();
|
||||
|
||||
ValidationHelper.VerifyData(streamingValues.ToArray(), batchValues, 0, 100, 1e-9);
|
||||
@@ -155,7 +155,7 @@ public class ObvValidationTests
|
||||
var volume = _data.Bars.Volume.Values.ToArray();
|
||||
var spanOutput = new double[close.Length];
|
||||
|
||||
Obv.Calculate(close, volume, spanOutput);
|
||||
Obv.Batch(close, volume, spanOutput);
|
||||
|
||||
ValidationHelper.VerifyData(streamingValues.ToArray(), spanOutput, 0, 100, 1e-9);
|
||||
}
|
||||
|
||||
+10
-3
@@ -175,7 +175,7 @@ public sealed class Obv : ITValuePublisher
|
||||
return new TSeries(t, v);
|
||||
}
|
||||
|
||||
public static TSeries Calculate(TBarSeries source)
|
||||
public static TSeries Batch(TBarSeries source)
|
||||
{
|
||||
if (source.Count == 0)
|
||||
{
|
||||
@@ -185,13 +185,13 @@ public sealed class Obv : ITValuePublisher
|
||||
var t = source.Open.Times.ToArray();
|
||||
var v = new double[source.Count];
|
||||
|
||||
Calculate(source.Close.Values, source.Volume.Values, v);
|
||||
Batch(source.Close.Values, source.Volume.Values, v);
|
||||
|
||||
return new TSeries(t, v);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Calculate(ReadOnlySpan<double> close, ReadOnlySpan<double> volume, Span<double> output)
|
||||
public static void Batch(ReadOnlySpan<double> close, ReadOnlySpan<double> volume, Span<double> output)
|
||||
{
|
||||
if (close.Length != volume.Length)
|
||||
{
|
||||
@@ -243,4 +243,11 @@ public sealed class Obv : ITValuePublisher
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static (TSeries Results, Obv Indicator) Calculate(TBarSeries source)
|
||||
{
|
||||
var indicator = new Obv();
|
||||
TSeries results = indicator.Update(source);
|
||||
return (results, indicator);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user