mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-26 06:18:05 +00:00
normalization of methods
This commit is contained in:
@@ -68,7 +68,7 @@ public class HpTests
|
||||
var tseriesResult = hp.Update(source);
|
||||
var spanOutput = new double[source.Count];
|
||||
|
||||
Hp.Calculate(source.Values, spanOutput, 1600);
|
||||
Hp.Batch(source.Values, spanOutput, 1600);
|
||||
|
||||
for (int i = 0; i < source.Count; i++)
|
||||
{
|
||||
@@ -116,6 +116,6 @@ public class HpTests
|
||||
{
|
||||
double[] src = new double[10];
|
||||
double[] dst = new double[5];
|
||||
Assert.Throws<ArgumentException>(() => Hp.Calculate(src, dst, 1600));
|
||||
Assert.Throws<ArgumentException>(() => Hp.Batch(src, dst, 1600));
|
||||
}
|
||||
}
|
||||
|
||||
+15
-3
@@ -165,7 +165,7 @@ public sealed class Hp : AbstractBase
|
||||
}
|
||||
|
||||
var resultValues = new double[source.Count];
|
||||
Calculate(source.Values, resultValues, Lambda);
|
||||
Batch(source.Values, resultValues, Lambda);
|
||||
|
||||
var result = new TSeries();
|
||||
var times = source.Times;
|
||||
@@ -196,10 +196,16 @@ public sealed class Hp : AbstractBase
|
||||
return result;
|
||||
}
|
||||
|
||||
public static TSeries Batch(TSeries source, double lambda = 1600.0)
|
||||
{
|
||||
var indicator = new Hp(lambda);
|
||||
return indicator.Update(source);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Static calculation of HP Filter on a span.
|
||||
/// </summary>
|
||||
public static void Calculate(ReadOnlySpan<double> source, Span<double> output, double lambda)
|
||||
public static void Batch(ReadOnlySpan<double> source, Span<double> output, double lambda)
|
||||
{
|
||||
if (source.Length != output.Length)
|
||||
{
|
||||
@@ -236,6 +242,12 @@ public sealed class Hp : AbstractBase
|
||||
prevTrend = val;
|
||||
}
|
||||
}
|
||||
public static (TSeries Results, Hp Indicator) Calculate(TSeries source, double lambda = 1600.0)
|
||||
{
|
||||
var indicator = new Hp(lambda);
|
||||
TSeries results = indicator.Update(source);
|
||||
return (results, indicator);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unsubscribes from the source publisher if one was provided during construction.
|
||||
@@ -248,4 +260,4 @@ public sealed class Hp : AbstractBase
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user