mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-18 18:48:05 +00:00
Refactor and enhance various channel indicators for improved performance and stability
- Updated Codacy instructions to streamline usage guidelines. - Refactored Bbands class to utilize ArrayPool for memory management, preventing stack overflow on large series. - Changed Fcb class to use long for monotonic deques to avoid truncation issues. - Enhanced Kchannel class to ensure safe defaults for non-finite values. - Improved Maenv class to prevent double-priming during calculations. - Modified Mmchannel class to ensure non-negative buffer indices and removed unnecessary state tracking. - Updated Pchannel class to correctly reference IsHot state. - Refined Regchannel class to avoid double-processing during calculations. - Enhanced Starchannel class to sanitize non-finite values during calculations. - Adjusted Stbands.Quantower.cs to allow finer control over multiplier precision. - Updated Ubands class to only update last valid values on new bars. - Modified Uchannel.Quantower.cs to allow for finer multiplier precision. - Enhanced Vwapbands classes to include standard deviation calculations and ensure consistent array lengths. - Refactored Vwapsd classes to include standard deviation outputs and ensure consistent array lengths. - Updated MonotonicDeque to use long for indices to prevent overflow. - Improved Mdape class to handle zero actual values with a substitute value for error calculation. - Enhanced Rae class to ensure correct state management during updates. - Refined Wmape class to simplify the logic for finding last valid actual and predicted values. - Updated Cmf.Quantower classes to ensure MinHistoryDepths reflects the current period.
This commit is contained in:
@@ -16,7 +16,7 @@ namespace QuanTAlib;
|
||||
[SkipLocalsInit]
|
||||
public sealed class MonotonicDeque
|
||||
{
|
||||
private readonly int[] _deque;
|
||||
private readonly long[] _deque;
|
||||
private readonly int _period;
|
||||
private int _head;
|
||||
private int _count;
|
||||
@@ -24,7 +24,7 @@ public sealed class MonotonicDeque
|
||||
/// <summary>
|
||||
/// Gets the current front index (the index of the current extremum).
|
||||
/// </summary>
|
||||
public int FrontIndex => _count > 0 ? _deque[_head] : -1;
|
||||
public long FrontIndex => _count > 0 ? _deque[_head] : -1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current element count in the deque.
|
||||
@@ -43,7 +43,7 @@ public sealed class MonotonicDeque
|
||||
}
|
||||
|
||||
_period = period;
|
||||
_deque = new int[period];
|
||||
_deque = new long[period];
|
||||
_head = 0;
|
||||
_count = 0;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public sealed class MonotonicDeque
|
||||
while (_count > 0)
|
||||
{
|
||||
int backIdx = (_head + _count - 1) % _period;
|
||||
int bufIdx = _deque[backIdx] % _period;
|
||||
int bufIdx = (int)(_deque[backIdx] % _period);
|
||||
if (buffer[bufIdx] <= value)
|
||||
{
|
||||
_count--;
|
||||
@@ -83,7 +83,7 @@ public sealed class MonotonicDeque
|
||||
|
||||
// Push new index
|
||||
int tail = (_head + _count) % _period;
|
||||
_deque[tail] = (int)logicalIndex;
|
||||
_deque[tail] = logicalIndex;
|
||||
_count++;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public sealed class MonotonicDeque
|
||||
while (_count > 0)
|
||||
{
|
||||
int backIdx = (_head + _count - 1) % _period;
|
||||
int bufIdx = _deque[backIdx] % _period;
|
||||
int bufIdx = (int)(_deque[backIdx] % _period);
|
||||
if (buffer[bufIdx] >= value)
|
||||
{
|
||||
_count--;
|
||||
@@ -122,7 +122,7 @@ public sealed class MonotonicDeque
|
||||
|
||||
// Push new index
|
||||
int tail = (_head + _count) % _period;
|
||||
_deque[tail] = (int)logicalIndex;
|
||||
_deque[tail] = logicalIndex;
|
||||
_count++;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public sealed class MonotonicDeque
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public double GetExtremum(double[] buffer)
|
||||
{
|
||||
return _count > 0 ? buffer[_deque[_head] % _period] : double.NaN;
|
||||
return _count > 0 ? buffer[(int)(_deque[_head] % _period)] : double.NaN;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user