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
@@ -311,7 +311,7 @@ public class CviTests
var iterativeResult = cvi.Last.Value;
// Batch via static method
var batchResult = Cvi.Calculate(bars, 10, 10);
var batchResult = Cvi.Batch(bars, 10, 10);
Assert.Equal(iterativeResult, batchResult[batchResult.Count - 1].Value, 1e-8);
}
@@ -321,7 +321,7 @@ public class CviTests
{
var bars = GenerateTestData(100);
var result = Cvi.Calculate(bars, 14, 10);
var result = Cvi.Batch(bars, 14, 10);
Assert.Equal(100, result.Count);
Assert.True(double.IsFinite(result[result.Count - 1].Value));
@@ -336,10 +336,10 @@ public class CviTests
ts.Add(new TValue(DateTime.UtcNow.AddMinutes(i), 100 + i));
}
Assert.Throws<ArgumentException>(() => Cvi.Calculate(ts, 0, 10));
Assert.Throws<ArgumentException>(() => Cvi.Calculate(ts, -1, 10));
Assert.Throws<ArgumentException>(() => Cvi.Calculate(ts, 10, 0));
Assert.Throws<ArgumentException>(() => Cvi.Calculate(ts, 10, -1));
Assert.Throws<ArgumentException>(() => Cvi.Batch(ts, 0, 10));
Assert.Throws<ArgumentException>(() => Cvi.Batch(ts, -1, 10));
Assert.Throws<ArgumentException>(() => Cvi.Batch(ts, 10, 0));
Assert.Throws<ArgumentException>(() => Cvi.Batch(ts, 10, -1));
}
[Fact]
+1 -1
View File
@@ -196,7 +196,7 @@ public class CviValidationTests
}
// Batch calculation
var batchResult = Cvi.Calculate(bars, 10, 10);
var batchResult = Cvi.Batch(bars, 10, 10);
// Compare last values
Assert.Equal(batchResult.Last.Value, streamingCvi.Last.Value, 8);
+9 -2
View File
@@ -276,7 +276,7 @@ public sealed class Cvi : AbstractBase
/// <summary>
/// Calculates CVI for entire TBarSeries.
/// </summary>
public static TSeries Calculate(TBarSeries source, int rocLength = 10, int smoothLength = 10)
public static TSeries Batch(TBarSeries source, int rocLength = 10, int smoothLength = 10)
{
var cvi = new Cvi(rocLength, smoothLength);
return cvi.Update(source);
@@ -285,7 +285,7 @@ public sealed class Cvi : AbstractBase
/// <summary>
/// Calculates CVI for entire series (assumes values are pre-calculated ranges).
/// </summary>
public static TSeries Calculate(TSeries source, int rocLength = 10, int smoothLength = 10)
public static TSeries Batch(TSeries source, int rocLength = 10, int smoothLength = 10)
{
if (rocLength <= 0)
{
@@ -381,4 +381,11 @@ public sealed class Cvi : AbstractBase
output[i] = double.IsFinite(result) ? result : 0.0;
}
}
public static (TSeries Results, Cvi Indicator) Calculate(TBarSeries source, int rocLength = 10, int smoothLength = 10)
{
var indicator = new Cvi(rocLength, smoothLength);
TSeries results = indicator.Update(source);
return (results, indicator);
}
}