mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-25 13:58:04 +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:
@@ -467,22 +467,23 @@ public class VwapsdTests
|
||||
double[] upper = new double[5];
|
||||
double[] lower = new double[5];
|
||||
double[] vwap = new double[5];
|
||||
double[] stdDev = new double[5];
|
||||
double[] wrongSize = new double[3];
|
||||
|
||||
// NumDevs must be >= MinNumDevs
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() =>
|
||||
Vwapsd.Calculate(price.AsSpan(), volume.AsSpan(),
|
||||
upper.AsSpan(), lower.AsSpan(), vwap.AsSpan(), 0));
|
||||
upper.AsSpan(), lower.AsSpan(), vwap.AsSpan(), stdDev.AsSpan(), 0));
|
||||
|
||||
// NumDevs must be <= MaxNumDevs
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() =>
|
||||
Vwapsd.Calculate(price.AsSpan(), volume.AsSpan(),
|
||||
upper.AsSpan(), lower.AsSpan(), vwap.AsSpan(), 6.0));
|
||||
upper.AsSpan(), lower.AsSpan(), vwap.AsSpan(), stdDev.AsSpan(), 6.0));
|
||||
|
||||
// All arrays must be same length
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
Vwapsd.Calculate(price.AsSpan(), volume.AsSpan(),
|
||||
wrongSize.AsSpan(), lower.AsSpan(), vwap.AsSpan(), 1.0));
|
||||
wrongSize.AsSpan(), lower.AsSpan(), vwap.AsSpan(), stdDev.AsSpan(), 1.0));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -493,9 +494,10 @@ public class VwapsdTests
|
||||
double[] upper = new double[5];
|
||||
double[] lower = new double[5];
|
||||
double[] vwap = new double[5];
|
||||
double[] stdDev = new double[5];
|
||||
|
||||
Vwapsd.Calculate(price.AsSpan(), volume.AsSpan(),
|
||||
upper.AsSpan(), lower.AsSpan(), vwap.AsSpan(), 1.0);
|
||||
upper.AsSpan(), lower.AsSpan(), vwap.AsSpan(), stdDev.AsSpan(), 1.0);
|
||||
|
||||
foreach (var val in vwap)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user