sonar fixes

This commit is contained in:
Miha Kralj
2024-11-05 15:51:29 -08:00
parent 2b5c89640d
commit 0bae9ce15b
19 changed files with 801 additions and 141 deletions
+2
View File
@@ -76,6 +76,8 @@ public class EventingTests
("Stddev", new Stddev(p), new Stddev(input, p)),
("Variance", new Variance(p), new Variance(input, p)),
("Zscore", new Zscore(p), new Zscore(input, p)),
("Beta", new Beta(p), new Beta(input, p)),
("Corr", new Corr(p), new Corr(input, p)),
// Volatility indicators (value-based)
("Hv", new Hv(p), new Hv(input, p)),
("Jvolty", new Jvolty(p), new Jvolty(input, p)),
+33
View File
@@ -26,6 +26,39 @@ public class StatisticsUpdateTests
return new TBar(DateTime.Now, open, high, low, close, 1000, IsNew);
}
[Fact]
public void Beta_Update()
{
var indicator = new Beta(period: 14);
TBar marketBar = GetRandomBar(true);
TBar assetBar = GetRandomBar(true);
double initialValue = indicator.Calc(marketBar, assetBar);
for (int i = 0; i < RandomUpdates; i++)
{
indicator.Calc(GetRandomBar(false), GetRandomBar(false));
}
double finalValue = indicator.Calc(new TBar(marketBar.Time, marketBar.Open, marketBar.High, marketBar.Low, marketBar.Close, marketBar.Volume, false),
new TBar(assetBar.Time, assetBar.Open, assetBar.High, assetBar.Low, assetBar.Close, assetBar.Volume, false));
Assert.Equal(initialValue, finalValue, precision);
}
[Fact]
public void Corr_Update()
{
var indicator = new Corr(period: 14);
double initialValue = indicator.Calc(new TValue(DateTime.Now, ReferenceValue, IsNew: true), new TValue(DateTime.Now, ReferenceValue, IsNew: true));
for (int i = 0; i < RandomUpdates; i++)
{
indicator.Calc(new TValue(DateTime.Now, GetRandomDouble(), IsNew: false), new TValue(DateTime.Now, GetRandomDouble(), IsNew: false));
}
double finalValue = indicator.Calc(new TValue(DateTime.Now, ReferenceValue, IsNew: false), new TValue(DateTime.Now, ReferenceValue, IsNew: false));
Assert.Equal(initialValue, finalValue, precision);
}
[Fact]
public void Curvature_Update()
{