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
+6 -1
View File
@@ -61,6 +61,7 @@ public sealed class Tema : ITValuePublisher
private EmaState _p_state3 = EmaState.New();
private double _lastValidValue;
private double _p_lastValidValue;
public string Name { get; }
public TValue Last { get; private set; }
@@ -83,7 +84,7 @@ public sealed class Tema : ITValuePublisher
public Tema(double alpha)
{
if (alpha <= 0 || alpha > 1) throw new ArgumentException("Alpha must be between 0 and 1", nameof(alpha));
if (alpha <= 0 || alpha >= 1) throw new ArgumentException("Alpha must be strictly between 0 and 1", nameof(alpha));
_alpha = alpha;
_decay = 1.0 - alpha;
@@ -98,12 +99,14 @@ public sealed class Tema : ITValuePublisher
_p_state1 = _state1;
_p_state2 = _state2;
_p_state3 = _state3;
_p_lastValidValue = _lastValidValue;
}
else
{
_state1 = _p_state1;
_state2 = _p_state2;
_state3 = _p_state3;
_lastValidValue = _p_lastValidValue;
}
// EMA1
@@ -174,6 +177,7 @@ public sealed class Tema : ITValuePublisher
_p_state2 = s2;
_p_state3 = s3;
_lastValidValue = lastValid;
_p_lastValidValue = lastValid;
Last = new TValue(tSpan[len - 1], vSpan[len - 1]);
return new TSeries(t, v);
@@ -343,6 +347,7 @@ public sealed class Tema : ITValuePublisher
_p_state2 = EmaState.New();
_p_state3 = EmaState.New();
_lastValidValue = 0;
_p_lastValidValue = 0;
Last = default;
}
}