mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-13 08:08:05 +00:00
Sonarcloud changes
This commit is contained in:
@@ -14,17 +14,17 @@ public class MAX_Series : Single_TSeries_Indicator
|
||||
}
|
||||
private readonly System.Collections.Generic.List<double> _buffer = new();
|
||||
|
||||
public override void Add((DateTime t, double v) d, bool update)
|
||||
public override void Add((DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
if (update) { this._buffer[this._buffer.Count - 1] = d.v; }
|
||||
else { this._buffer.Add(d.v); }
|
||||
if (update) { this._buffer[this._buffer.Count - 1] = TValue.v; }
|
||||
else { this._buffer.Add(TValue.v); }
|
||||
if (this._buffer.Count > this._p && this._p != 0) { this._buffer.RemoveAt(0); }
|
||||
|
||||
double _max = d.v;
|
||||
double _max = TValue.v;
|
||||
for (int i = 0; i < this._buffer.Count; i++)
|
||||
{ _max = (this._buffer[i] > _max) ? this._buffer[i] : _max; }
|
||||
|
||||
var result = (d.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _max);
|
||||
var result = (TValue.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _max);
|
||||
|
||||
base.Add(result, update);
|
||||
}
|
||||
|
||||
@@ -14,17 +14,17 @@ public class MIN_Series : Single_TSeries_Indicator
|
||||
}
|
||||
private readonly System.Collections.Generic.List<double> _buffer = new();
|
||||
|
||||
public override void Add((System.DateTime t, double v) d, bool update)
|
||||
public override void Add((System.DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
if (update) { this._buffer[this._buffer.Count - 1] = d.v; }
|
||||
else { this._buffer.Add(d.v); }
|
||||
if (update) { this._buffer[this._buffer.Count - 1] = TValue.v; }
|
||||
else { this._buffer.Add(TValue.v); }
|
||||
if (this._buffer.Count > this._p && this._p != 0) { this._buffer.RemoveAt(0); }
|
||||
|
||||
double _min = d.v;
|
||||
double _min = TValue.v;
|
||||
for (int i = 0; i < this._buffer.Count; i++)
|
||||
{ _min = (this._buffer[i] < _min) ? this._buffer[i] : _min; }
|
||||
|
||||
var result = (d.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _min);
|
||||
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _min);
|
||||
|
||||
base.Add(result, update);
|
||||
}
|
||||
|
||||
@@ -24,15 +24,15 @@ public class TR_Series : Single_TBars_Indicator
|
||||
if (this._bars.Count > 0) { base.Add(this._bars); }
|
||||
}
|
||||
|
||||
public override void Add((DateTime t, double o, double h, double l, double c, double v) TValue, bool update = false)
|
||||
public override void Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update)
|
||||
{
|
||||
if (_cm1 is double.NaN) { _cm1 = TValue.c; }
|
||||
if (_cm1 is double.NaN) { _cm1 = TBar.c; }
|
||||
|
||||
double d1 = Math.Abs(TValue.h - TValue.l);
|
||||
double d2 = Math.Abs(_cm1 - TValue.h);
|
||||
double d3 = Math.Abs(_cm1 - TValue.l);
|
||||
var ret = (TValue.t, (base.Count==0 && base._NaN) ? double.NaN : Math.Max(d1,Math.Max(d2,d3)) );
|
||||
double d1 = Math.Abs(TBar.h - TBar.l);
|
||||
double d2 = Math.Abs(_cm1 - TBar.h);
|
||||
double d3 = Math.Abs(_cm1 - TBar.l);
|
||||
var ret = (TBar.t, (base.Count==0 && base._NaN) ? double.NaN : Math.Max(d1,Math.Max(d2,d3)) );
|
||||
base.Add(ret, update);
|
||||
_cm1 = TValue.c;
|
||||
_cm1 = TBar.c;
|
||||
}
|
||||
}
|
||||
@@ -26,17 +26,17 @@ public class ATR_Series : Single_TBars_Indicator
|
||||
this._k = 1.0 / (double)(this._p);
|
||||
this._k1m = 1.0 - this._k;
|
||||
this._lastema = this._lastlastema = double.NaN;
|
||||
if (_bars.Count > 0) { base.Add(_bars); }
|
||||
if (this._bars.Count > 0) { base.Add(this._bars); }
|
||||
}
|
||||
|
||||
public override void Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update = false)
|
||||
public override void Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update)
|
||||
{
|
||||
if (update) {
|
||||
this._lastema = this._lastlastema;
|
||||
this._cm1 = this._lastcm1;
|
||||
}
|
||||
|
||||
if (_cm1 is double.NaN) { _cm1 = TBar.c; }
|
||||
if (this._cm1 is double.NaN) { this._cm1 = TBar.c; }
|
||||
double d1 = Math.Abs(TBar.h - TBar.l);
|
||||
double d2 = Math.Abs(_cm1 - TBar.h);
|
||||
double d3 = Math.Abs(_cm1 - TBar.l);
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ATRP_Series : Single_TBars_Indicator
|
||||
if (_bars.Count > 0) { base.Add(_bars); }
|
||||
}
|
||||
|
||||
public override void Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update = false)
|
||||
public override void Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update)
|
||||
{
|
||||
if (update) {
|
||||
this._lastema = this._lastlastema;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class DEMA_Series : Single_TSeries_Indicator
|
||||
if (_data.Count > 0) { base.Add(_data); }
|
||||
}
|
||||
|
||||
public override void Add((DateTime t, double v) d, bool update = false)
|
||||
public override void Add((DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
|
||||
if (update)
|
||||
@@ -42,10 +42,10 @@ public class DEMA_Series : Single_TSeries_Indicator
|
||||
|
||||
if (this.Count < this._p)
|
||||
{
|
||||
if (update) { _buffer[_buffer.Count - 1] = d.v; }
|
||||
if (update) { _buffer[_buffer.Count - 1] = TValue.v; }
|
||||
else
|
||||
{
|
||||
_buffer.Add(d.v);
|
||||
_buffer.Add(TValue.v);
|
||||
}
|
||||
if (_buffer.Count > this._p) { _buffer.RemoveAt(0); }
|
||||
|
||||
@@ -57,7 +57,7 @@ public class DEMA_Series : Single_TSeries_Indicator
|
||||
}
|
||||
else
|
||||
{
|
||||
_ema1 = d.v * this._k + this._lastema1 * this._k1m;
|
||||
_ema1 = TValue.v * this._k + this._lastema1 * this._k1m;
|
||||
_ema2 = _ema1 * this._k + this._lastema2 * this._k1m;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class DEMA_Series : Single_TSeries_Indicator
|
||||
this._lastema1 = _ema1;
|
||||
this._lastema2 = _ema2;
|
||||
|
||||
var ret = (d.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _dema);
|
||||
var ret = (TValue.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _dema);
|
||||
base.Add(ret, update);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,17 +33,17 @@ public class EMA_Series : Single_TSeries_Indicator
|
||||
if (this._data.Count > 0) { base.Add(this._data); }
|
||||
}
|
||||
|
||||
public override void Add((DateTime t, double v) d, bool update = false)
|
||||
public override void Add((DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
double _ema = 0;
|
||||
if (update) { this._lastema = this._lastlastema; }
|
||||
|
||||
if (this.Count < this._p)
|
||||
{
|
||||
if (update) { this._buffer[this._buffer.Count - 1] = d.v; }
|
||||
if (update) { this._buffer[this._buffer.Count - 1] = TValue.v; }
|
||||
else
|
||||
{
|
||||
this._buffer.Add(d.v);
|
||||
this._buffer.Add(TValue.v);
|
||||
}
|
||||
if (this._buffer.Count > this._p) { this._buffer.RemoveAt(0); }
|
||||
|
||||
@@ -52,13 +52,13 @@ public class EMA_Series : Single_TSeries_Indicator
|
||||
}
|
||||
else
|
||||
{
|
||||
_ema = d.v * this._k + this._lastema * this._k1m;
|
||||
_ema = TValue.v * this._k + this._lastema * this._k1m;
|
||||
}
|
||||
|
||||
this._lastlastema = this._lastema;
|
||||
this._lastema = _ema;
|
||||
|
||||
var ret = (d.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _ema);
|
||||
var ret = (TValue.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _ema);
|
||||
base.Add(ret, update);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class HEMA_Series : Single_TSeries_Indicator
|
||||
private double _lastema2, _lastlastema2;
|
||||
private double _lastema3, _lastlastema3;
|
||||
|
||||
public override void Add((System.DateTime t, double v) d, bool update)
|
||||
public override void Add((System.DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
if (update)
|
||||
{
|
||||
@@ -40,11 +40,11 @@ public class HEMA_Series : Single_TSeries_Indicator
|
||||
this._lastema3 = this._lastlastema3;
|
||||
}
|
||||
double _ema1 = System.Double.IsNaN(this._lastema1)
|
||||
? d.v
|
||||
: d.v * this._k1 + this._lastema1 * (1 - this._k1);
|
||||
? TValue.v
|
||||
: TValue.v * this._k1 + this._lastema1 * (1 - this._k1);
|
||||
double _ema2 = System.Double.IsNaN(this._lastema2)
|
||||
? d.v
|
||||
: d.v * this._k2 + this._lastema2 * (1 - this._k2);
|
||||
? TValue.v
|
||||
: TValue.v * this._k2 + this._lastema2 * (1 - this._k2);
|
||||
|
||||
double _rawhema = (2 * _ema1) - _ema2;
|
||||
double _ema3 = System.Double.IsNaN(this._lastema3)
|
||||
@@ -59,7 +59,7 @@ public class HEMA_Series : Single_TSeries_Indicator
|
||||
this._lastema3 = _ema3;
|
||||
|
||||
(System.DateTime t, double v) result =
|
||||
(d.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _ema3);
|
||||
(TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _ema3);
|
||||
base.Add(result, update);
|
||||
}
|
||||
}
|
||||
@@ -32,17 +32,17 @@ public class RMA_Series : Single_TSeries_Indicator
|
||||
if (_data.Count > 0) { base.Add(_data); }
|
||||
}
|
||||
|
||||
public override void Add((DateTime t, double v) d, bool update = false)
|
||||
public override void Add((DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
double _ema = 0;
|
||||
if (update) { this._lastema = this._lastlastema; }
|
||||
|
||||
if (this.Count < this._p)
|
||||
{
|
||||
if (update) { _buffer[_buffer.Count - 1] = d.v; }
|
||||
if (update) { _buffer[_buffer.Count - 1] = TValue.v; }
|
||||
else
|
||||
{
|
||||
_buffer.Add(d.v);
|
||||
_buffer.Add(TValue.v);
|
||||
}
|
||||
if (_buffer.Count > this._p) { _buffer.RemoveAt(0); }
|
||||
|
||||
@@ -51,13 +51,13 @@ public class RMA_Series : Single_TSeries_Indicator
|
||||
}
|
||||
else
|
||||
{
|
||||
_ema = d.v * _k + _lastema * _k1m;
|
||||
_ema = TValue.v * _k + _lastema * _k1m;
|
||||
}
|
||||
|
||||
this._lastlastema = this._lastema;
|
||||
this._lastema = _ema;
|
||||
|
||||
var ret = (d.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _ema);
|
||||
var ret = (TValue.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _ema);
|
||||
base.Add(ret, update);
|
||||
}
|
||||
}
|
||||
@@ -24,17 +24,17 @@ public class SMA_Series : Single_TSeries_Indicator
|
||||
}
|
||||
private readonly System.Collections.Generic.List<double> _buffer = new();
|
||||
|
||||
public override void Add((System.DateTime t, double v) d, bool update)
|
||||
public override void Add((System.DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
if (update) { _buffer[_buffer.Count - 1] = d.v; }
|
||||
else { _buffer.Add(d.v); }
|
||||
if (update) { _buffer[_buffer.Count - 1] = TValue.v; }
|
||||
else { _buffer.Add(TValue.v); }
|
||||
if (_buffer.Count > this._p && this._p != 0) { _buffer.RemoveAt(0); }
|
||||
|
||||
double _sma = 0;
|
||||
for (int i = 0; i < _buffer.Count; i++) { _sma += _buffer[i]; }
|
||||
_sma /= this._buffer.Count;
|
||||
|
||||
var result = (d.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _sma);
|
||||
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _sma);
|
||||
|
||||
base.Add(result, update);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class TEMA_Series : Single_TSeries_Indicator
|
||||
if (_data.Count > 0) { base.Add(_data); }
|
||||
}
|
||||
|
||||
public override void Add((DateTime t, double v) d, bool update = false)
|
||||
public override void Add((DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
|
||||
if (update)
|
||||
@@ -45,10 +45,10 @@ public class TEMA_Series : Single_TSeries_Indicator
|
||||
|
||||
if (this.Count < this._p)
|
||||
{
|
||||
if (update) { _buffer[_buffer.Count - 1] = d.v; }
|
||||
if (update) { _buffer[_buffer.Count - 1] = TValue.v; }
|
||||
else
|
||||
{
|
||||
_buffer.Add(d.v);
|
||||
_buffer.Add(TValue.v);
|
||||
}
|
||||
if (_buffer.Count > this._p) { _buffer.RemoveAt(0); }
|
||||
|
||||
@@ -59,7 +59,7 @@ public class TEMA_Series : Single_TSeries_Indicator
|
||||
}
|
||||
else
|
||||
{
|
||||
_ema1 = d.v * this._k + this._lastema1 * this._k1m;
|
||||
_ema1 = TValue.v * this._k + this._lastema1 * this._k1m;
|
||||
_ema2 = _ema1 * this._k + this._lastema2 * this._k1m;
|
||||
_ema3 = _ema2 * this._k + this._lastema3 * this._k1m;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class TEMA_Series : Single_TSeries_Indicator
|
||||
this._lastema2 = _ema2;
|
||||
this._lastema3 = _ema3;
|
||||
|
||||
var ret = (d.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _tema);
|
||||
var ret = (TValue.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _tema);
|
||||
base.Add(ret, update);
|
||||
}
|
||||
}
|
||||
@@ -22,17 +22,17 @@ public class WMA_Series : Single_TSeries_Indicator
|
||||
private readonly System.Collections.Generic.List<double> _buffer = new();
|
||||
private readonly System.Collections.Generic.List<double> _weights = new();
|
||||
|
||||
public override void Add((System.DateTime t, double v) d, bool update)
|
||||
public override void Add((System.DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
if (update) { _buffer[_buffer.Count - 1] = d.v; }
|
||||
else { _buffer.Add(d.v); }
|
||||
if (update) { _buffer[_buffer.Count - 1] = TValue.v; }
|
||||
else { _buffer.Add(TValue.v); }
|
||||
if (_buffer.Count > this._p && this._p != 0) { _buffer.RemoveAt(0); }
|
||||
|
||||
double _wma = 0;
|
||||
for (int i = 0; i < _buffer.Count; i++) { _wma += _buffer[i] * this._weights[i]; }
|
||||
_wma /= (this._buffer.Count * (this._buffer.Count + 1)) * 0.5;
|
||||
|
||||
var result = (d.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _wma);
|
||||
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _wma);
|
||||
|
||||
base.Add(result, update);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ZLEMA_Series : Single_TSeries_Indicator
|
||||
if (base._data.Count > 0) { base.Add(base._data); }
|
||||
}
|
||||
|
||||
public override void Add((System.DateTime t, double v) d, bool update)
|
||||
public override void Add((System.DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
if (update)
|
||||
{
|
||||
@@ -42,14 +42,14 @@ public class ZLEMA_Series : Single_TSeries_Indicator
|
||||
}
|
||||
int _lag = (int)(0.5 * (_p - 1));
|
||||
int _l = Math.Max(this._data.Count - _lag, 0);
|
||||
double _lagdata = 1 * d.v - this._data[_l].v;
|
||||
double _lagdata = 1 * TValue.v - this._data[_l].v;
|
||||
|
||||
double _ema = System.Double.IsNaN(this._lastema) ? _lagdata : _lagdata * this._k + this._lastema * this._k1m;
|
||||
this._lastlastema = this._lastema;
|
||||
this._lastema = _ema;
|
||||
|
||||
(System.DateTime t, double v) result =
|
||||
(d.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _ema);
|
||||
(TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _ema);
|
||||
base.Add(result, update);
|
||||
|
||||
}
|
||||
|
||||
@@ -33,10 +33,10 @@ public class KURT_Series : Single_TSeries_Indicator
|
||||
protected double _logbase = 2.0;
|
||||
private readonly System.Collections.Generic.List<double> _buffer = new();
|
||||
|
||||
public override void Add((System.DateTime t, double v) d, bool update)
|
||||
public override void Add((System.DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
if (update) { this._buffer[this._buffer.Count - 1] = d.v; }
|
||||
else { this._buffer.Add(d.v); }
|
||||
if (update) { this._buffer[this._buffer.Count - 1] = TValue.v; }
|
||||
else { this._buffer.Add(TValue.v); }
|
||||
if (this._buffer.Count > this._p && this._p != 0) { this._buffer.RemoveAt(0); }
|
||||
|
||||
double _n = this._buffer.Count;
|
||||
@@ -56,7 +56,7 @@ public class KURT_Series : Single_TSeries_Indicator
|
||||
double _Vx = _s2 / (_n - 1);
|
||||
double _kurt = (_n > 3) ? (((_n * (_n + 1)) / ((_n - 1) * (_n - 2) * (_n - 3))) * (_s4 / (_Vx * _Vx)) - (3 * ((_n - 1) * (_n - 1) / ((_n - 2) * (_n - 3))))) : Double.NaN;
|
||||
|
||||
var result = (d.t, (this.Count < this._p - 1 && this._NaN) ? Double.NaN : _kurt);
|
||||
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? Double.NaN : _kurt);
|
||||
base.Add(result, update);
|
||||
}
|
||||
}
|
||||
@@ -22,10 +22,10 @@ public class MAD_Series : Single_TSeries_Indicator
|
||||
}
|
||||
private readonly System.Collections.Generic.List<double> _buffer = new();
|
||||
|
||||
public override void Add((System.DateTime t, double v) d, bool update)
|
||||
public override void Add((System.DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
if (update) { this._buffer[this._buffer.Count - 1] = d.v; }
|
||||
else { _buffer.Add(d.v); }
|
||||
if (update) { this._buffer[this._buffer.Count - 1] = TValue.v; }
|
||||
else { _buffer.Add(TValue.v); }
|
||||
if (_buffer.Count > this._p && this._p != 0) { _buffer.RemoveAt(0); }
|
||||
|
||||
double _sma = 0;
|
||||
@@ -36,7 +36,7 @@ public class MAD_Series : Single_TSeries_Indicator
|
||||
for (int i = 0; i < _buffer.Count; i++) { _mad += Math.Abs(_buffer[i] - _sma); }
|
||||
_mad /= this._buffer.Count;
|
||||
|
||||
var result = (d.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _mad);
|
||||
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _mad);
|
||||
base.Add(result, update);
|
||||
}
|
||||
}
|
||||
@@ -25,10 +25,10 @@ public class MAPE_Series : Single_TSeries_Indicator
|
||||
}
|
||||
private readonly System.Collections.Generic.List<double> _buffer = new();
|
||||
|
||||
public override void Add((System.DateTime t, double v) d, bool update)
|
||||
public override void Add((System.DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
if (update) { _buffer[_buffer.Count - 1] = d.v; }
|
||||
else { _buffer.Add(d.v); }
|
||||
if (update) { _buffer[_buffer.Count - 1] = TValue.v; }
|
||||
else { _buffer.Add(TValue.v); }
|
||||
if (_buffer.Count > this._p && this._p != 0) { _buffer.RemoveAt(0); }
|
||||
|
||||
double _sma = 0;
|
||||
@@ -39,7 +39,7 @@ public class MAPE_Series : Single_TSeries_Indicator
|
||||
for (int i = 0; i < _buffer.Count; i++) { _mape += (_buffer[i] != 0) ? Math.Abs(_buffer[i] - _sma) / Math.Abs(_buffer[i]) : double.PositiveInfinity; }
|
||||
_mape /= this._buffer.Count;
|
||||
|
||||
var result = (d.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _mape);
|
||||
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _mape);
|
||||
base.Add(result, update);
|
||||
}
|
||||
}
|
||||
@@ -28,10 +28,10 @@ public class MED_Series : Single_TSeries_Indicator
|
||||
}
|
||||
private readonly System.Collections.Generic.List<double> _buffer = new();
|
||||
|
||||
public override void Add((System.DateTime t, double v) d, bool update)
|
||||
public override void Add((System.DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
if (update) { this._buffer[this._buffer.Count - 1] = d.v; }
|
||||
else { this._buffer.Add(d.v); }
|
||||
if (update) { this._buffer[this._buffer.Count - 1] = TValue.v; }
|
||||
else { this._buffer.Add(TValue.v); }
|
||||
if (this._buffer.Count > this._p && this._p != 0) { this._buffer.RemoveAt(0); }
|
||||
|
||||
System.Collections.Generic.List<double> _s = new(this._buffer);
|
||||
@@ -40,7 +40,7 @@ public class MED_Series : Single_TSeries_Indicator
|
||||
int _p2 = Math.Max(0, _s.Count / 2 - 1);
|
||||
double _med = (_s.Count % 2 != 0) ? _s[_p1] : (_s[_p1] + _s[_p2]) / 2;
|
||||
|
||||
var result = (d.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _med);
|
||||
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _med);
|
||||
|
||||
base.Add(result, update);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ public class MSE_Series : Single_TSeries_Indicator
|
||||
}
|
||||
private readonly System.Collections.Generic.List<double> _buffer = new();
|
||||
|
||||
public override void Add((System.DateTime t, double v) d, bool update)
|
||||
public override void Add((System.DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
if (update) { _buffer[_buffer.Count - 1] = d.v; }
|
||||
else { _buffer.Add(d.v); }
|
||||
if (update) { _buffer[_buffer.Count - 1] = TValue.v; }
|
||||
else { _buffer.Add(TValue.v); }
|
||||
if (_buffer.Count > this._p && this._p != 0) { _buffer.RemoveAt(0); }
|
||||
|
||||
double _sma = 0;
|
||||
@@ -32,7 +32,7 @@ public class MSE_Series : Single_TSeries_Indicator
|
||||
for (int i = 0; i < _buffer.Count; i++) { _mse += (_buffer[i] - _sma) * (_buffer[i] - _sma); }
|
||||
_mse /= this._buffer.Count;
|
||||
|
||||
var result = (d.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _mse);
|
||||
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _mse);
|
||||
base.Add(result, update);
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,10 @@ public class PSDEV_Series : Single_TSeries_Indicator
|
||||
}
|
||||
private readonly System.Collections.Generic.List<double> _buffer = new();
|
||||
|
||||
public override void Add((System.DateTime t, double v) d, bool update)
|
||||
public override void Add((System.DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
if (update) { _buffer[_buffer.Count - 1] = d.v; }
|
||||
else { _buffer.Add(d.v); }
|
||||
if (update) { _buffer[_buffer.Count - 1] = TValue.v; }
|
||||
else { _buffer.Add(TValue.v); }
|
||||
if (_buffer.Count > this._p && this._p != 0) { _buffer.RemoveAt(0); }
|
||||
|
||||
double _sma = 0;
|
||||
@@ -38,7 +38,7 @@ public class PSDEV_Series : Single_TSeries_Indicator
|
||||
_pvar /= this._buffer.Count;
|
||||
double _psdev = Math.Sqrt(_pvar);
|
||||
|
||||
var result = (d.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _psdev);
|
||||
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _psdev);
|
||||
base.Add(result, update);
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,10 @@ public class PVAR_Series : Single_TSeries_Indicator
|
||||
}
|
||||
private readonly System.Collections.Generic.List<double> _buffer = new();
|
||||
|
||||
public override void Add((System.DateTime t, double v) d, bool update)
|
||||
public override void Add((System.DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
if (update) { _buffer[_buffer.Count - 1] = d.v; }
|
||||
else { _buffer.Add(d.v); }
|
||||
if (update) { _buffer[_buffer.Count - 1] = TValue.v; }
|
||||
else { _buffer.Add(TValue.v); }
|
||||
if (_buffer.Count > this._p && this._p != 0) { _buffer.RemoveAt(0); }
|
||||
|
||||
double _sma = 0;
|
||||
@@ -37,7 +37,7 @@ public class PVAR_Series : Single_TSeries_Indicator
|
||||
for (int i = 0; i < _buffer.Count; i++) { _pvar += (_buffer[i] - _sma) * (_buffer[i] - _sma); }
|
||||
_pvar /= this._buffer.Count;
|
||||
|
||||
var result = (d.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _pvar);
|
||||
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _pvar);
|
||||
base.Add(result, update);
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,10 @@ public class SDEV_Series : Single_TSeries_Indicator
|
||||
}
|
||||
private readonly System.Collections.Generic.List<double> _buffer = new();
|
||||
|
||||
public override void Add((System.DateTime t, double v) d, bool update)
|
||||
public override void Add((System.DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
if (update) { this._buffer[this._buffer.Count - 1] = d.v; }
|
||||
else { this._buffer.Add(d.v); }
|
||||
if (update) { this._buffer[this._buffer.Count - 1] = TValue.v; }
|
||||
else { this._buffer.Add(TValue.v); }
|
||||
if (this._buffer.Count > this._p && this._p != 0) { this._buffer.RemoveAt(0); }
|
||||
|
||||
double _sma = 0;
|
||||
@@ -38,7 +38,7 @@ public class SDEV_Series : Single_TSeries_Indicator
|
||||
_svar /= (this._buffer.Count > 1) ? this._buffer.Count - 1 : 1; // Bessel's correction
|
||||
double _ssdev = Math.Sqrt(_svar);
|
||||
|
||||
var result = (d.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _ssdev);
|
||||
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _ssdev);
|
||||
base.Add(result, update);
|
||||
}
|
||||
}
|
||||
@@ -18,10 +18,10 @@ public class SMAPE_Series : Single_TSeries_Indicator
|
||||
}
|
||||
private readonly System.Collections.Generic.List<double> _buffer = new();
|
||||
|
||||
public override void Add((System.DateTime t, double v) d, bool update)
|
||||
public override void Add((System.DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
if (update) { _buffer[_buffer.Count - 1] = d.v; }
|
||||
else { _buffer.Add(d.v); }
|
||||
if (update) { _buffer[_buffer.Count - 1] = TValue.v; }
|
||||
else { _buffer.Add(TValue.v); }
|
||||
if (_buffer.Count > this._p && this._p != 0) { _buffer.RemoveAt(0); }
|
||||
|
||||
double _sma = 0;
|
||||
@@ -32,7 +32,7 @@ public class SMAPE_Series : Single_TSeries_Indicator
|
||||
for (int i = 0; i < _buffer.Count; i++) { _smape += Math.Abs(_buffer[i] - _sma) / (Math.Abs(_buffer[i]) + Math.Abs(_sma)); }
|
||||
_smape /= this._buffer.Count;
|
||||
|
||||
var result = (d.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _smape);
|
||||
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _smape);
|
||||
base.Add(result, update);
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,10 @@ public class VAR_Series : Single_TSeries_Indicator
|
||||
}
|
||||
private readonly System.Collections.Generic.List<double> _buffer = new();
|
||||
|
||||
public override void Add((System.DateTime t, double v) d, bool update)
|
||||
public override void Add((System.DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
if (update) { this._buffer[this._buffer.Count - 1] = d.v; }
|
||||
else { this._buffer.Add(d.v); }
|
||||
if (update) { this._buffer[this._buffer.Count - 1] = TValue.v; }
|
||||
else { this._buffer.Add(TValue.v); }
|
||||
if (this._buffer.Count > this._p && this._p != 0) { this._buffer.RemoveAt(0); }
|
||||
|
||||
double _sma = 0;
|
||||
@@ -37,7 +37,7 @@ public class VAR_Series : Single_TSeries_Indicator
|
||||
for (int i = 0; i < this._buffer.Count; i++) { _svar += (this._buffer[i] - _sma) * (this._buffer[i] - _sma); }
|
||||
_svar /= (this._buffer.Count > 1) ? this._buffer.Count - 1 : 1; // Bessel's correction
|
||||
|
||||
var result = (d.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _svar);
|
||||
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _svar);
|
||||
base.Add(result, update);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace QuanTAlib;
|
||||
namespace QuanTAlib;
|
||||
using System;
|
||||
|
||||
/* <summary>
|
||||
@@ -18,10 +18,10 @@ public class WMAPE_Series : Single_TSeries_Indicator
|
||||
}
|
||||
private readonly System.Collections.Generic.List<double> _buffer = new();
|
||||
|
||||
public override void Add((System.DateTime t, double v) d, bool update)
|
||||
public override void Add((System.DateTime t, double v) TValue, bool update)
|
||||
{
|
||||
if (update) { _buffer[_buffer.Count - 1] = d.v; }
|
||||
else { _buffer.Add(d.v); }
|
||||
if (update) { _buffer[_buffer.Count - 1] = TValue.v; }
|
||||
else { _buffer.Add(TValue.v); }
|
||||
if (_buffer.Count > this._p && this._p != 0) { _buffer.RemoveAt(0); }
|
||||
|
||||
double _sma = 0;
|
||||
@@ -37,7 +37,7 @@ public class WMAPE_Series : Single_TSeries_Indicator
|
||||
}
|
||||
_wmape /= _div;
|
||||
|
||||
var result = (d.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _wmape);
|
||||
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _wmape);
|
||||
base.Add(result, update);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user