normalization of methods

This commit is contained in:
Miha Kralj
2026-02-10 21:33:16 -08:00
parent 915d7a007b
commit 6d6259a47d
527 changed files with 10525 additions and 2123 deletions
+6 -6
View File
@@ -225,7 +225,7 @@ public class EfiTests
bars.Add(new TBar(time.AddMinutes(1), 10, 12, 8, 12, 200));
bars.Add(new TBar(time.AddMinutes(2), 12, 12, 8, 8, 100));
var result = Efi.Calculate(bars, 3);
var result = Efi.Batch(bars, 3);
Assert.Equal(3, result.Count);
}
@@ -240,7 +240,7 @@ public class EfiTests
double[] volume = { 100, 200, 100 };
double[] output = new double[3];
Efi.Calculate(close, volume, output, 3);
Efi.Batch(close, volume, output, 3);
// Bar 0: raw force = 0, result = 0
Assert.Equal(0, output[0]);
@@ -258,7 +258,7 @@ public class EfiTests
double[] output = new double[2];
Assert.Throws<ArgumentException>(() =>
Efi.Calculate(close, volume, output, 3));
Efi.Batch(close, volume, output, 3));
}
[Fact]
@@ -269,14 +269,14 @@ public class EfiTests
double[] output = new double[1];
Assert.Throws<ArgumentException>(() =>
Efi.Calculate(close, volume, output, 0));
Efi.Batch(close, volume, output, 0));
}
[Fact]
public void Efi_Calculate_EmptySeries_ReturnsEmpty()
{
var bars = new TBarSeries();
var result = Efi.Calculate(bars);
var result = Efi.Batch(bars);
Assert.Empty(result);
}
@@ -300,7 +300,7 @@ public class EfiTests
}
// Batch
var batchResult = Efi.Calculate(bars, 13);
var batchResult = Efi.Batch(bars, 13);
// Compare all values
for (int i = 0; i < 100; i++)
+2 -2
View File
@@ -57,7 +57,7 @@ public class EfiValidationTests
}
// Batch
var batchResult = Efi.Calculate(_data.Bars, DefaultPeriod);
var batchResult = Efi.Batch(_data.Bars, DefaultPeriod);
var batchValues = batchResult.Values.ToArray();
ValidationHelper.VerifyData(streamingValues.ToArray(), batchValues, 0, 100, 1e-12);
@@ -79,7 +79,7 @@ public class EfiValidationTests
var volume = _data.Bars.Volume.Values.ToArray();
var spanValues = new double[close.Length];
Efi.Calculate(close, volume, spanValues, DefaultPeriod);
Efi.Batch(close, volume, spanValues, DefaultPeriod);
ValidationHelper.VerifyData(streamingValues.ToArray(), spanValues, 0, 100, 1e-12);
}
+10 -3
View File
@@ -225,7 +225,7 @@ public sealed class Efi : ITValuePublisher
return new TSeries(t, v);
}
public static TSeries Calculate(TBarSeries source, int period = 13)
public static TSeries Batch(TBarSeries source, int period = 13)
{
if (source.Count == 0)
{
@@ -235,13 +235,13 @@ public sealed class Efi : ITValuePublisher
var t = source.Open.Times.ToArray();
var v = new double[source.Count];
Calculate(source.Close.Values, source.Volume.Values, v, period);
Batch(source.Close.Values, source.Volume.Values, v, period);
return new TSeries(t, v);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Calculate(ReadOnlySpan<double> close, ReadOnlySpan<double> volume, Span<double> output, int period = 13)
public static void Batch(ReadOnlySpan<double> close, ReadOnlySpan<double> volume, Span<double> output, int period = 13)
{
if (close.Length != volume.Length)
{
@@ -298,4 +298,11 @@ public sealed class Efi : ITValuePublisher
}
}
}
public static (TSeries Results, Efi Indicator) Calculate(TBarSeries source, int period = 13)
{
var indicator = new Efi(period);
TSeries results = indicator.Update(source);
return (results, indicator);
}
}