mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-25 13:58:04 +00:00
normalization of methods
This commit is contained in:
@@ -161,7 +161,7 @@ public class LsmaTests
|
||||
values[i] = bar.Close;
|
||||
}
|
||||
|
||||
Lsma.Calculate(values, output, period);
|
||||
Lsma.Batch(values, output, period);
|
||||
|
||||
var lsma = new Lsma(period);
|
||||
for (int i = 0; i < count; i++)
|
||||
|
||||
@@ -67,7 +67,7 @@ public class LsmaValidationTests
|
||||
{
|
||||
// Calculate QuanTAlib LSMA (Span API)
|
||||
double[] qOutput = new double[_testData.RawData.Length];
|
||||
global::QuanTAlib.Lsma.Calculate(_testData.RawData.Span, qOutput.AsSpan(), period);
|
||||
global::QuanTAlib.Lsma.Batch(_testData.RawData.Span, qOutput.AsSpan(), period);
|
||||
|
||||
// Calculate Skender EPMA
|
||||
var sResult = _testData.SkenderQuotes.GetEpma(period).ToList();
|
||||
|
||||
@@ -221,7 +221,7 @@ public sealed class Lsma : AbstractBase
|
||||
var vSpan = CollectionsMarshal.AsSpan(v);
|
||||
|
||||
double initialLastValid = _state.LastValidValue;
|
||||
Calculate(source.Values, vSpan, _period, _offset, initialLastValid);
|
||||
Batch(source.Values, vSpan, _period, _offset, initialLastValid);
|
||||
source.Times.CopyTo(tSpan);
|
||||
|
||||
// Restore state
|
||||
@@ -282,7 +282,7 @@ public sealed class Lsma : AbstractBase
|
||||
/// Zero-allocation method for maximum performance.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Calculate(ReadOnlySpan<double> source, Span<double> output, int period, int offset = 0, double initialLastValid = double.NaN)
|
||||
public static void Batch(ReadOnlySpan<double> source, Span<double> output, int period, int offset = 0, double initialLastValid = double.NaN)
|
||||
{
|
||||
if (source.Length != output.Length)
|
||||
{
|
||||
@@ -395,6 +395,13 @@ public sealed class Lsma : AbstractBase
|
||||
}
|
||||
}
|
||||
|
||||
public static (TSeries Results, Lsma Indicator) Calculate(TSeries source, int period, int offset = 0)
|
||||
{
|
||||
var indicator = new Lsma(period, offset);
|
||||
TSeries results = indicator.Update(source);
|
||||
return (results, indicator);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the LSMA state.
|
||||
/// </summary>
|
||||
@@ -422,4 +429,4 @@ public sealed class Lsma : AbstractBase
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user