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:
@@ -64,7 +64,7 @@ public sealed class ApoValidationTests : IDisposable
|
||||
|
||||
// 3. Span Mode
|
||||
double[] spanOutput = new double[input.Length];
|
||||
Apo.Calculate(input.AsSpan(), spanOutput.AsSpan(), fastPeriod, slowPeriod);
|
||||
Apo.Batch(input.AsSpan(), spanOutput.AsSpan(), fastPeriod, slowPeriod);
|
||||
ValidationHelper.VerifyData(spanOutput, output, outRange, lookback: slowPeriod - 1);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public sealed class ApoValidationTests : IDisposable
|
||||
|
||||
// 3. Span Mode
|
||||
double[] spanOutput = new double[input.Length];
|
||||
Apo.Calculate(input.AsSpan(), spanOutput.AsSpan(), fastPeriod, slowPeriod);
|
||||
Apo.Batch(input.AsSpan(), spanOutput.AsSpan(), fastPeriod, slowPeriod);
|
||||
ValidationHelper.VerifyData(spanOutput, output, lookback: 1);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public sealed class ApoValidationTests : IDisposable
|
||||
// 3. Span Mode
|
||||
double[] input = _testData.Data.Values.ToArray();
|
||||
double[] spanOutput = new double[input.Length];
|
||||
Apo.Calculate(input.AsSpan(), spanOutput.AsSpan(), fastPeriod, slowPeriod);
|
||||
Apo.Batch(input.AsSpan(), spanOutput.AsSpan(), fastPeriod, slowPeriod);
|
||||
ValidationHelper.VerifyData(spanOutput, output, lookback: 0, tolerance: ValidationHelper.OoplesTolerance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ public sealed class Apo : ITValuePublisher, IDisposable
|
||||
/// <param name="fastPeriod">Fast EMA period (default 12)</param>
|
||||
/// <param name="slowPeriod">Slow EMA period (default 26)</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Calculate(ReadOnlySpan<double> source, Span<double> output, int fastPeriod = 12, int slowPeriod = 26)
|
||||
public static void Batch(ReadOnlySpan<double> source, Span<double> output, int fastPeriod = 12, int slowPeriod = 26)
|
||||
{
|
||||
if (source.Length != output.Length)
|
||||
{
|
||||
@@ -198,6 +198,13 @@ public sealed class Apo : ITValuePublisher, IDisposable
|
||||
SimdExtensions.Subtract(fastEma, slowEma, output);
|
||||
}
|
||||
|
||||
public static (TSeries Results, Apo Indicator) Calculate(TSeries source, int fastPeriod = 12, int slowPeriod = 26)
|
||||
{
|
||||
var indicator = new Apo(fastPeriod, slowPeriod);
|
||||
TSeries results = indicator.Update(source);
|
||||
return (results, indicator);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes resources and unsubscribes from the source publisher.
|
||||
/// </summary>
|
||||
@@ -215,4 +222,4 @@ public sealed class Apo : ITValuePublisher, IDisposable
|
||||
_source = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user