Enhance code quality and stability across various modules

- Updated .coderabbit.yaml to exclude additional file types from reviews, improving the focus on relevant code changes.
- Modified scanner.sh to handle test failures more gracefully, ensuring that analysis stops on test failures and improving logging.
- Improved sonarscanner.sh to ensure build and test failures are properly reported, enhancing CI reliability.
- Refined SimdExtensions.cs documentation for clarity on variance calculation methods.
- Cleaned up TSeries.Tests.cs by simplifying the test structure and ensuring proper namespace usage.
- Fixed potential issues in tseries.cs by ensuring correct handling of DateTime values.
- Enhanced CsvFeed.cs to improve error handling during CSV parsing, ensuring robustness against malformed data.
- Updated GBM.cs to correctly calculate volume in the current bar, ensuring accurate simulation.
- Adjusted index.html to use globalThis for better compatibility across environments.
- Refined quantalib.csproj to exclude unnecessary files from compilation, streamlining the build process.
- Added comprehensive tests for the Mama class to ensure correct behavior during updates and state management.
- Improved error handling in various trend classes (Kama, Dema, Ema, T3, Tema, Wma) to ensure NaN values are managed correctly.
- Removed redundant Mama.Repro.Tests.cs file and consolidated tests into Mama.Tests.cs for better organization.
- Enhanced T3 and Tema classes to maintain state integrity during updates, particularly with NaN values.
This commit is contained in:
Miha Kralj
2025-12-10 14:51:58 -05:00
parent 7a4850956b
commit b26d5d7751
27 changed files with 260 additions and 136 deletions
+4 -2
View File
@@ -11,6 +11,8 @@ public class AlmaTests
{
Assert.Throws<ArgumentException>(() => new Alma(0));
Assert.Throws<ArgumentException>(() => new Alma(10, sigma: 0));
Assert.Throws<ArgumentOutOfRangeException>(() => new Alma(10, offset: -0.1));
Assert.Throws<ArgumentOutOfRangeException>(() => new Alma(10, offset: 1.1));
var alma = new Alma(10);
Assert.NotNull(alma);
@@ -52,7 +54,7 @@ public class AlmaTests
for (int i = 0; i < 100; i++)
{
var bar = gbm.Next(isNew: true);
series.Add(bar.Time, bar.Close);
series.Add(new TValue(bar.Time, bar.Close));
}
// Streaming
@@ -66,7 +68,7 @@ public class AlmaTests
var batchResults = almaBatch.Update(series);
Assert.Equal(streamingResults.Count, batchResults.Count);
for (int i = 0; i < streamingResults.Count; i++)
for (int i = 0; i < batchResults.Count; i++)
{
Assert.Equal(streamingResults[i].Value, batchResults[i].Value, 1e-9);
}
+4 -2
View File
@@ -62,6 +62,8 @@ public sealed class Alma : ITValuePublisher
throw new ArgumentException("Period must be greater than 0", nameof(period));
if (sigma <= 0)
throw new ArgumentException("Sigma must be greater than 0", nameof(sigma));
if (offset < 0 || offset > 1)
throw new ArgumentOutOfRangeException(nameof(offset), "Offset must be between 0 and 1");
_period = period;
_offset = offset;
@@ -225,8 +227,8 @@ public sealed class Alma : ITValuePublisher
}
// Horizontal sum
vSum = Avx.Add(vSum, Avx2.Permute4x64(vSum.AsUInt64(), 0b_01_00_11_10).AsDouble());
vSum = Avx.Add(vSum, Avx2.Permute4x64(vSum.AsUInt64(), 0b_00_00_00_01).AsDouble());
vSum = Avx.Add(vSum, Avx2.Permute4x64(vSum.AsUInt64(), 0b_01_00_11_10).AsDouble()); // skipcq: CS-R1131
vSum = Avx.Add(vSum, Avx2.Permute4x64(vSum.AsUInt64(), 0b_00_00_00_01).AsDouble()); // skipcq: CS-R1131
sum = vSum.GetElement(0);
}