chore: Update project files and configurations; enhance .gitignore, add Qodana and SonarScanner scripts, and improve test project references

This commit is contained in:
Miha Kralj
2025-12-03 09:27:29 -08:00
parent 1d145d0622
commit 4a0a8d6da2
28 changed files with 257 additions and 88 deletions
+2
View File
@@ -22,6 +22,8 @@
<ItemGroup>
<Using Include="Xunit" />
<Using Include="QuanTAlib" />
<Using Include="System.Collections" />
</ItemGroup>
<ItemGroup>
-4
View File
@@ -1,7 +1,3 @@
using System;
using Xunit;
using QuanTAlib;
namespace QuanTAlib.Tests;
public class EmaTests
+3 -5
View File
@@ -4,9 +4,7 @@ using System.Linq;
using Skender.Stock.Indicators;
using TALib;
using Tulip;
using Xunit;
using Xunit.Abstractions;
using QuanTAlib;
namespace QuanTAlib.Tests;
@@ -213,7 +211,7 @@ public class EmaValidationTests
// Calculate Tulip EMA
var emaIndicator = Tulip.Indicators.ema;
double[][] inputs = { tData };
double[] options = { (double)period };
double[] options = { period };
double[][] outputs = { new double[tData.Length] };
emaIndicator.Run(inputs, options, outputs);
@@ -246,7 +244,7 @@ public class EmaValidationTests
// Calculate Tulip EMA
var emaIndicator = Tulip.Indicators.ema;
double[][] inputs = { tData };
double[] options = { (double)period };
double[] options = { period };
double[][] outputs = { new double[tData.Length] };
emaIndicator.Run(inputs, options, outputs);
@@ -275,7 +273,7 @@ public class EmaValidationTests
// Calculate Tulip EMA
var emaIndicator = Tulip.Indicators.ema;
double[][] inputs = { sourceData };
double[] options = { (double)period };
double[] options = { period };
double[][] outputs = { new double[sourceData.Length] };
emaIndicator.Run(inputs, options, outputs);
+16 -3
View File
@@ -25,12 +25,25 @@ namespace QuanTAlib;
/// </remarks>
public class Ema
{
private struct State
private struct State : IEquatable<State>
{
public double Ema;
public double E;
public bool IsHot;
public static State New() => new() { Ema = 0, E = 1.0, IsHot = false };
public readonly bool Equals(State other) =>
Ema == other.Ema && E == other.E && IsHot == other.IsHot;
public override readonly bool Equals(object? obj) =>
obj is State other && Equals(other);
public override readonly int GetHashCode() =>
HashCode.Combine(Ema, E, IsHot);
public static bool operator ==(State left, State right) => left.Equals(right);
public static bool operator !=(State left, State right) => !left.Equals(right);
}
private readonly double _alpha;
@@ -60,7 +73,7 @@ public class Ema
/// <summary>
/// Creates EMA with specified alpha smoothing factor.
/// </summary>
/// <param name="alpha">Smoothing factor (0 < alpha <= 1)</param>
/// <param name="alpha">Smoothing factor (0 &lt; alpha &lt;= 1)</param>
public Ema(double alpha)
{
if (alpha <= 0 || alpha > 1)
@@ -217,7 +230,7 @@ public class Ema
/// </summary>
/// <param name="source">Input values</param>
/// <param name="output">Output span (must be same length as source)</param>
/// <param name="alpha">Smoothing factor (0 < alpha <= 1)</param>
/// <param name="alpha">Smoothing factor (0 &lt; alpha &lt;= 1)</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Calculate(ReadOnlySpan<double> source, Span<double> output, double alpha)
{
-4
View File
@@ -1,7 +1,3 @@
using System;
using System.Linq;
using Xunit;
using QuanTAlib;
namespace QuanTAlib.Tests;
-4
View File
@@ -1,7 +1,3 @@
using System;
using Xunit;
using QuanTAlib;
namespace QuanTAlib.Tests;
public class SmaTests
+3 -5
View File
@@ -4,9 +4,7 @@ using System.Linq;
using Skender.Stock.Indicators;
using TALib;
using Tulip;
using Xunit;
using Xunit.Abstractions;
using QuanTAlib;
namespace QuanTAlib.Tests;
@@ -213,7 +211,7 @@ public class SmaValidationTests
// Calculate Tulip SMA
var smaIndicator = Tulip.Indicators.sma;
double[][] inputs = { tData };
double[] options = { (double)period };
double[] options = { period };
int lookback = period - 1;
double[][] outputs = { new double[tData.Length - lookback] };
@@ -247,7 +245,7 @@ public class SmaValidationTests
// Calculate Tulip SMA
var smaIndicator = Tulip.Indicators.sma;
double[][] inputs = { tData };
double[] options = { (double)period };
double[] options = { period };
int lookback = period - 1;
double[][] outputs = { new double[tData.Length - lookback] };
@@ -277,7 +275,7 @@ public class SmaValidationTests
// Calculate Tulip SMA
var smaIndicator = Tulip.Indicators.sma;
double[][] inputs = { sourceData };
double[] options = { (double)period };
double[] options = { period };
int lookback = period - 1;
double[][] outputs = { new double[sourceData.Length - lookback] };
-3
View File
@@ -1,6 +1,3 @@
using System.Linq;
using Xunit;
using QuanTAlib;
namespace QuanTAlib.Tests;
-4
View File
@@ -1,7 +1,3 @@
using System;
using Xunit;
using QuanTAlib;
namespace QuanTAlib.Tests;
public class WmaTests
+3 -5
View File
@@ -4,9 +4,7 @@ using System.Linq;
using Skender.Stock.Indicators;
using TALib;
using Tulip;
using Xunit;
using Xunit.Abstractions;
using QuanTAlib;
namespace QuanTAlib.Tests;
@@ -213,7 +211,7 @@ public class WmaValidationTests
// Calculate Tulip WMA
var wmaIndicator = Tulip.Indicators.wma;
double[][] inputs = { tData };
double[] options = { (double)period };
double[] options = { period };
int lookback = period - 1;
double[][] outputs = { new double[tData.Length - lookback] };
@@ -247,7 +245,7 @@ public class WmaValidationTests
// Calculate Tulip WMA
var wmaIndicator = Tulip.Indicators.wma;
double[][] inputs = { tData };
double[] options = { (double)period };
double[] options = { period };
int lookback = period - 1;
double[][] outputs = { new double[tData.Length - lookback] };
@@ -277,7 +275,7 @@ public class WmaValidationTests
// Calculate Tulip WMA
var wmaIndicator = Tulip.Indicators.wma;
double[][] inputs = { sourceData };
double[] options = { (double)period };
double[] options = { period };
int lookback = period - 1;
double[][] outputs = { new double[sourceData.Length - lookback] };
-3
View File
@@ -1,6 +1,3 @@
using System.Linq;
using Xunit;
using QuanTAlib;
namespace QuanTAlib.Tests;
-4
View File
@@ -1,7 +1,3 @@
using System;
using System.Collections;
using Xunit;
using QuanTAlib;
namespace QuanTAlib.Tests;
+20 -4
View File
@@ -423,7 +423,7 @@ public sealed class RingBuffer : IEnumerable<double>
/// <summary>
/// High-performance enumerator for the RingBuffer.
/// </summary>
public struct Enumerator : IEnumerator<double>
public struct Enumerator : IEnumerator<double>, IEquatable<Enumerator>
{
private readonly RingBuffer _buffer;
private readonly int _start;
@@ -453,8 +453,8 @@ public sealed class RingBuffer : IEnumerable<double>
return true;
}
public double Current => _current;
object IEnumerator.Current => Current;
public readonly double Current => _current;
readonly object IEnumerator.Current => Current;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Reset()
@@ -463,6 +463,22 @@ public sealed class RingBuffer : IEnumerable<double>
_current = default;
}
public void Dispose() { }
public readonly void Dispose() { }
public readonly bool Equals(Enumerator other) =>
ReferenceEquals(_buffer, other._buffer) &&
_start == other._start &&
_count == other._count &&
_index == other._index &&
_current == other._current;
public override readonly bool Equals(object? obj) =>
obj is Enumerator other && Equals(other);
public override readonly int GetHashCode() =>
HashCode.Combine(RuntimeHelpers.GetHashCode(_buffer), _start, _count, _index, _current);
public static bool operator ==(Enumerator left, Enumerator right) => left.Equals(right);
public static bool operator !=(Enumerator left, Enumerator right) => !left.Equals(right);
}
}
+4 -5
View File
@@ -1,6 +1,3 @@
using System;
using Xunit;
using QuanTAlib;
namespace QuanTAlib.Tests;
@@ -550,11 +547,13 @@ public class SimdExtensionsTests
Assert.True(avg > 0);
Assert.True(min > 0);
Assert.True(max > min);
Assert.Equal(min, minAlt);
Assert.Equal(max, maxAlt);
Assert.True(variance > 0);
Assert.True(stdDev > 0);
Assert.True(sw.ElapsedMilliseconds < 10,
$"SIMD operations took {sw.ElapsedMilliseconds}ms, expected < 10ms");
Assert.True(sw.ElapsedMilliseconds < 50,
$"SIMD operations took {sw.ElapsedMilliseconds}ms, expected < 50ms");
}
[Fact]
-3
View File
@@ -1,6 +1,3 @@
using System;
using Xunit;
using QuanTAlib;
namespace QuanTAlib.Tests
{
-6
View File
@@ -1,9 +1,3 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Xunit;
using QuanTAlib;
namespace QuanTAlib.Tests
{
-6
View File
@@ -1,9 +1,3 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Xunit;
using QuanTAlib;
namespace QuanTAlib.Tests
{
-3
View File
@@ -1,6 +1,3 @@
using System;
using Xunit;
using QuanTAlib;
namespace QuanTAlib.Tests
{
-1
View File
@@ -1,4 +1,3 @@
using Xunit;
namespace QuanTAlib.Tests;
-3
View File
@@ -1,6 +1,3 @@
using System;
using Xunit;
using QuanTAlib;
namespace QuanTAlib.Tests;
+5 -5
View File
@@ -32,17 +32,17 @@
<UserSecretsId>6afc11a7-4355-4f5e-9fdf-22431e5b03cb</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<InternalsVisibleTo Include="QuanTAlib.Tests" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="QuanTAlib.Tests" />
</ItemGroup>
<ItemGroup>
<Compile Include="**\*.cs" Exclude="**\*.Tests.cs;**\*.Quantower.cs;obj\**\*.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PackageReference Include="GitVersion.MsBuild" Version="6.5.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>