python wrapper

This commit is contained in:
Miha Kralj
2026-02-28 14:14:35 -08:00
parent 82e0248eb0
commit 83e9511261
521 changed files with 62395 additions and 15669 deletions
@@ -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()
{