mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-01 03:07:43 +00:00
b3a64f18fa
- Added Ztest class to compute the one-sample t-statistic using sample standard deviation with Bessel correction. - Implemented validation tests for Ztest to ensure accuracy against manual calculations and PineScript. - Updated documentation for Ztest, detailing its mathematical foundation, performance profile, and common pitfalls. - Adjusted NDepend badges to reflect changes in code metrics after implementation. - Updated missing indicators report to reflect the completion of statistical indicators, including ZTEST.
55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using TradingPlatform.BusinessLayer;
|
|
|
|
namespace QuanTAlib.Tests;
|
|
|
|
public class QuantileIndicatorTests
|
|
{
|
|
[Fact]
|
|
public void QuantileIndicator_Constructor_DefaultValues()
|
|
{
|
|
var indicator = new QuantileIndicator();
|
|
Assert.Equal(14, indicator.Period);
|
|
Assert.Equal(0.5, indicator.QuantileLevel);
|
|
Assert.False(indicator.SeparateWindow);
|
|
}
|
|
|
|
[Fact]
|
|
public void QuantileIndicator_MinHistoryDepths()
|
|
{
|
|
var indicator = new QuantileIndicator { Period = 20 };
|
|
Assert.Equal(20, indicator.Period);
|
|
}
|
|
|
|
[Fact]
|
|
public void QuantileIndicator_Initialize_CreatesInternalQuantile()
|
|
{
|
|
var indicator = new QuantileIndicator { Period = 10, QuantileLevel = 0.75 };
|
|
indicator.Initialize();
|
|
|
|
Assert.Equal("Quantile 10 (0.75)", indicator.ShortName);
|
|
}
|
|
|
|
[Fact]
|
|
public void QuantileIndicator_ProcessUpdate_HistoricalBar_ComputesValue()
|
|
{
|
|
var indicator = new QuantileIndicator { Period = 5, QuantileLevel = 0.75 };
|
|
indicator.Initialize();
|
|
|
|
// Add historical data
|
|
var now = DateTime.UtcNow;
|
|
for (int i = 0; i < 20; i++)
|
|
{
|
|
indicator.HistoricalData.AddBar(now.AddMinutes(i), 100 + i, 110 + i, 90 + i, 105 + i);
|
|
|
|
var args = new UpdateArgs(UpdateReason.HistoricalBar);
|
|
indicator.ProcessUpdate(args);
|
|
}
|
|
|
|
// Line series should have a value
|
|
double quantile = indicator.LinesSeries[0].GetValue(0);
|
|
|
|
// Quantile of a trending series should be finite
|
|
Assert.True(double.IsFinite(quantile));
|
|
}
|
|
}
|