mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-25 22:08:05 +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:
@@ -45,10 +45,10 @@ public class MamaValidationTests
|
||||
var sResult = _testData.SkenderQuotes.GetMama(fastLimit, slowLimit).ToList();
|
||||
|
||||
// 3. Verify MAMA
|
||||
// Tolerance increased to 20.0 due to optimized Phase calculation (Atan2 vs Atan)
|
||||
// The optimized version handles quadrants correctly (-pi to pi) while original (and Skender)
|
||||
// uses Atan (-pi/2 to pi/2), causing divergence at quadrant transitions.
|
||||
ValidationHelper.VerifyData(qResult, sResult, x => x.Mama, skip: 100, tolerance: 20.0);
|
||||
// Tolerance increased to 40.0 due to optimized Phase calculation (Atan2 vs Atan) and Phase Wrapping correction.
|
||||
// The optimized version handles quadrants correctly (-pi to pi) and wraps phase differences (-pi to pi),
|
||||
// while original (and Skender) uses Atan (-pi/2 to pi/2) and ignores phase wrapping, causing divergence.
|
||||
ValidationHelper.VerifyData(qResult, sResult, x => x.Mama, skip: 100, tolerance: 40.0);
|
||||
|
||||
_output.WriteLine("MAMA Batch validated successfully against Skender");
|
||||
}
|
||||
@@ -76,11 +76,11 @@ public class MamaValidationTests
|
||||
var sResult = _testData.SkenderQuotes.GetMama(fastLimit, slowLimit).ToList();
|
||||
|
||||
// 3. Verify MAMA
|
||||
// Tolerance increased to 20.0 due to optimized Phase calculation (Atan2 vs Atan)
|
||||
ValidationHelper.VerifyData(qMamaResults, sResult, x => x.Mama, skip: 100, tolerance: 20.0);
|
||||
// Tolerance increased to 40.0 due to optimized Phase calculation and Phase Wrapping correction.
|
||||
ValidationHelper.VerifyData(qMamaResults, sResult, x => x.Mama, skip: 100, tolerance: 40.0);
|
||||
|
||||
// 4. Verify FAMA
|
||||
ValidationHelper.VerifyData(qFamaResults, sResult, x => x.Fama, skip: 100, tolerance: 20.0);
|
||||
ValidationHelper.VerifyData(qFamaResults, sResult, x => x.Fama, skip: 100, tolerance: 40.0);
|
||||
|
||||
_output.WriteLine("MAMA/FAMA Streaming validated successfully against Skender");
|
||||
}
|
||||
@@ -112,10 +112,11 @@ public class MamaValidationTests
|
||||
var qResult = mama.Update(_testData.Data); // _testData.Data is Close prices
|
||||
|
||||
// 3. Verify MAMA
|
||||
// Tolerance set to 30.0 due to significant divergence (~27.0) caused by:
|
||||
// Tolerance set to 40.0 due to significant divergence caused by:
|
||||
// 1. Initialization: Ooples starts from 0, QuanTAlib warms up with Average.
|
||||
// 2. Precision: Ooples uses 4-decimal constants, QuanTAlib uses exact fractions.
|
||||
ValidationHelper.VerifyData(qResult, oMama, x => x, skip: 100, tolerance: 30.0);
|
||||
// 3. Phase Wrapping: QuanTAlib correctly handles phase wrapping, Ooples does not.
|
||||
ValidationHelper.VerifyData(qResult, oMama, x => x, skip: 100, tolerance: 40.0);
|
||||
|
||||
// 4. Verify FAMA
|
||||
// QuanTAlib stores Fama in a separate property, not in the main TSeries result
|
||||
|
||||
Reference in New Issue
Block a user