Refactor T3 Moving Average Implementation and Remove Unused Tests

- Deleted DebugTulip.Tests.cs as it was no longer needed.
- Refactored T3.cs to encapsulate parameters in a struct for better organization and readability.
- Updated methods in T3.cs to use the new Parameters struct, improving clarity and reducing redundancy.
- Enhanced T3.md documentation to provide clearer explanations of the T3 moving average and its parameters.
- Removed Wma.Coverage.Tests.cs as it was obsolete.
- Added new tests in IndicatorExtensions.Tests.cs to validate logic methods and ensure correct calculations.
- Updated IndicatorExtensions.cs to improve method organization and add new functionality for handling chart coordinates.
- Refactored mocks in TradingPlatformMocks.cs to align with new chart interface definitions.
This commit is contained in:
Miha Kralj
2025-12-07 17:32:01 -08:00
parent 94d06b0749
commit 3975ff2d7f
10 changed files with 330 additions and 850 deletions
-77
View File
@@ -1,77 +0,0 @@
using System;
using Xunit;
namespace QuanTAlib.Tests;
public class HmaCoverageTests
{
[Fact]
public void Hma_CalculateIntermediate_Simd_Coverage()
{
// CalculateIntermediate uses SIMD if length >= Vector256<double>.Count (4)
int count = 100;
int period = 10;
double[] source = new double[count];
double[] output = new double[count];
for(int i=0; i<count; i++) source[i] = 100.0;
Hma.Calculate(source.AsSpan(), output.AsSpan(), period);
Assert.Equal(100.0, output[^1], 1e-9);
}
[Fact]
public void Hma_CalculateIntermediate_Scalar_Coverage()
{
// Force scalar path by using small length
int count = 3;
int period = 2; // Min period is 2
double[] source = new double[count];
double[] output = new double[count];
for(int i=0; i<count; i++) source[i] = 100.0;
Hma.Calculate(source.AsSpan(), output.AsSpan(), period);
Assert.Equal(100.0, output[^1], 1e-9);
}
[Fact]
public void Hma_Reset_ClearsState()
{
var hma = new Hma(10);
hma.Update(new TValue(DateTime.UtcNow, 100.0));
Assert.NotEqual(0, hma.Last.Value);
hma.Reset();
Assert.Equal(0, hma.Last.Value);
Assert.False(hma.IsHot);
}
[Fact]
public void Hma_UpdateSeries_RestoresState()
{
var hma = new Hma(10);
var series = new TSeries();
for(int i=0; i<20; i++) series.Add(DateTime.UtcNow.AddMinutes(i), 100.0);
hma.Update(series);
// After batch update, the instance state should be consistent with the end of the series
// So next update should continue correctly
var nextVal = hma.Update(new TValue(DateTime.UtcNow.AddMinutes(20), 100.0));
Assert.Equal(100.0, nextVal.Value, 1e-9);
}
[Fact]
public void Hma_Constructor_Validation()
{
Assert.Throws<ArgumentException>(() => new Hma(1));
Assert.Throws<ArgumentException>(() => new Hma(0));
var hma = new Hma(2);
Assert.NotNull(hma);
}
}