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:
@@ -48,10 +48,10 @@ public class MgdiTests
|
||||
var source = new double[10];
|
||||
var output = new double[10];
|
||||
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => Mgdi.Calculate(source, output, 14, double.NaN));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => Mgdi.Calculate(source, output, 14, double.PositiveInfinity));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => Mgdi.Calculate(source, output, 14, double.NegativeInfinity));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => Mgdi.Calculate(source, output, 14, 0));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => Mgdi.Calculate(source, output, 14, -1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => Mgdi.Batch(source, output, 14, double.NaN));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => Mgdi.Batch(source, output, 14, double.PositiveInfinity));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => Mgdi.Batch(source, output, 14, double.NegativeInfinity));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => Mgdi.Batch(source, output, 14, 0));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => Mgdi.Batch(source, output, 14, -1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public sealed class Mgdi : AbstractBase
|
||||
var tSpan = CollectionsMarshal.AsSpan(t);
|
||||
var vSpan = CollectionsMarshal.AsSpan(v);
|
||||
|
||||
Calculate(source.Values, vSpan, _period, _k);
|
||||
Batch(source.Values, vSpan, _period, _k);
|
||||
source.Times.CopyTo(tSpan);
|
||||
|
||||
// Restore state
|
||||
@@ -164,7 +164,7 @@ public sealed class Mgdi : AbstractBase
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Calculate(ReadOnlySpan<double> source, Span<double> output, int period = 14, double k = 0.6)
|
||||
public static void Batch(ReadOnlySpan<double> source, Span<double> output, int period = 14, double k = 0.6)
|
||||
{
|
||||
ArgumentOutOfRangeException.ThrowIfLessThan(period, 1);
|
||||
if (double.IsNaN(k) || double.IsInfinity(k) || k <= 0)
|
||||
@@ -229,6 +229,13 @@ public sealed class Mgdi : AbstractBase
|
||||
}
|
||||
}
|
||||
|
||||
public static (TSeries Results, Mgdi Indicator) Calculate(TSeries source, int period = 14, double k = 0.6)
|
||||
{
|
||||
var indicator = new Mgdi(period, k);
|
||||
TSeries results = indicator.Update(source);
|
||||
return (results, indicator);
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
Init();
|
||||
|
||||
Reference in New Issue
Block a user