mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-21 03:58:04 +00:00
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:
@@ -1,5 +1,6 @@
|
||||
namespace QuanTAlib.Tests;
|
||||
|
||||
#pragma warning disable S2245 // Random is acceptable for simulation/testing purposes
|
||||
public class TemaTests
|
||||
{
|
||||
[Fact]
|
||||
@@ -253,7 +254,7 @@ public class TemaTests
|
||||
{
|
||||
double[] source = new double[10000];
|
||||
double[] output = new double[10000];
|
||||
var rng = new Random(42);
|
||||
var rng = new Random(42); // nosemgrep
|
||||
for (int i = 0; i < source.Length; i++)
|
||||
source[i] = rng.NextDouble() * 100;
|
||||
|
||||
|
||||
@@ -19,7 +19,9 @@ namespace QuanTAlib;
|
||||
/// Uses three EMA instances, each with O(1) update complexity.
|
||||
///
|
||||
/// IsHot:
|
||||
/// Becomes true when the third EMA converges (approx. 3x EMA convergence time).
|
||||
/// Becomes true when the TEMA step response converges to within 5% error.
|
||||
/// This happens when the third EMA's error factor drops below ~9% (approx 2.43/alpha steps),
|
||||
/// which is faster than the standard EMA convergence (3/alpha steps).
|
||||
/// </remarks>
|
||||
[SkipLocalsInit]
|
||||
public sealed class Tema
|
||||
@@ -48,7 +50,7 @@ public sealed class Tema
|
||||
|
||||
public string Name { get; }
|
||||
public TValue Value { get; private set; }
|
||||
public bool IsHot => _state3.IsHot;
|
||||
public bool IsHot => _state3.E <= 0.09;
|
||||
|
||||
public Tema(int period)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user