Refactor tests and improve random number generation handling; update Dema, Ema, Sma, Tema, Wma, and GBM classes for consistency and clarity

This commit is contained in:
Miha Kralj
2025-12-05 10:33:27 -08:00
parent 9e152b9027
commit 3b146b68bd
10 changed files with 240 additions and 242 deletions
+3 -6
View File
@@ -9,6 +9,7 @@ namespace QuanTAlib;
/// </summary>
[SkipLocalsInit]
#pragma warning disable S101 // Rename class 'GBM' to match pascal case naming rules
#pragma warning disable S2245 // Random is acceptable for simulation/testing purposes
public class GBM : IFeed
#pragma warning restore S101
{
@@ -82,10 +83,8 @@ public class GBM : IFeed
return _cachedZ;
}
#pragma warning disable S2245 // Random is acceptable for simulation/testing purposes
double u1 = 1.0 - _rnd.NextDouble();
double u2 = 1.0 - _rnd.NextDouble();
#pragma warning restore S2245
double u1 = 1.0 - _rnd.NextDouble(); // nosemgrep
double u2 = 1.0 - _rnd.NextDouble(); // nosemgrep
double mag = Math.Sqrt(-2.0 * Math.Log(u1));
double angle = 2.0 * Math.PI * u2;
@@ -190,11 +189,9 @@ public class GBM : IFeed
double open = currentPrice;
double close = price;
#pragma warning disable S2245 // Random is acceptable for simulation/testing purposes
double rnd1 = _rnd.NextDouble();
double rnd2 = _rnd.NextDouble();
double rnd3 = _rnd.NextDouble();
#pragma warning restore S2245
t[i] = currentTime;
o[i] = open;