mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-21 12:08:05 +00:00
test: setup common stability and robustness properties tracking
This commit is contained in:
@@ -197,4 +197,4 @@ public sealed class AcValidationTests
|
||||
int finiteCount = values.Count(v => double.IsFinite(v));
|
||||
Assert.True(finiteCount > 100, $"Expected >100 finite values, got {finiteCount}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,13 @@ namespace QuanTAlib;
|
||||
/// AO = SMA(Median Price, fastPeriod) - SMA(Median Price, slowPeriod)
|
||||
/// AC = AO - SMA(AO, acPeriod)
|
||||
///
|
||||
/// Design note: Ac implements <see cref="ITValuePublisher"/> directly rather than inheriting
|
||||
/// from AbstractBase. This is intentional: Ac is an OHLC-based indicator whose primary input
|
||||
/// is a <see cref="TBar"/> (requiring High and Low), not a single <see cref="TValue"/>.
|
||||
/// AbstractBase's contract (Update(TValue), Prime(ReadOnlySpan<double>)) does not fit
|
||||
/// OHLC indicators. The practical entry points are Update(TBar) and Prime(TBarSeries).
|
||||
/// If a future TBarIndicatorBase is introduced, Ac would be a candidate to migrate.
|
||||
///
|
||||
/// Sources:
|
||||
/// https://www.investopedia.com/terms/a/accelerationdeceleration-indicator.asp
|
||||
/// https://www.tradingview.com/support/solutions/43000501837-accelerator-oscillator-ac/
|
||||
|
||||
@@ -16,6 +16,13 @@ namespace QuanTAlib;
|
||||
/// Median Price = (High + Low) / 2
|
||||
/// AO = SMA(Median Price, 5) - SMA(Median Price, 34)
|
||||
///
|
||||
/// Design note: Ao implements <see cref="ITValuePublisher"/> directly rather than inheriting
|
||||
/// from AbstractBase. This is intentional: Ao is an OHLC-based indicator whose primary input
|
||||
/// is a <see cref="TBar"/> (requiring High and Low), not a single <see cref="TValue"/>.
|
||||
/// AbstractBase's contract (Update(TValue), Prime(ReadOnlySpan<double>)) does not fit
|
||||
/// OHLC indicators. The practical entry points are Update(TBar) and Prime(TBarSeries).
|
||||
/// If a future TBarIndicatorBase is introduced, Ao would be a candidate to migrate.
|
||||
///
|
||||
/// Sources:
|
||||
/// https://www.investopedia.com/terms/a/awesomeoscillator.asp
|
||||
/// https://www.tradingview.com/support/solutions/43000501826-awesome-oscillator-ao/
|
||||
|
||||
@@ -43,8 +43,8 @@ public sealed class ApoValidationTests : IDisposable
|
||||
double[] input = _testData.Data.Values.ToArray();
|
||||
double[] output = new double[input.Length];
|
||||
|
||||
// TA-Lib APO: double[] inReal, int optInFastPeriod, int optInSlowPeriod, int optInMAType
|
||||
// MAType 1 = EMA
|
||||
// TA-Lib APO: double[] inReal, int optInFastPeriod, int optInSlowPeriod, int optInTALib.Core.MAType
|
||||
// TALib.Core.MAType 1 = EMA
|
||||
var retCode = TALib.Functions.Apo<double>(input, 0..^0, output, out var outRange, fastPeriod, slowPeriod, TALib.Core.MAType.Ema);
|
||||
Assert.Equal(TALib.Core.RetCode.Success, retCode);
|
||||
|
||||
|
||||
@@ -308,4 +308,4 @@ public sealed class DemValidationTests(ITestOutputHelper output)
|
||||
int finiteCount = values.Count(v => double.IsFinite(v));
|
||||
Assert.True(finiteCount > 100, $"Expected >100 finite values, got {finiteCount}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,4 +243,4 @@ public sealed class DymoiValidationTests
|
||||
int finiteCount = values.Count(v => double.IsFinite(v));
|
||||
Assert.True(finiteCount > 100, $"Expected >100 finite values, got {finiteCount}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,4 +226,4 @@ public sealed class InertiaValidationTests : IDisposable
|
||||
int finiteCount = values.Count(v => double.IsFinite(v));
|
||||
Assert.True(finiteCount > 100, $"Expected >100 finite values, got {finiteCount}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,4 +350,4 @@ public sealed class LrsiValidationTests
|
||||
int finiteCount = values.Count(v => double.IsFinite(v));
|
||||
Assert.True(finiteCount > 100, $"Expected >100 finite values, got {finiteCount}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,4 +242,4 @@ public sealed class PgoValidationTests
|
||||
int finiteCount = values.Count(v => double.IsFinite(v));
|
||||
Assert.True(finiteCount > 100, $"Expected >100 finite values, got {finiteCount}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,4 +178,4 @@ public sealed class SmiValidationTests
|
||||
int finiteCount = values.Count(v => double.IsFinite(v));
|
||||
Assert.True(finiteCount > 100, $"Expected >100 finite values, got {finiteCount}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,10 +258,10 @@ public sealed class StochValidationTests : IDisposable
|
||||
// --- I) TALib cross-validation ---
|
||||
|
||||
/// <summary>
|
||||
/// TALib Stoch(fastKPeriod=14, slowKPeriod=1, slowKMAType=SMA, slowDPeriod=3, slowDMAType=SMA)
|
||||
/// TALib Stoch(fastKPeriod=14, slowKPeriod=1, slowKTALib.Core.MAType=SMA, slowDPeriod=3, slowDTALib.Core.MAType=SMA)
|
||||
/// with slowKPeriod=1 (no K smoothing) produces raw %K == our K output.
|
||||
/// slowD with SMA(3) matches our D output.
|
||||
/// Note: TALib Stoch uses SMA for both K and D smoothing (MAType=SMA).
|
||||
/// Note: TALib Stoch uses SMA for both K and D smoothing (TALib.Core.MAType=SMA).
|
||||
/// QuanTAlib Stoch also uses SMA. With slowKPeriod=1 (identity) the K lines match directly.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
|
||||
@@ -105,7 +105,7 @@ public sealed class TrixValidationTests(ITestOutputHelper output) : IDisposable
|
||||
|
||||
double[] tOutput = new double[tData.Length];
|
||||
var retCode = TALib.Functions.Trix<double>(tData, 0..^0, tOutput, out var outRange, period);
|
||||
Assert.Equal(Core.RetCode.Success, retCode);
|
||||
Assert.Equal(TALib.Core.RetCode.Success, retCode);
|
||||
|
||||
int lookback = TALib.Functions.TrixLookback(period);
|
||||
|
||||
@@ -132,7 +132,7 @@ public sealed class TrixValidationTests(ITestOutputHelper output) : IDisposable
|
||||
}
|
||||
|
||||
var retCode = TALib.Functions.Trix<double>(tData, 0..^0, tOutput, out var outRange, period);
|
||||
Assert.Equal(Core.RetCode.Success, retCode);
|
||||
Assert.Equal(TALib.Core.RetCode.Success, retCode);
|
||||
|
||||
int lookback = TALib.Functions.TrixLookback(period);
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ public sealed class UltoscValidationTests : IDisposable
|
||||
var qResult = ultosc.Update(_data.Bars);
|
||||
|
||||
var retCode = TALib.Functions.UltOsc(hData, lData, cData, 0..^0, output, out var outRange, p1, p2, p3);
|
||||
Assert.Equal(Core.RetCode.Success, retCode);
|
||||
Assert.Equal(TALib.Core.RetCode.Success, retCode);
|
||||
|
||||
int lookback = TALib.Functions.UltOscLookback(p1, p2, p3);
|
||||
|
||||
@@ -279,7 +279,7 @@ public sealed class UltoscValidationTests : IDisposable
|
||||
}
|
||||
|
||||
var retCode = TALib.Functions.UltOsc(hData, lData, cData, 0..^0, output, out var outRange, p1, p2, p3);
|
||||
Assert.Equal(Core.RetCode.Success, retCode);
|
||||
Assert.Equal(TALib.Core.RetCode.Success, retCode);
|
||||
|
||||
int lookback = TALib.Functions.UltOscLookback(p1, p2, p3);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user