mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-26 06:18:05 +00:00
feat: Implement IEquatable for state structures in Dema, Ema, T3, Tema, and Hma classes; update IsHot logic in Hma
This commit is contained in:
@@ -26,7 +26,7 @@ namespace QuanTAlib;
|
||||
[SkipLocalsInit]
|
||||
public sealed class Tema : ITValuePublisher
|
||||
{
|
||||
private struct EmaState
|
||||
private struct EmaState : IEquatable<EmaState>
|
||||
{
|
||||
public double Ema;
|
||||
public double E;
|
||||
@@ -34,6 +34,20 @@ public sealed class Tema : ITValuePublisher
|
||||
public bool IsCompensated;
|
||||
|
||||
public static EmaState New() => new() { Ema = 0, E = 1.0, IsHot = false, IsCompensated = false };
|
||||
|
||||
public override bool Equals(object? obj) => obj is EmaState other && Equals(other);
|
||||
|
||||
public bool Equals(EmaState other) =>
|
||||
Ema == other.Ema &&
|
||||
E == other.E &&
|
||||
IsHot == other.IsHot &&
|
||||
IsCompensated == other.IsCompensated;
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(Ema, E, IsHot, IsCompensated);
|
||||
|
||||
public static bool operator ==(EmaState left, EmaState right) => left.Equals(right);
|
||||
|
||||
public static bool operator !=(EmaState left, EmaState right) => !left.Equals(right);
|
||||
}
|
||||
|
||||
private readonly double _alpha;
|
||||
|
||||
Reference in New Issue
Block a user