mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-07 05:27:43 +00:00
060649192f
- Remove 'C# Implementation Considerations' sections from 34 indicator .md files - Delete 29 temp PowerShell scripts (_fix_mojibake.ps1, _hex_scan.ps1, etc.) - Move test files into tests/ subdirectories for consistent project structure - Add trader-focused bullet points to indicator documentation
43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using QuanTAlib.Tests;
|
|
using MathNet.Numerics.Statistics;
|
|
|
|
namespace QuanTAlib.Validation;
|
|
|
|
public sealed class SkewValidationTests : IDisposable
|
|
{
|
|
private readonly ValidationTestData _data = new();
|
|
|
|
public void Dispose()
|
|
{
|
|
_data.Dispose();
|
|
}
|
|
|
|
[Fact]
|
|
public void Skew_Matches_MathNet()
|
|
{
|
|
const int period = 20;
|
|
var skew = new Skew(period, isPopulation: false);
|
|
var popSkew = new Skew(period, isPopulation: true);
|
|
|
|
var quotes = _data.SkenderQuotes.ToList();
|
|
double[] input = quotes.Select(q => (double)q.Close).ToArray();
|
|
|
|
for (int i = 0; i < input.Length; i++)
|
|
{
|
|
var val = skew.Update(new TValue(quotes[i].Date, input[i]));
|
|
var popVal = popSkew.Update(new TValue(quotes[i].Date, input[i]));
|
|
|
|
// Validate last 100 bars
|
|
if (i >= input.Length - 100)
|
|
{
|
|
var window = input[(i - period + 1)..(i + 1)];
|
|
double expected = window.Skewness();
|
|
double expectedPop = window.PopulationSkewness();
|
|
|
|
Assert.Equal(expected, val.Value, 1e-6);
|
|
Assert.Equal(expectedPop, popVal.Value, 1e-6);
|
|
}
|
|
}
|
|
}
|
|
}
|