Files
QuanTAlib/lib/statistics/linreg/LinReg.Validation.Tests.cs
T
Miha Kralj a82f6b7949 Refactor: Remove unnecessary using directives across multiple files
- Cleaned up code by removing unused using directives from various test and implementation files in the trends and volume directories.
- This includes files related to HMA, HTIT, JMA, KAMA, LSMA, MAMA, MGDI, PWMA, RMA, SMA, SSF, SUPER, T3, TEMA, TRIMA, USF, VIDYA, WMA, ATR, ADL, and ADOSC.
- Improved code readability and maintainability by streamlining imports.
2025-12-28 23:55:24 -08:00

58 lines
1.5 KiB
C#

using System.Runtime.CompilerServices;
using Skender.Stock.Indicators;
using OoplesFinance.StockIndicators;
using OoplesFinance.StockIndicators.Models;
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()
{
var 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()
{
var 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);
}
}