mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-20 03:28:05 +00:00
Enhance validation tests for various indicators with external library comparisons
- Added detailed comments explaining the validation limitations for MMA and ZLEMA due to differences in algorithm implementations. - Implemented validation tests for True Range against TALib and Tulip, ensuring directional agreement. - Updated Ulcer Index validation to clarify differences in algorithmic approaches between QuanTAlib and Skender. - Enhanced Ease of Movement tests to verify directional agreement with Tulip's EMV, noting differences in volume scaling. - Expanded Klinger Volume Oscillator tests to validate against Skender and Tulip, focusing on directional agreement across multiple period configurations. - Improved Negative Volume Index tests to compare percentage changes with Tulip, addressing differences in starting values. - Updated Positive Volume Index tests to validate against Tulip, emphasizing percentage change comparisons. - Enhanced Williams Accumulation/Distribution tests to verify directional agreement with Tulip, highlighting formula differences.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Skender.Stock.Indicators;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace QuanTAlib.Tests;
|
||||
@@ -512,4 +513,66 @@ public sealed class MaenvValidationTests : IDisposable
|
||||
|
||||
_output.WriteLine("Maenv SMA ring buffer O(1) validated");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_Skender_SMA_Centerline()
|
||||
{
|
||||
// Skender GetMaEnvelopes(lookbackPeriods, percentOffset, MaType.SMA)
|
||||
// QuanTAlib Maenv(period, percentage, MaenvType.SMA)
|
||||
// Both compute: Middle = SMA(Close), Upper = Middle + Middle*pct/100, Lower = Middle - Middle*pct/100
|
||||
// For SMA type, results should match exactly.
|
||||
|
||||
int[] periods = { 5, 10, 20, 50 };
|
||||
double percentage = 2.5;
|
||||
|
||||
foreach (var period in periods)
|
||||
{
|
||||
var (qMiddle, _, _) = Maenv.Batch(_testData.Data, period, percentage, MaenvType.SMA);
|
||||
|
||||
var sResult = _testData.SkenderQuotes
|
||||
.GetMaEnvelopes(period, percentage, MaType.SMA)
|
||||
.ToList();
|
||||
|
||||
ValidationHelper.VerifyData(qMiddle, sResult, s => s.Centerline);
|
||||
}
|
||||
_output.WriteLine("Maenv SMA centerline validated against Skender for all periods");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_Skender_SMA_UpperEnvelope()
|
||||
{
|
||||
int[] periods = { 5, 10, 20, 50 };
|
||||
double percentage = 2.5;
|
||||
|
||||
foreach (var period in periods)
|
||||
{
|
||||
var (_, qUpper, _) = Maenv.Batch(_testData.Data, period, percentage, MaenvType.SMA);
|
||||
|
||||
var sResult = _testData.SkenderQuotes
|
||||
.GetMaEnvelopes(period, percentage, MaType.SMA)
|
||||
.ToList();
|
||||
|
||||
ValidationHelper.VerifyData(qUpper, sResult, s => s.UpperEnvelope);
|
||||
}
|
||||
_output.WriteLine("Maenv SMA upper envelope validated against Skender for all periods");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_Skender_SMA_LowerEnvelope()
|
||||
{
|
||||
int[] periods = { 5, 10, 20, 50 };
|
||||
double percentage = 2.5;
|
||||
|
||||
foreach (var period in periods)
|
||||
{
|
||||
var (_, _, qLower) = Maenv.Batch(_testData.Data, period, percentage, MaenvType.SMA);
|
||||
|
||||
var sResult = _testData.SkenderQuotes
|
||||
.GetMaEnvelopes(period, percentage, MaType.SMA)
|
||||
.ToList();
|
||||
|
||||
ValidationHelper.VerifyData(qLower, sResult, s => s.LowerEnvelope);
|
||||
}
|
||||
_output.WriteLine("Maenv SMA lower envelope validated against Skender for all periods");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user