mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-23 04:58:08 +00:00
normalization of methods
This commit is contained in:
@@ -134,7 +134,7 @@ public class AdlTests
|
||||
bars.Add(new TBar(time.AddMinutes(1), 10, 12, 8, 12, 200));
|
||||
bars.Add(new TBar(time.AddMinutes(2), 12, 12, 8, 8, 100));
|
||||
|
||||
var result = Adl.Calculate(bars);
|
||||
var result = Adl.Batch(bars);
|
||||
|
||||
Assert.Equal(3, result.Count);
|
||||
Assert.Equal(0, result[0].Value);
|
||||
@@ -151,7 +151,7 @@ public class AdlTests
|
||||
double[] volume = { 100, 200, 100 };
|
||||
double[] output = new double[3];
|
||||
|
||||
Adl.Calculate(high, low, close, volume, output);
|
||||
Adl.Batch(high, low, close, volume, output);
|
||||
|
||||
Assert.Equal(0, output[0]);
|
||||
Assert.Equal(200, output[1]);
|
||||
@@ -168,14 +168,14 @@ public class AdlTests
|
||||
double[] output = new double[2];
|
||||
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
Adl.Calculate(high, low, close, volume, output));
|
||||
Adl.Batch(high, low, close, volume, output));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Adl_Calculate_EmptySeries_ReturnsEmpty()
|
||||
{
|
||||
var bars = new TBarSeries();
|
||||
var result = Adl.Calculate(bars);
|
||||
var result = Adl.Batch(bars);
|
||||
Assert.Empty(result);
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public class AdlTests
|
||||
volume[i] = 10;
|
||||
}
|
||||
|
||||
Adl.Calculate(high, low, close, volume, output);
|
||||
Adl.Batch(high, low, close, volume, output);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
|
||||
+11
-4
@@ -121,7 +121,7 @@ public sealed class Adl : ITValuePublisher
|
||||
return new TSeries(t, v);
|
||||
}
|
||||
|
||||
public static TSeries Calculate(TBarSeries source)
|
||||
public static TSeries Batch(TBarSeries source)
|
||||
{
|
||||
if (source.Count == 0)
|
||||
{
|
||||
@@ -131,13 +131,13 @@ public sealed class Adl : ITValuePublisher
|
||||
var t = source.Open.Times.ToArray(); // Times are same for all series
|
||||
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)
|
||||
{
|
||||
@@ -195,4 +195,11 @@ public sealed class Adl : ITValuePublisher
|
||||
output[i] = sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static (TSeries Results, Adl Indicator) Calculate(TBarSeries source)
|
||||
{
|
||||
var indicator = new Adl();
|
||||
TSeries results = indicator.Update(source);
|
||||
return (results, indicator);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user