mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-17 01:58:06 +00:00
Squash
dotcover s1 .sln s1 s1 s2 s3 s4 s5 s1 s2 x x2 x3 x4 x5 x6 x1 sonarcube cleanup1 sonarcube cleanup2 sonarcube cleanup 3 fixes q q q q q q q q q1 q2 q q1 codacy 1
This commit is contained in:
@@ -22,8 +22,8 @@ public class Alma : AbstractBase
|
||||
private readonly int _period;
|
||||
private readonly double _offset;
|
||||
private readonly double _sigma;
|
||||
private CircularBuffer? _buffer;
|
||||
private CircularBuffer? _weight;
|
||||
private readonly CircularBuffer? _buffer;
|
||||
private readonly CircularBuffer? _weight;
|
||||
private double _norm;
|
||||
|
||||
/// <param name="period">The number of data points used in the ALMA calculation.</param>
|
||||
@@ -41,6 +41,8 @@ public class Alma : AbstractBase
|
||||
_sigma = sigma;
|
||||
WarmupPeriod = period;
|
||||
Name = "Alma";
|
||||
_buffer = new CircularBuffer(_period);
|
||||
_weight = new CircularBuffer(_period);
|
||||
Init();
|
||||
}
|
||||
|
||||
@@ -57,8 +59,6 @@ public class Alma : AbstractBase
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
_buffer = new CircularBuffer(_period);
|
||||
_weight = new CircularBuffer(_period);
|
||||
_norm = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ public class Convolution : AbstractBase
|
||||
{
|
||||
private readonly double[] _kernel;
|
||||
private readonly int _kernelSize;
|
||||
private CircularBuffer _buffer;
|
||||
private double[] _normalizedKernel;
|
||||
private readonly CircularBuffer _buffer;
|
||||
private readonly double[] _normalizedKernel;
|
||||
|
||||
public Convolution(double[] kernel)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Dsma : AbstractBase
|
||||
{
|
||||
private readonly int _period;
|
||||
private readonly CircularBuffer _buffer;
|
||||
private readonly double _a1, _b1, _c1, _c2, _c3;
|
||||
private readonly double _c1, _c2, _c3;
|
||||
private double _lastDsma, _p_lastDsma;
|
||||
private double _filt, _filt1, _filt2, _zeros, _zeros1;
|
||||
private double _p_filt, _p_filt1, _p_filt2, _p_zeros, _p_zeros1;
|
||||
@@ -49,8 +49,8 @@ public class Dsma : AbstractBase
|
||||
_buffer = new CircularBuffer(period);
|
||||
|
||||
// SuperSmoother filter coefficients
|
||||
_a1 = Math.Exp(-1.414 * Math.PI / (0.5 * period));
|
||||
_b1 = 2 * _a1 * Math.Cos(1.414 * Math.PI / (0.5 * period));
|
||||
double _a1 = Math.Exp(-1.414 * Math.PI / (0.5 * period));
|
||||
double _b1 = 2 * _a1 * Math.Cos(1.414 * Math.PI / (0.5 * period));
|
||||
_c2 = _b1;
|
||||
_c3 = -_a1 * _a1;
|
||||
_c1 = 1 - _c2 - _c3;
|
||||
|
||||
+7
-5
@@ -30,10 +30,12 @@ public class Ema : AbstractBase
|
||||
// inherited _index
|
||||
// inherited _value
|
||||
private readonly int _period;
|
||||
private CircularBuffer _sma;
|
||||
private readonly CircularBuffer _sma;
|
||||
private double _lastEma, _p_lastEma;
|
||||
private double _k, _e, _p_e;
|
||||
private bool _isInit, _p_isInit, _useSma;
|
||||
private double _e, _p_e;
|
||||
private readonly double _k;
|
||||
private bool _isInit, _p_isInit;
|
||||
private readonly bool _useSma;
|
||||
|
||||
public Ema(int period, bool useSma = true)
|
||||
{
|
||||
@@ -50,13 +52,14 @@ public class Ema : AbstractBase
|
||||
Init();
|
||||
}
|
||||
|
||||
public Ema(double alpha) : base()
|
||||
public Ema(double alpha)
|
||||
{
|
||||
_k = alpha;
|
||||
_useSma = false;
|
||||
_sma = new(1);
|
||||
_period = 1;
|
||||
WarmupPeriod = (int)Math.Ceiling(Math.Log(0.05) / Math.Log(1 - _k)); //95th percentile
|
||||
_sma = new(_period);
|
||||
Init();
|
||||
}
|
||||
|
||||
@@ -74,7 +77,6 @@ public class Ema : AbstractBase
|
||||
_lastEma = 0;
|
||||
_isInit = false;
|
||||
_p_isInit = false;
|
||||
_sma = new(_period);
|
||||
}
|
||||
|
||||
protected override void ManageState(bool isNew)
|
||||
|
||||
+10
-4
@@ -6,14 +6,20 @@ namespace QuanTAlib
|
||||
{
|
||||
private readonly int _period;
|
||||
private readonly double _fc;
|
||||
private CircularBuffer _buffer;
|
||||
private readonly CircularBuffer _buffer;
|
||||
private double _lastFrama;
|
||||
private double _prevLastFrama;
|
||||
|
||||
public Frama(int period, double fc = 0.5)
|
||||
{
|
||||
if (period < 2)
|
||||
{
|
||||
throw new ArgumentException("Period must be at least 2", nameof(period));
|
||||
}
|
||||
if (fc <= 0 || fc >= 1)
|
||||
{
|
||||
throw new ArgumentException("Fc must be between 0 and 1", nameof(fc));
|
||||
}
|
||||
|
||||
_period = period;
|
||||
_fc = fc;
|
||||
@@ -78,11 +84,11 @@ namespace QuanTAlib
|
||||
}
|
||||
|
||||
double n1 = (hh - ll) / _period;
|
||||
double n2 = (hh1 - ll1 + hh2 - ll2) / (_period / 2);
|
||||
double n2 = (hh1 - ll1 + hh2 - ll2) / half;
|
||||
|
||||
double d = (Math.Log(n2 + double.Epsilon) - Math.Log(n1 + double.Epsilon)) / Math.Log(2);
|
||||
double d = (Math.Log(n1 + double.Epsilon) - Math.Log(n2 + double.Epsilon)) / Math.Log(2);
|
||||
|
||||
double alpha = Math.Exp(-4.6 * (d - 1));
|
||||
double alpha = Math.Exp(-4.6 * (d - 1) * _fc);
|
||||
alpha = Math.Max(Math.Min(alpha, 1), 0.01); // Ensure alpha is between 0.01 and 1
|
||||
|
||||
_lastFrama = alpha * (Input.Value - _lastFrama) + _lastFrama;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//not working yet
|
||||
//TODO consistency test
|
||||
|
||||
using QuanTAlib;
|
||||
namespace QuanTAlib;
|
||||
|
||||
public class Htit : AbstractBase
|
||||
{
|
||||
@@ -18,8 +18,8 @@ public class Htit : AbstractBase
|
||||
private readonly CircularBuffer _sdBuffer = new(2);
|
||||
private readonly CircularBuffer _itBuffer = new(4);
|
||||
|
||||
private double _lastPd = 0;
|
||||
private double _p_lastPd = 0;
|
||||
private double _lastPd;
|
||||
private double _p_lastPd;
|
||||
|
||||
public Htit()
|
||||
{
|
||||
|
||||
+12
-18
@@ -1,14 +1,12 @@
|
||||
using QuanTAlib;
|
||||
namespace QuanTAlib;
|
||||
//TODO consistency test
|
||||
public class Jma : AbstractBase
|
||||
{
|
||||
public readonly int Period;
|
||||
private readonly int Period;
|
||||
private readonly double _phase;
|
||||
private readonly int _vshort, _vlong;
|
||||
private CircularBuffer _values;
|
||||
private CircularBuffer _voltyShort;
|
||||
private CircularBuffer _vsumBuff;
|
||||
private CircularBuffer _avoltyBuff;
|
||||
private readonly CircularBuffer _values;
|
||||
private readonly CircularBuffer _voltyShort;
|
||||
private readonly CircularBuffer _vsumBuff;
|
||||
|
||||
private double _beta, _len1, _pow1;
|
||||
private double _upperBand, _lowerBand, _prevMa1, _prevDet0, _prevDet1, _prevJma;
|
||||
@@ -21,17 +19,16 @@ public class Jma : AbstractBase
|
||||
throw new ArgumentOutOfRangeException(nameof(period), "Period must be greater than or equal to 1.");
|
||||
}
|
||||
Period = period;
|
||||
_vshort = vshort;
|
||||
_vlong = 65;
|
||||
int _vshort = vshort;
|
||||
int _vlong = 65;
|
||||
_phase = Math.Clamp((phase * 0.01) + 1.5, 0.5, 2.5);
|
||||
|
||||
_values = new CircularBuffer(period);
|
||||
_voltyShort = new CircularBuffer(vshort);
|
||||
_voltyShort = new CircularBuffer(_vshort);
|
||||
_vsumBuff = new CircularBuffer(_vlong);
|
||||
_avoltyBuff = new CircularBuffer(2);
|
||||
|
||||
Name = "JMA";
|
||||
WarmupPeriod = period * 2;
|
||||
WarmupPeriod = 65;
|
||||
Init();
|
||||
}
|
||||
|
||||
@@ -42,9 +39,6 @@ public class Jma : AbstractBase
|
||||
_beta = 0.45 * (Period - 1) / (0.45 * (Period - 1) + 2);
|
||||
_len1 = Math.Max((Math.Log(Math.Sqrt(Period - 1)) / Math.Log(2.0)) + 2.0, 0);
|
||||
_pow1 = Math.Max(_len1 - 2.0, 0.5);
|
||||
_avoltyBuff.Clear();
|
||||
_avoltyBuff.Add(0, true);
|
||||
_avoltyBuff.Add(0, true);
|
||||
base.Init();
|
||||
}
|
||||
|
||||
@@ -97,9 +91,9 @@ public class Jma : AbstractBase
|
||||
double vsum = _vsumBuff.Newest() + 0.1 * (volty - _voltyShort.Oldest());
|
||||
_vsumBuff.Add(vsum, Input.IsNew);
|
||||
|
||||
double prevAvolty = _avoltyBuff.Newest();
|
||||
double avolty = prevAvolty + 2.0 / (Math.Max(4.0 * Period, 30) + 1.0) * (vsum - prevAvolty);
|
||||
_avoltyBuff.Add(avolty, Input.IsNew);
|
||||
double avolty = 0;
|
||||
for (int i = 0; i < _vsumBuff.Count; i++) { avolty += _vsumBuff[i]; }
|
||||
avolty /= _vsumBuff.Count;
|
||||
|
||||
double dVolty = (avolty > 0) ? volty / avolty : 0;
|
||||
dVolty = Math.Min(Math.Max(dVolty, 1.0), Math.Pow(_len1, 1.0 / _pow1));
|
||||
|
||||
@@ -6,7 +6,7 @@ public class Kama : AbstractBase
|
||||
{
|
||||
private readonly int _period;
|
||||
private readonly double _scFast, _scSlow;
|
||||
private CircularBuffer? _buffer;
|
||||
private readonly CircularBuffer? _buffer;
|
||||
private double _lastKama, _p_lastKama;
|
||||
|
||||
public Kama(int period, int fast = 2, int slow = 30)
|
||||
@@ -20,6 +20,7 @@ public class Kama : AbstractBase
|
||||
_scSlow = 2.0 / (slow + 1);
|
||||
WarmupPeriod = period;
|
||||
Name = $"Kama({_period}, {fast}, {slow})";
|
||||
_buffer = new CircularBuffer(_period + 1);
|
||||
Init();
|
||||
}
|
||||
|
||||
@@ -32,7 +33,7 @@ public class Kama : AbstractBase
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
_buffer = new CircularBuffer(_period + 1);
|
||||
|
||||
_lastKama = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,12 @@ public class Ltma : AbstractBase
|
||||
|
||||
public double Gamma => _gamma;
|
||||
|
||||
public Ltma(double gamma = 0.1)
|
||||
public Ltma(double gamma = 0.1)
|
||||
{
|
||||
if (gamma < 0 || gamma > 1)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(gamma), "Gamma must be between 0 and 1.");
|
||||
}
|
||||
_gamma = gamma;
|
||||
Name = $"Laguerre({gamma:F2})";
|
||||
WarmupPeriod = 4; // Minimum number of samples needed
|
||||
|
||||
@@ -8,12 +8,13 @@ public class Maaf : AbstractBase
|
||||
{
|
||||
private readonly CircularBuffer _priceBuffer;
|
||||
private readonly CircularBuffer _smoothBuffer;
|
||||
private double _prevFilter, _prevValue2, _threshold;
|
||||
private double _prevFilter, _prevValue2;
|
||||
private readonly double _threshold;
|
||||
private double _p_prevFilter, _p_prevValue2;
|
||||
|
||||
private readonly int _period;
|
||||
|
||||
public Maaf(int Period = 39, double Threshold = 0.002)
|
||||
public Maaf(int Period = 39, double Threshold = 0.002)
|
||||
{
|
||||
_period = Period;
|
||||
_threshold = Threshold;
|
||||
@@ -94,7 +95,10 @@ public class Maaf : AbstractBase
|
||||
length -= 2;
|
||||
}
|
||||
|
||||
if (length < 3) length = 3;
|
||||
if (length < 3)
|
||||
{
|
||||
length = 3;
|
||||
}
|
||||
|
||||
double finalAlpha = 2.0 / (length + 1);
|
||||
double filter = finalAlpha * (smooth - _prevFilter) + _prevFilter;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
using QuanTAlib;
|
||||
using System;
|
||||
namespace QuanTAlib;
|
||||
|
||||
|
||||
public class Mama : AbstractBase
|
||||
{
|
||||
private readonly double _fastLimit, _slowLimit;
|
||||
private CircularBuffer _pr, _sm, _dt, _i1, _q1, _i2, _q2, _re, _im, _pd, _ph;
|
||||
private readonly CircularBuffer _pr, _sm, _dt, _i1, _q1, _i2, _q2, _re, _im, _pd, _ph;
|
||||
private double _mama, _fama;
|
||||
private double _prevMama, _prevFama, _sumPr;
|
||||
private double _p_prevMama, _p_prevFama, _p_sumPr;
|
||||
|
||||
public TValue Fama { get; private set; }
|
||||
|
||||
public Mama(double fastLimit = 0.5, double slowLimit = 0.05)
|
||||
public Mama(double fastLimit = 0.5, double slowLimit = 0.05)
|
||||
{
|
||||
Fama = new TValue();
|
||||
Name = $"Mama({_fastLimit:F2}, {_slowLimit:F2})";
|
||||
|
||||
+5
-11
@@ -2,31 +2,25 @@ namespace QuanTAlib;
|
||||
|
||||
public class Qema : AbstractBase
|
||||
{
|
||||
private readonly double _k1, _k2, _k3, _k4;
|
||||
private readonly Ema _ema1, _ema2, _ema3, _ema4;
|
||||
private double _lastQema, _p_lastQema;
|
||||
|
||||
public Qema(double k1=0.2, double k2=0.2, double k3=0.2, double k4=0.2)
|
||||
public Qema(double k1 = 0.2, double k2 = 0.2, double k3 = 0.2, double k4 = 0.2)
|
||||
{
|
||||
if (k1 <= 0 || k2 <= 0 || k3 <= 0 || k4 <= 0 )
|
||||
if (k1 <= 0 || k2 <= 0 || k3 <= 0 || k4 <= 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("All k values must be in the range (0, 1].");
|
||||
throw new ArgumentOutOfRangeException(nameof(k1), "All k values must be in the range (0, 1].");
|
||||
}
|
||||
|
||||
_k1 = k1;
|
||||
_k2 = k2;
|
||||
_k3 = k3;
|
||||
_k4 = k4;
|
||||
|
||||
_ema1 = new Ema(k1);
|
||||
_ema2 = new Ema(k2);
|
||||
_ema3 = new Ema(k3);
|
||||
_ema4 = new Ema(k4);
|
||||
|
||||
Name = $"QEMA ({k1:F2},{k2:F2},{k3:F2},{k4:F2})";
|
||||
double smK = Math.Min(Math.Min(_k1, _k2), Math.Min(_k3, _k4));
|
||||
double smK = Math.Min(Math.Min(k1, k2), Math.Min(k3, k4));
|
||||
|
||||
WarmupPeriod = (int) ((2 - smK) / smK);
|
||||
WarmupPeriod = (int)((2 - smK) / smK);
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,12 +12,16 @@ public class Rema : AbstractBase
|
||||
public int Period => _period;
|
||||
public double Lambda => _lambda;
|
||||
|
||||
public Rema(int period, double lambda = 0.5)
|
||||
public Rema(int period, double lambda = 0.5)
|
||||
{
|
||||
if (period < 1)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(period), "Period must be greater than or equal to 1.");
|
||||
}
|
||||
if (lambda < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(lambda), "Lambda must be non-negative.");
|
||||
}
|
||||
|
||||
_period = period;
|
||||
_lambda = lambda;
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ namespace QuanTAlib {
|
||||
|
||||
public class Rma : AbstractBase {
|
||||
private readonly int _period;
|
||||
private double _alpha;
|
||||
private readonly double _alpha;
|
||||
private double _lastRMA;
|
||||
private double _savedLastRMA;
|
||||
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@ public class Sma : AbstractBase
|
||||
{
|
||||
// inherited _index
|
||||
// inherited _value
|
||||
public readonly int Period;
|
||||
private CircularBuffer _buffer;
|
||||
private readonly int Period;
|
||||
private readonly CircularBuffer _buffer;
|
||||
|
||||
public Sma(int period)
|
||||
{
|
||||
|
||||
@@ -5,10 +5,10 @@ namespace QuanTAlib;
|
||||
public class Smma : AbstractBase
|
||||
{
|
||||
private readonly int _period;
|
||||
private CircularBuffer? _buffer;
|
||||
private readonly CircularBuffer? _buffer;
|
||||
private double _lastSmma, _p_lastSmma;
|
||||
|
||||
public Smma(int period)
|
||||
public Smma(int period)
|
||||
{
|
||||
if (period < 1)
|
||||
{
|
||||
@@ -17,6 +17,7 @@ public class Smma : AbstractBase
|
||||
_period = period;
|
||||
WarmupPeriod = period;
|
||||
Name = $"Smma({_period})";
|
||||
_buffer = new CircularBuffer(_period);
|
||||
Init();
|
||||
}
|
||||
|
||||
@@ -29,7 +30,6 @@ public class Smma : AbstractBase
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
_buffer = new CircularBuffer(_period);
|
||||
_lastSmma = 0;
|
||||
}
|
||||
|
||||
|
||||
+7
-10
@@ -3,30 +3,27 @@ namespace QuanTAlib;
|
||||
public class T3 : AbstractBase
|
||||
{
|
||||
private readonly int _period;
|
||||
private readonly double _vfactor;
|
||||
private readonly bool _useSma;
|
||||
private readonly double _k, _k1m, _c1, _c2, _c3, _c4;
|
||||
private readonly double _k, _c1, _c2, _c3, _c4;
|
||||
private readonly CircularBuffer _buffer1, _buffer2, _buffer3, _buffer4, _buffer5, _buffer6;
|
||||
private double _lastEma1, _lastEma2, _lastEma3, _lastEma4, _lastEma5, _lastEma6;
|
||||
private double _p_lastEma1, _p_lastEma2, _p_lastEma3, _p_lastEma4, _p_lastEma5, _p_lastEma6;
|
||||
|
||||
public T3(int period, double vfactor = 0.7, bool useSma = true)
|
||||
public T3(int period, double vfactor = 0.7, bool useSma = true)
|
||||
{
|
||||
if (period < 1)
|
||||
{
|
||||
throw new ArgumentException("Period must be greater than or equal to 1.", nameof(period));
|
||||
}
|
||||
_period = period;
|
||||
_vfactor = vfactor;
|
||||
_useSma = useSma;
|
||||
WarmupPeriod = period;
|
||||
|
||||
_k = 2.0 / (_period + 1);
|
||||
_k1m = 1.0 - _k;
|
||||
_c1 = -_vfactor * _vfactor * _vfactor;
|
||||
_c2 = 3 * _vfactor * _vfactor + 3 * _vfactor * _vfactor * _vfactor;
|
||||
_c3 = -6 * _vfactor * _vfactor - 3 * _vfactor - 3 * _vfactor * _vfactor * _vfactor;
|
||||
_c4 = 1 + 3 * _vfactor + _vfactor * _vfactor * _vfactor + 3 * _vfactor * _vfactor;
|
||||
_c1 = -vfactor * vfactor * vfactor;
|
||||
_c2 = 3 * vfactor * vfactor + 3 * vfactor * vfactor * vfactor;
|
||||
_c3 = -6 * vfactor * vfactor - 3 * vfactor - 3 * vfactor * vfactor * vfactor;
|
||||
_c4 = 1 + 3 * vfactor + vfactor * vfactor * vfactor + 3 * vfactor * vfactor;
|
||||
|
||||
_buffer1 = new(period);
|
||||
_buffer2 = new(period);
|
||||
@@ -36,7 +33,7 @@ public class T3 : AbstractBase
|
||||
_buffer6 = new(period);
|
||||
|
||||
|
||||
Name = $"T3({_period}, {_vfactor})";
|
||||
Name = $"T3({_period}, {vfactor})";
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@ public class Vidya : AbstractBase
|
||||
private readonly int _longPeriod;
|
||||
private readonly double _alpha;
|
||||
private double _lastVIDYA, _p_lastVIDYA;
|
||||
private CircularBuffer? _shortBuffer;
|
||||
private CircularBuffer? _longBuffer;
|
||||
private readonly CircularBuffer? _shortBuffer;
|
||||
private readonly CircularBuffer? _longBuffer;
|
||||
|
||||
public Vidya(int shortPeriod, int longPeriod = 0, double alpha = 0.2)
|
||||
public Vidya(int shortPeriod, int longPeriod = 0, double alpha = 0.2)
|
||||
{
|
||||
if (shortPeriod < 1)
|
||||
{
|
||||
@@ -24,6 +24,8 @@ public class Vidya : AbstractBase
|
||||
_alpha = alpha;
|
||||
WarmupPeriod = _longPeriod;
|
||||
Name = $"Vidya({_shortPeriod},{_longPeriod})";
|
||||
_shortBuffer = new CircularBuffer(_shortPeriod);
|
||||
_longBuffer = new CircularBuffer(_longPeriod);
|
||||
Init();
|
||||
}
|
||||
|
||||
@@ -38,8 +40,6 @@ public class Vidya : AbstractBase
|
||||
{
|
||||
base.Init();
|
||||
_lastVIDYA = 0;
|
||||
_shortBuffer = new CircularBuffer(_shortPeriod);
|
||||
_longBuffer = new CircularBuffer(_longPeriod);
|
||||
}
|
||||
|
||||
protected override void ManageState(bool isNew)
|
||||
@@ -83,7 +83,7 @@ public class Vidya : AbstractBase
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private double CalculateStdDev(CircularBuffer buffer)
|
||||
private static double CalculateStdDev(CircularBuffer buffer)
|
||||
{
|
||||
double mean = buffer.Average();
|
||||
double sumSquaredDiff = buffer.Sum(x => Math.Pow(x - mean, 2));
|
||||
|
||||
+4
-4
@@ -1,8 +1,9 @@
|
||||
namespace QuanTAlib;
|
||||
|
||||
//TODO fix WMA - passing Talib test
|
||||
|
||||
public class Wma : AbstractBase
|
||||
{
|
||||
private readonly int _period;
|
||||
private readonly Convolution _convolution;
|
||||
|
||||
public Wma(int period)
|
||||
@@ -11,10 +12,9 @@ public class Wma : AbstractBase
|
||||
{
|
||||
throw new ArgumentException("Period must be greater than or equal to 1.", nameof(period));
|
||||
}
|
||||
_period = period;
|
||||
_convolution = new Convolution(GenerateWmaKernel(_period));
|
||||
_convolution = new Convolution(GenerateWmaKernel(period));
|
||||
Name = "Wma";
|
||||
WarmupPeriod = _period;
|
||||
WarmupPeriod = period;
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,11 @@ namespace QuanTAlib;
|
||||
public class Zlema : AbstractBase
|
||||
{
|
||||
private readonly int _period;
|
||||
private CircularBuffer? _buffer;
|
||||
private double _alpha;
|
||||
private int _lag;
|
||||
private readonly CircularBuffer? _buffer;
|
||||
private readonly double _alpha;
|
||||
private double _lastZLEMA, _p_lastZLEMA;
|
||||
|
||||
public Zlema(int period)
|
||||
public Zlema(int period)
|
||||
{
|
||||
if (period < 1)
|
||||
{
|
||||
@@ -20,8 +19,8 @@ public class Zlema : AbstractBase
|
||||
_period = period;
|
||||
WarmupPeriod = period;
|
||||
_alpha = 2.0 / (_period + 1);
|
||||
_lag = (_period - 1) / 2;
|
||||
Name = $"Zlema({_period})";
|
||||
_buffer = new CircularBuffer(_period);
|
||||
Init();
|
||||
}
|
||||
|
||||
@@ -34,7 +33,6 @@ public class Zlema : AbstractBase
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
_buffer = new CircularBuffer(_period);
|
||||
_lastZLEMA = 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user