mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-24 13:38:05 +00:00
sonar fixes
This commit is contained in:
@@ -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)),
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user