Bband, Ccv, Ce, Cv, Cvi, Ewma, Fcb, Gkv, Hlv

This commit is contained in:
Miha Kralj
2024-11-03 10:47:10 -08:00
parent 4b5724d5bc
commit caa0d31dbe
22 changed files with 1595 additions and 129 deletions
+25
View File
@@ -17,6 +17,15 @@ public class StatisticsUpdateTests
return (double)BitConverter.ToUInt64(bytes, 0) / ulong.MaxValue * 200 - 100; // Range: -100 to 100
}
private TBar GetRandomBar(bool IsNew)
{
double open = GetRandomDouble();
double high = open + Math.Abs(GetRandomDouble());
double low = open - Math.Abs(GetRandomDouble());
double close = low + (high - low) * GetRandomDouble();
return new TBar(DateTime.Now, open, high, low, close, 1000, IsNew);
}
[Fact]
public void Curvature_Update()
{
@@ -47,6 +56,22 @@ public class StatisticsUpdateTests
Assert.Equal(initialValue, finalValue, precision);
}
[Fact]
public void Hurst_Update()
{
var indicator = new Hurst(period: 100, minLength: 10);
TBar r = GetRandomBar(true);
double initialValue = indicator.Calc(r);
for (int i = 0; i < RandomUpdates; i++)
{
indicator.Calc(GetRandomBar(IsNew: false));
}
double finalValue = indicator.Calc(new TBar(r.Time, r.Open, r.High, r.Low, r.Close, r.Volume, IsNew: false));
Assert.Equal(initialValue, finalValue, precision);
}
[Fact]
public void Kurtosis_Update()
{