mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-25 22:08:05 +00:00
normalization of methods
This commit is contained in:
@@ -37,12 +37,12 @@ public class NotchTests
|
||||
var data = _gbm.Fetch(100, DateTime.UtcNow.Ticks, TimeSpan.FromMinutes(1));
|
||||
var series = data.Close;
|
||||
|
||||
// 1. Static Calculate (TSeries)
|
||||
var staticResult = Notch.Calculate(series, period, q);
|
||||
// 1. Static Batch(TSeries)
|
||||
var staticResult = Notch.Batch(series, period, q);
|
||||
|
||||
// 2. Static Calculate (Span)
|
||||
// 2. Static Batch(Span)
|
||||
double[] spanResult = new double[series.Count];
|
||||
Notch.Calculate(series.Values, spanResult.AsSpan(), period, q);
|
||||
Notch.Batch(series.Values, spanResult.AsSpan(), period, q);
|
||||
|
||||
// 3. Instance Update (TSeries)
|
||||
var instance = new Notch(period, q);
|
||||
|
||||
@@ -138,7 +138,7 @@ public sealed class Notch : AbstractBase
|
||||
ReadOnlySpan<double> srcSpan = source.Values;
|
||||
double[] outArray = new double[srcSpan.Length];
|
||||
|
||||
Calculate(srcSpan, outArray.AsSpan(), NotchFreq, Bandwidth);
|
||||
Batch(srcSpan, outArray.AsSpan(), NotchFreq, Bandwidth);
|
||||
|
||||
for (int i = 0; i < outArray.Length; i++)
|
||||
{
|
||||
@@ -159,7 +159,7 @@ public sealed class Notch : AbstractBase
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void Calculate(ReadOnlySpan<double> source, Span<double> output, int period, double q = 1.0)
|
||||
public static void Batch(ReadOnlySpan<double> source, Span<double> output, int period, double q = 1.0)
|
||||
{
|
||||
if (source.Length != output.Length)
|
||||
{
|
||||
@@ -210,13 +210,13 @@ public sealed class Notch : AbstractBase
|
||||
}
|
||||
}
|
||||
|
||||
public static TSeries Calculate(TSeries source, int period, double q = 1.0)
|
||||
public static TSeries Batch(TSeries source, int period, double q = 1.0)
|
||||
{
|
||||
var result = new TSeries();
|
||||
ReadOnlySpan<double> srcSpan = source.Values;
|
||||
double[] outArray = new double[srcSpan.Length];
|
||||
|
||||
Calculate(srcSpan, outArray.AsSpan(), period, q);
|
||||
Batch(srcSpan, outArray.AsSpan(), period, q);
|
||||
|
||||
for (int i = 0; i < outArray.Length; i++)
|
||||
{
|
||||
@@ -226,6 +226,13 @@ public sealed class Notch : AbstractBase
|
||||
return result;
|
||||
}
|
||||
|
||||
public static (TSeries Results, Notch Indicator) Calculate(TSeries source, int period, double q = 1.0)
|
||||
{
|
||||
var indicator = new Notch(period, q);
|
||||
TSeries results = indicator.Update(source);
|
||||
return (results, indicator);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unsubscribes from the source publisher if one was provided during construction.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user