mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-01 11:17:46 +00:00
86fe32a682
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat> Co-authored-by: Warp <agent@warp.dev>
56 lines
1.4 KiB
C#
56 lines
1.4 KiB
C#
using System.Runtime.CompilerServices;
|
|
using Skender.Stock.Indicators;
|
|
|
|
namespace QuanTAlib.Tests;
|
|
|
|
public sealed class LinRegValidationTests : IDisposable
|
|
{
|
|
private readonly ValidationTestData _data;
|
|
|
|
public LinRegValidationTests()
|
|
{
|
|
_data = new ValidationTestData();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_data.Dispose();
|
|
}
|
|
|
|
[SkipLocalsInit]
|
|
[Fact]
|
|
public void Validate_Against_Skender_Slope()
|
|
{
|
|
const int period = 14;
|
|
var skender = _data.SkenderQuotes.GetSlope(period).ToList();
|
|
|
|
var linreg = new LinReg(period);
|
|
var slopeSeries = new TSeries();
|
|
foreach (var item in _data.Data)
|
|
{
|
|
linreg.Update(item);
|
|
slopeSeries.Add(new TValue(item.Time, linreg.Slope));
|
|
}
|
|
|
|
ValidationHelper.VerifyData(slopeSeries, skender, x => x.Slope, tolerance: ValidationHelper.DefaultTolerance);
|
|
}
|
|
|
|
[SkipLocalsInit]
|
|
[Fact]
|
|
public void Validate_Against_Skender_RSquared()
|
|
{
|
|
const int period = 14;
|
|
var skender = _data.SkenderQuotes.GetSlope(period).ToList();
|
|
|
|
var linreg = new LinReg(period);
|
|
var r2Series = new TSeries();
|
|
foreach (var item in _data.Data)
|
|
{
|
|
linreg.Update(item);
|
|
r2Series.Add(new TValue(item.Time, linreg.RSquared));
|
|
}
|
|
|
|
ValidationHelper.VerifyData(r2Series, skender, x => x.RSquared, tolerance: ValidationHelper.DefaultTolerance);
|
|
}
|
|
}
|