mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-22 12:38:06 +00:00
feat: Add Cumulative Moving Average (CMA) implementation with detailed documentation
- Introduced Cma class for calculating the Cumulative Moving Average using Welford's algorithm with FMA for precision. - Added methods for batch processing and streaming updates. - Implemented a comprehensive markdown documentation for CMA, covering its mathematical foundation, performance profile, and use cases. - Enhanced existing trend indicators (Bessel, Butter, Htit, Jma, Mama, Ssf, Vidya) with FMA for improved numerical stability and precision. - Updated Adosc to utilize a single-pass algorithm for performance optimization. - Fixed date initialization in benchmarks to ensure UTC consistency.
This commit is contained in:
@@ -9,10 +9,26 @@ namespace QuanTAlib;
|
||||
/// Implemented as struct to avoid heap allocations in high-frequency event dispatch.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
public readonly struct TBarEventArgs
|
||||
public readonly struct TBarEventArgs : IEquatable<TBarEventArgs>
|
||||
{
|
||||
public TBar Value { get; init; }
|
||||
public bool IsNew { get; init; }
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool Equals(TBarEventArgs other) =>
|
||||
Value.Equals(other.Value) && IsNew == other.IsNew;
|
||||
|
||||
public override bool Equals(object? obj) =>
|
||||
obj is TBarEventArgs other && Equals(other);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
HashCode.Combine(Value, IsNew);
|
||||
|
||||
public static bool operator ==(TBarEventArgs left, TBarEventArgs right) =>
|
||||
left.Equals(right);
|
||||
|
||||
public static bool operator !=(TBarEventArgs left, TBarEventArgs right) =>
|
||||
!left.Equals(right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -277,4 +293,4 @@ public class TBarSeries : IReadOnlyList<TBar>
|
||||
|
||||
IEnumerator<TBar> IEnumerable<TBar>.GetEnumerator() => GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace QuanTAlib;
|
||||
@@ -7,10 +8,26 @@ namespace QuanTAlib;
|
||||
/// Implemented as struct to avoid heap allocations in high-frequency event dispatch.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
public readonly struct TValueEventArgs
|
||||
public readonly struct TValueEventArgs : IEquatable<TValueEventArgs>
|
||||
{
|
||||
public TValue Value { get; init; }
|
||||
public bool IsNew { get; init; }
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool Equals(TValueEventArgs other) =>
|
||||
Value.Equals(other.Value) && IsNew == other.IsNew;
|
||||
|
||||
public override bool Equals(object? obj) =>
|
||||
obj is TValueEventArgs other && Equals(other);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
HashCode.Combine(Value, IsNew);
|
||||
|
||||
public static bool operator ==(TValueEventArgs left, TValueEventArgs right) =>
|
||||
left.Equals(right);
|
||||
|
||||
public static bool operator !=(TValueEventArgs left, TValueEventArgs right) =>
|
||||
!left.Equals(right);
|
||||
}
|
||||
|
||||
// Performance-focused event args struct; not derived from EventArgs by design.
|
||||
|
||||
Reference in New Issue
Block a user