mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-26 06:18:05 +00:00
python wrapper
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using Skender.Stock.Indicators;
|
||||
|
||||
namespace QuanTAlib.Tests;
|
||||
|
||||
/// <summary>
|
||||
@@ -112,6 +114,39 @@ public class SlopeValidationTests
|
||||
}
|
||||
}
|
||||
|
||||
// === Skender Cross-Validation ===
|
||||
|
||||
/// <summary>
|
||||
/// Structural validation against Skender <c>GetSlope</c>.
|
||||
/// Skender Slope computes linear regression slope over a lookback window,
|
||||
/// while QuanTAlib Slope computes simple first difference (current - previous).
|
||||
/// Different formulas mean numeric equality is not expected.
|
||||
/// Both must produce finite output and agree on trend direction for simple linear data.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Validate_Skender_Slope_Structural()
|
||||
{
|
||||
using var data = new ValidationTestData();
|
||||
const int period = 14;
|
||||
|
||||
// QuanTAlib Slope (streaming, simple difference)
|
||||
var slope = new Slope();
|
||||
var qResults = new List<double>();
|
||||
foreach (var tv in data.Data)
|
||||
{
|
||||
qResults.Add(slope.Update(tv).Value);
|
||||
}
|
||||
|
||||
// Skender Slope (linear regression slope)
|
||||
var sResult = data.SkenderQuotes.GetSlope(period).ToList();
|
||||
|
||||
// Structural: both produce finite output after warmup
|
||||
Assert.True(double.IsFinite(slope.Last.Value), "QuanTAlib Slope last must be finite");
|
||||
|
||||
int finiteCount = sResult.Count(r => r.Slope is not null && double.IsFinite(r.Slope.Value));
|
||||
Assert.True(finiteCount > 100, $"Skender Slope should produce >100 finite values, got {finiteCount}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LargeLinearSequence_ProducesConstantSlope()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user