mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-23 13:08:04 +00:00
feat(tests): enhance tests with GBM for noise generation and improve tolerance for MAMA validation
feat(trends): implement IDisposable in Bessel and Conv classes to manage event subscriptions fix(trends): add validation for period and parameters in Kama and MGDI calculations fix(trends): clamp logarithmic calculations in JMA to avoid -Infinity
This commit is contained in:
@@ -12,13 +12,14 @@ public class CovarianceSimdTests
|
||||
// Arrange
|
||||
int count = 1000; // > 256 to trigger SIMD
|
||||
int period = 20;
|
||||
var r = new Random(42);
|
||||
var gbmX = new GBM(startPrice: 100, mu: 0.05, sigma: 0.2, seed: 42);
|
||||
var gbmY = new GBM(startPrice: 100, mu: 0.05, sigma: 0.2, seed: 123);
|
||||
var dataX = new double[count];
|
||||
var dataY = new double[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
dataX[i] = r.NextDouble() * 100;
|
||||
dataY[i] = r.NextDouble() * 100;
|
||||
dataX[i] = gbmX.Next().Close;
|
||||
dataY[i] = gbmY.Next().Close;
|
||||
}
|
||||
|
||||
var sourceX = new TSeries();
|
||||
|
||||
@@ -11,14 +11,15 @@ public class CovarianceValidationTests
|
||||
// Arrange
|
||||
int period = 10;
|
||||
var cov = new Covariance(period, isPopulation: false);
|
||||
var r = new Random(123);
|
||||
var gbmX = new GBM(startPrice: 100, mu: 0.05, sigma: 0.2, seed: 123);
|
||||
var gbmY = new GBM(startPrice: 100, mu: 0.05, sigma: 0.2, seed: 456);
|
||||
|
||||
double[] x = new double[100];
|
||||
double[] y = new double[100];
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
x[i] = r.NextDouble() * 100;
|
||||
y[i] = r.NextDouble() * 100;
|
||||
x[i] = gbmX.Next().Close;
|
||||
y[i] = gbmY.Next().Close;
|
||||
cov.Update(x[i], y[i]);
|
||||
|
||||
if (i >= period - 1)
|
||||
@@ -52,14 +53,15 @@ public class CovarianceValidationTests
|
||||
// Arrange
|
||||
int period = 10;
|
||||
var cov = new Covariance(period, isPopulation: true);
|
||||
var r = new Random(456);
|
||||
var gbmX = new GBM(startPrice: 100, mu: 0.05, sigma: 0.2, seed: 456);
|
||||
var gbmY = new GBM(startPrice: 100, mu: 0.05, sigma: 0.2, seed: 789);
|
||||
|
||||
double[] x = new double[100];
|
||||
double[] y = new double[100];
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
x[i] = r.NextDouble() * 100;
|
||||
y[i] = r.NextDouble() * 100;
|
||||
x[i] = gbmX.Next().Close;
|
||||
y[i] = gbmY.Next().Close;
|
||||
cov.Update(x[i], y[i]);
|
||||
|
||||
if (i >= period - 1)
|
||||
|
||||
Reference in New Issue
Block a user