Code Quality

This commit is contained in:
Miha Kralj
2022-11-11 11:42:06 -08:00
56 changed files with 48 additions and 268 deletions
+9 -9
View File
@@ -88,17 +88,17 @@ jobs:
files: /Quantower/Settings/Scripts/Indicators/QuanTAlib/*.dll files: /Quantower/Settings/Scripts/Indicators/QuanTAlib/*.dll
- name: Authenticate to Github packages source - name: Authenticate to Github packages source
run: dotnet nuget add source run: dotnet nuget add source
--username mihakralj --username mihakralj
--password ${{ secrets.GITHUB_TOKEN }} --password ${{ secrets.GITHUB_TOKEN }}
--store-password-in-clear-text --store-password-in-clear-text
--name github "https://nuget.pkg.github.com/mihakralj/index.json" --name github "https://nuget.pkg.github.com/mihakralj/index.json"
- name: Push package to github - name: Push package to github
if: ${{ github.ref == 'refs/heads/dev' }} if: ${{ github.ref == 'refs/heads/dev' }}
run: dotnet nuget push '.\Source\bin\Release\QuanTAlib.*.nupkg' run: dotnet nuget push '.\Source\bin\Release\QuanTAlib.*.nupkg'
--source https://nuget.pkg.github.com/mihakralj/index.json --source https://nuget.pkg.github.com/mihakralj/index.json
--skip-duplicate --skip-duplicate
--no-symbols --no-symbols
- name: Push package to nuget.org - name: Push package to nuget.org
+2 -2
View File
@@ -30,8 +30,8 @@ public class ATR_chart : Indicator
this.ShortName = "ATR (" + this.Period + ")"; this.ShortName = "ATR (" + this.Period + ")";
this.bars = new(); this.bars = new();
this.indicator = new(source: bars, period: this.Period, useNaN: false); this.indicator = new(source: bars, period: this.Period, useNaN: false);
} }
protected override void OnUpdate(UpdateArgs args) protected override void OnUpdate(UpdateArgs args)
{ {
bool update = !(args.Reason == UpdateReason.NewBar || bool update = !(args.Reason == UpdateReason.NewBar ||
-5
View File
@@ -51,11 +51,6 @@ public class WMAPE_chart : Indicator
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open), this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low), this.GetPrice(PriceType.Close), this.GetPrice(PriceType.Volume), update); this.bars.Add(this.Time(), this.GetPrice(PriceType.Open), this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low), this.GetPrice(PriceType.Close), this.GetPrice(PriceType.Volume), update);
double result = this.indicator[this.indicator.Count - 1].v; double result = this.indicator[this.indicator.Count - 1].v;
this.SetValue(result, 0); this.SetValue(result, 0);
} }
} }
-93
View File
@@ -1,93 +0,0 @@
using System.Collections;
using System.Drawing;
using System.Drawing.Text;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
public class ZLMA_chart : Indicator
{
#region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private readonly int Period = 10;
[InputParameter("Data source", 1, variants: new object[]
{ "Open", 0, "High", 1, "Low", 2, "Close", 3, "HL2", 4, "OC2", 5,
"OHL3", 6, "HLC3", 7, "OHLC4", 8, "Weighted (HLCC4)", 9 })]
private readonly int DataSource = 3;
[InputParameter("MA algorithm", 2, variants: new object[]
{ "SMA", 0,
"WMA", 1,
"EMA", 2,
"DEMA", 3,
"TEMA", 4,
"HMA", 5,
"KAMA", 6,
"JMA", 7,
"SMMA", 8
})]
private readonly int matype = 2;
#endregion Parameters
private TBars bars;
///////
private TSeries indicator;
///////
public ZLMA_chart()
{
this.SeparateWindow = false;
this.Name = "ZLMA - Zero-lag Moving Average";
this.Description = "Zero-Lag Moving Average description";
this.AddLineSeries("ZLMA", Color.RoyalBlue, 3, LineStyle.Solid);
}
protected override void OnInit()
{
this.bars = new();
string maname = matype switch
{
0 => "SMA",
1 => "WMA",
2 => "EMA",
3 => "DEMA",
4 => "TEMA",
5 => "HMA",
6 => "KAMA",
7 => "JMA",
8 => "SMMA",
_ => "???"
};
this.ShortName = "ZLMA (" + maname + ", " + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
ZL_Series zerolag = new(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
this.indicator = matype switch
{
0 => new SMA_Series(source: zerolag, period: this.Period, useNaN: false),
1 => new WMA_Series(source: zerolag, period: this.Period, useNaN: false),
2 => new EMA_Series(source: zerolag, period: this.Period, useNaN: false),
3 => new DEMA_Series(source: zerolag, period: this.Period, useNaN: false),
4 => new TEMA_Series(source: zerolag, period: this.Period, useNaN: false),
5 => new HMA_Series(source: zerolag, period: this.Period, useNaN: false),
6 => new KAMA_Series(source: zerolag, period: this.Period, useNaN: false),
7 => new JMA_Series(source: zerolag, period: this.Period, useNaN: false),
8 => new SMMA_Series(source: zerolag, period: this.Period, useNaN: false),
_ => new EMA_Series(source: zerolag, period: this.Period, useNaN: false)
};
}
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
double result = this.indicator[this.indicator.Count-1].v;
this.SetValue(result);
}
}
+17 -51
View File
@@ -32,23 +32,14 @@ public abstract class Single_TSeries_Indicator : TSeries
public new virtual void Add((System.DateTime t, double v) TValue, bool update) => base.Add(TValue, update); public new virtual void Add((System.DateTime t, double v) TValue, bool update) => base.Add(TValue, update);
// potentially overridable Add() method for the whole series (could be replaced with faster bulk algo) // potentially overridable Add() method for the whole series (could be replaced with faster bulk algo)
public virtual void Add(TSeries data) public virtual void Add(TSeries data) { for (int i = 0; i < data.Count; i++) { this.Add(TValue: data[i], update: false); }}
{
for (int i = 0; i < data.Count; i++) { this.Add(TValue: data[i], update: false); }
}
public new void Add((System.DateTime t, double v) TValue) public new void Add((System.DateTime t, double v) TValue) => this.Add(TValue: TValue, update: false);
=> this.Add(TValue: TValue, update: false); public void Add(bool update) => this.Add(TValue: this._data[this._data.Count - 1], update: update);
public void Add(bool update) public void Add() => this.Add(TValue: this._data[this._data.Count - 1], update: false);
=> this.Add(TValue: this._data[this._data.Count - 1], update: update); public new void Sub(object source, TSeriesEventArgs e) => this.Add(TValue: this._data[this._data.Count - 1], update: e.update);
public void Add()
=> this.Add(TValue: this._data[this._data.Count - 1], update: false);
public new void Sub(object source, TSeriesEventArgs e)
=> this.Add(TValue: this._data[this._data.Count - 1], update: e.update);
} }
public abstract class Pair_TSeries_Indicator : TSeries public abstract class Pair_TSeries_Indicator : TSeries
{ {
protected readonly TSeries _d1; protected readonly TSeries _d1;
@@ -83,24 +74,14 @@ public abstract class Pair_TSeries_Indicator : TSeries
} }
// overridable Add(Tvalue, Tvalue) method to add/update a single value at the end of the list // overridable Add(Tvalue, Tvalue) method to add/update a single value at the end of the list
public virtual void Add((System.DateTime t, double v)TValue1, (System.DateTime t, double v)TValue2, bool update) public virtual void Add((System.DateTime t, double v)TValue1, (System.DateTime t, double v)TValue2, bool update) => base.Add(TValue: (TValue1.t, 0), update: update); // default inserts zeros
=> base.Add(TValue: (TValue1.t, 0), update: update); // default inserts zeros
// potentially overridable Add() bulk variations (could be replaced with faster bulk algos) // potentially overridable Add() bulk variations (could be replaced with faster bulk algos)
public virtual void Add(TSeries d1, TSeries d2) { public virtual void Add(TSeries d1, TSeries d2) { for (int i = 0; i < d1.Count; i++) { this.Add(d1[i], d2[i], update: false); }}
for (int i = 0; i < d1.Count; i++) { this.Add(d1[i], d2[i], update: false); } public virtual void Add(TSeries d1, double dd2) { for (int i = 0; i < d1.Count; i++) { this.Add(d1[i], (d1[i].t, dd2), update: false); }}
} public virtual void Add(double dd1, TSeries d2) { for (int i = 0; i < d2.Count; i++) { this.Add((d2[i].t, dd1), d2[i], update: false); }}
public virtual void Add(TSeries d1, double dd2) {
for (int i = 0; i < d1.Count; i++) { this.Add(d1[i], (d1[i].t, dd2), update: false); }
}
public virtual void Add(double dd1, TSeries d2) {
for (int i = 0; i < d2.Count; i++) { this.Add((d2[i].t, dd1), d2[i], update: false); }
}
public void Add((System.DateTime t, double v)TValue1, (System.DateTime t, double v)TValue2) => this.Add(TValue1, TValue2, update: false);
public void Add((System.DateTime t, double v)TValue1, (System.DateTime t, double v)TValue2)
=> this.Add(TValue1, TValue2, update: false);
public void Add(bool update) public void Add(bool update)
{ {
@@ -123,12 +104,9 @@ public abstract class Pair_TSeries_Indicator : TSeries
} }
public void Add() => this.Add(update: false); public void Add() => this.Add(update: false);
public new void Sub(object source, TSeriesEventArgs e) => this.Add(e.update);
public new void Sub(object source, TSeriesEventArgs e)
=> this.Add(e.update);
} }
public abstract class Single_TBars_Indicator : TSeries public abstract class Single_TBars_Indicator : TSeries
{ {
protected readonly int _p; protected readonly int _p;
@@ -148,22 +126,10 @@ public abstract class Single_TBars_Indicator : TSeries
public virtual void Add((System.DateTime t, double o, double h, double l, double c, double v) TBar, bool update) => base.Add((TBar.t, 0.0), update); public virtual void Add((System.DateTime t, double o, double h, double l, double c, double v) TBar, bool update) => base.Add((TBar.t, 0.0), update);
// potentially overridable Add() method for the whole bars or series (could be replaced with faster bulk algo) // potentially overridable Add() method for the whole bars or series (could be replaced with faster bulk algo)
public virtual void Add(TBars bars) public virtual void Add(TBars bars) { for (int i = 0; i < bars.Count; i++) { this.Add(TBar: bars[i], update: false); }}
{ public virtual void Add(TSeries data) { for (int i = 0; i < data.Count; i++) { base.Add(TValue: data[i], update: false); }}
for (int i = 0; i < bars.Count; i++) { this.Add(TBar: bars[i], update: false); } public void Add((System.DateTime t, double o, double h, double l, double c, double v) TBar) => this.Add(TBar: TBar, update: false);
} public void Add(bool update) => this.Add(TBar: this._bars[this._bars.Count - 1], update: update);
public void Add() => this.Add(TBar: this._bars[this._bars.Count - 1], update: false);
public virtual void Add(TSeries data) public new void Sub(object source, TSeriesEventArgs e) => this.Add(TBar: this._bars[this._bars.Count - 1], update: e.update);
{
for (int i = 0; i < data.Count; i++) { base.Add(TValue: data[i], update: false); }
}
public void Add((System.DateTime t, double o, double h, double l, double c, double v) TBar)
=> this.Add(TBar: TBar, update: false);
public void Add(bool update)
=> this.Add(TBar: this._bars[this._bars.Count - 1], update: update);
public void Add()
=> this.Add(TBar: this._bars[this._bars.Count - 1], update: false);
public new void Sub(object source, TSeriesEventArgs e)
=> this.Add(TBar: this._bars[this._bars.Count - 1], update: e.update);
} }
-3
View File
@@ -75,7 +75,6 @@ public class TBars : System.Collections.Generic.List<(DateTime t, double o, doub
}; };
} }
public void Add((DateTime t, double o, double h, double l, double c, double v) i, bool update = false) public void Add((DateTime t, double o, double h, double l, double c, double v) i, bool update = false)
=> Add(i.t, i.o, i.h, i.l, i.c, i.v, update); => Add(i.t, i.o, i.h, i.l, i.c, i.v, update);
@@ -130,6 +129,4 @@ public class TBars : System.Collections.Generic.List<(DateTime t, double o, doub
Pub(this, new TSeriesEventArgs { update = update }); Pub(this, new TSeriesEventArgs { update = update });
} }
} }
} }
-1
View File
@@ -55,4 +55,3 @@ public class Alphavantage_Feed : TBars
return (date, o, h, l, c, v); return (date, o, h, l, c, v);
} }
} }
+3 -3
View File
@@ -38,11 +38,11 @@ public class GBM_Feed : TBars
double OCMax = Math.Max(Open,Close); double OCMax = Math.Max(Open,Close);
double High = (GBM_value(seed, volatility*0.5, 0)); double High = (GBM_value(seed, volatility*0.5, 0));
High = (High<OCMax)? 2*OCMax-High : High; High = (High<OCMax)? (2 * OCMax) - High : High;
double OCMin = Math.Min(Open,Close); double OCMin = Math.Min(Open,Close);
double Low = (GBM_value(seed, volatility*0.5, 0)); double Low = (GBM_value(seed, volatility*0.5, 0));
Low = (Low>OCMin)? 2*OCMin-Low : Low; Low = (Low>OCMin)? (2 * OCMin) - Low : Low;
double Volume = GBM_value(seed*10, volatility*2, Drift:0); double Volume = GBM_value(seed*10, volatility*2, Drift:0);
@@ -55,6 +55,6 @@ public class GBM_Feed : TBars
double U1 = 1.0-rnd.NextDouble(); double U1 = 1.0-rnd.NextDouble();
double U2 = 1.0-rnd.NextDouble(); double U2 = 1.0-rnd.NextDouble();
double Z = Math.Sqrt(-2.0 * Math.Log(U1)) * Math.Sin(2.0 * Math.PI * U2); double Z = Math.Sqrt(-2.0 * Math.Log(U1)) * Math.Sin(2.0 * Math.PI * U2);
return Seed * Math.Exp( Drift - (Volatility*Volatility*0.5) + Volatility * Z); return Seed * Math.Exp( Drift - (Volatility*Volatility*0.5) + (Volatility * Z));
} }
} }
+3 -3
View File
@@ -17,9 +17,9 @@ public class RND_Feed : TBars
double c = startvalue; double c = startvalue;
for (int i = 0; i < bars; i++) for (int i = 0; i < bars; i++)
{ {
double o = Math.Round(c + c * (volatility * 0.1 * rnd.NextDouble() - 0.005), 2); double o = Math.Round(c + (c * (volatility * 0.1 * rnd.NextDouble() - 0.005)), 2);
double h = Math.Round(o + c * volatility * rnd.NextDouble(), 2); double h = Math.Round(o + (c * volatility * rnd.NextDouble()), 2);
double l = Math.Round(o - c * volatility * rnd.NextDouble(), 2); double l = Math.Round(o - (c * volatility * rnd.NextDouble()), 2);
c = Math.Round(l + (h - l) * rnd.NextDouble(), 2); c = Math.Round(l + (h - l) * rnd.NextDouble(), 2);
double v = Math.Round(1000 * rnd.NextDouble(), 2); double v = Math.Round(1000 * rnd.NextDouble(), 2);
this.Add(DateTime.Today.AddDays(i - bars), o, h, l, c, v); this.Add(DateTime.Today.AddDays(i - bars), o, h, l, c, v);
-3
View File
@@ -62,7 +62,4 @@ public class ALMA_Series : Single_TSeries_Indicator
_norm += _wt; _norm += _wt;
} }
} }
} }
+1 -1
View File
@@ -50,7 +50,7 @@ public class ATRP_Series : Single_TBars_Indicator
for (int i = 0; i < _buffer.Count; i++) { _ema += _buffer[i]; } for (int i = 0; i < _buffer.Count; i++) { _ema += _buffer[i]; }
_ema /= this._buffer.Count; _ema /= this._buffer.Count;
} }
else { _ema = d.v * _k + _lastema * _k1m; } else { _ema = (d.v * _k) + (_lastema * _k1m); }
this._lastlastema = this._lastema; this._lastlastema = this._lastema;
this._lastema = _ema; this._lastema = _ema;
+1 -2
View File
@@ -13,7 +13,6 @@ Sources:
</summary> */ </summary> */
public class ATR_Series : Single_TBars_Indicator public class ATR_Series : Single_TBars_Indicator
{ {
private readonly System.Collections.Generic.List<double> _buffer = new(); private readonly System.Collections.Generic.List<double> _buffer = new();
@@ -53,7 +52,7 @@ public class ATR_Series : Single_TBars_Indicator
for (int i = 0; i < _buffer.Count; i++) { _ema += _buffer[i]; } for (int i = 0; i < _buffer.Count; i++) { _ema += _buffer[i]; }
_ema /= this._buffer.Count; _ema /= this._buffer.Count;
} }
else { _ema = d.v * _k + _lastema * _k1m; } else { _ema = (d.v * _k) + (_lastema * _k1m); }
this._lastlastema = this._lastema; this._lastlastema = this._lastema;
this._lastema = _ema; this._lastema = _ema;
+3 -5
View File
@@ -31,7 +31,6 @@ public class DEMA_Series : Single_TSeries_Indicator
public override void Add((DateTime t, double v) TValue, bool update) public override void Add((DateTime t, double v) TValue, bool update)
{ {
if (update) if (update)
{ {
this._lastema1 = this._lastlastema1; this._lastema1 = this._lastlastema1;
@@ -53,15 +52,14 @@ public class DEMA_Series : Single_TSeries_Indicator
for (int i = 0; i < _buffer.Count; i++) { _sma += _buffer[i]; } for (int i = 0; i < _buffer.Count; i++) { _sma += _buffer[i]; }
_sma /= this._buffer.Count; _sma /= this._buffer.Count;
_ema1 = _ema2 = _sma; _ema1 = _ema2 = _sma;
} }
else else
{ {
_ema1 = TValue.v * this._k + this._lastema1 * this._k1m; _ema1 = (TValue.v * this._k) + (this._lastema1 * this._k1m);
_ema2 = _ema1 * this._k + this._lastema2 * this._k1m; _ema2 = (_ema1 * this._k) + (this._lastema2 * this._k1m);
} }
double _dema = 2 * _ema1 - _ema2; double _dema = (2 * _ema1) - _ema2;
this._lastlastema1 = this._lastema1; this._lastlastema1 = this._lastema1;
this._lastlastema2 = this._lastema2; this._lastlastema2 = this._lastema2;
this._lastema1 = _ema1; this._lastema1 = _ema1;
+1 -1
View File
@@ -52,7 +52,7 @@ public class EMA_Series : Single_TSeries_Indicator
} }
else else
{ {
_ema = TValue.v * this._k + this._lastema * this._k1m; _ema = (TValue.v * this._k) + (this._lastema * this._k1m);
} }
this._lastlastema = this._lastema; this._lastlastema = this._lastema;
+1 -1
View File
@@ -51,7 +51,7 @@ public class RMA_Series : Single_TSeries_Indicator
} }
else else
{ {
_ema = TValue.v * _k + _lastema * _k1m; _ema = (TValue.v * _k) + (_lastema * _k1m);
} }
this._lastlastema = this._lastema; this._lastlastema = this._lastema;
+4 -5
View File
@@ -33,7 +33,6 @@ public class TEMA_Series : Single_TSeries_Indicator
public override void Add((DateTime t, double v) TValue, bool update) public override void Add((DateTime t, double v) TValue, bool update)
{ {
if (update) if (update)
{ {
this._lastema1 = this._lastlastema1; this._lastema1 = this._lastlastema1;
@@ -59,12 +58,12 @@ public class TEMA_Series : Single_TSeries_Indicator
} }
else else
{ {
_ema1 = TValue.v * this._k + this._lastema1 * this._k1m; _ema1 = (TValue.v * this._k) + (this._lastema1 * this._k1m);
_ema2 = _ema1 * this._k + this._lastema2 * this._k1m; _ema2 = (_ema1 * this._k) + (this._lastema2 * this._k1m);
_ema3 = _ema2 * this._k + this._lastema3 * this._k1m; _ema3 = (_ema2 * this._k) + (this._lastema3 * this._k1m);
} }
double _tema = 3 * (_ema1 - _ema2) + _ema3; double _tema = (3 * (_ema1 - _ema2)) + _ema3;
this._lastlastema1 = this._lastema1; this._lastlastema1 = this._lastema1;
this._lastlastema2 = this._lastema2; this._lastlastema2 = this._lastema2;
+1 -1
View File
@@ -60,7 +60,7 @@ public class ZLEMA_Series : Single_TSeries_Indicator
} }
else else
{ {
_ema = _zl * this._k + this._lastema * this._k1m; _ema = (_zl * this._k) + (this._lastema * this._k1m);
} }
this._lastlastema = this._lastema; this._lastlastema = this._lastema;
+1 -1
View File
@@ -54,7 +54,7 @@ public class KURT_Series : Single_TSeries_Indicator
} }
double _Vx = _s2 / (_n - 1); 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; 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 = (TValue.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); base.Add(result, update);
+1 -1
View File
@@ -37,7 +37,7 @@ public class MED_Series : Single_TSeries_Indicator
System.Collections.Generic.List<double> _s = new(this._buffer); System.Collections.Generic.List<double> _s = new(this._buffer);
_s.Sort(); _s.Sort();
int _p1 = _s.Count / 2; int _p1 = _s.Count / 2;
int _p2 = Math.Max(0, _s.Count / 2 - 1); int _p2 = Math.Max(0, (_s.Count / 2) - 1);
double _med = (_s.Count % 2 != 0) ? _s[_p1] : (_s[_p1] + _s[_p2]) / 2; double _med = (_s.Count % 2 != 0) ? _s[_p1] : (_s[_p1] + _s[_p2]) / 2;
var result = (TValue.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);
-1
View File
@@ -108,6 +108,5 @@ public class TBars_Test
s.Add(DateTime.Today, 0.1, 1.1, 2.1, 3.1, 4.1, false); s.Add(DateTime.Today, 0.1, 1.1, 2.1, 3.1, 4.1, false);
Assert.Equal(s.Close.v, t.v); Assert.Equal(s.Close.v, t.v);
Assert.Equal(s.Close.Count, t.Count); Assert.Equal(s.Close.Count, t.Count);
} }
} }
-2
View File
@@ -48,7 +48,6 @@ public class TSeries_Test
TSeries t = s; TSeries t = s;
Assert.Equal(5, (double)t); Assert.Equal(5, (double)t);
Assert.Equal(5, t.Count); Assert.Equal(5, t.Count);
} }
[Fact] [Fact]
public void BroadcastingEvents() public void BroadcastingEvents()
@@ -58,6 +57,5 @@ public class TSeries_Test
s.Pub += t.Sub; s.Pub += t.Sub;
s.Add(0.0, update: true); s.Add(0.0, update: true);
Assert.Equal(0.0, (double)t); Assert.Equal(0.0, (double)t);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class ALMA_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -52,7 +52,5 @@ public class BBANDS_Test
Assert.Equal(a.Count, c.PercentB.Count); Assert.Equal(a.Count, c.PercentB.Count);
Assert.Equal(a.Count, c.Zscore.Count); Assert.Equal(a.Count, c.Zscore.Count);
Assert.Equal(a.Count, c.Bandwidth.Count); Assert.Equal(a.Count, c.Bandwidth.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class DEMA_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class EMA_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class HEMA_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class HMA_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class JMA_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class KAMA_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class MACD_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class RMA_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class RSI_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class SMA_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class SMMA_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class TEMA_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class WMA_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class ZLEMA_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class BIAS_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class KURT_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class ENTP_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class LINREG_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class MAD_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class MAPE_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class MAX_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class MED_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class MIN_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class MSE_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class PSDEV_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class PVAR_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class SDEV_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class SMAPE_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class VAR_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-2
View File
@@ -27,7 +27,5 @@ public class WMAPE_Test
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.PositiveInfinity); a.Add(double.PositiveInfinity);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
} }
} }
-3
View File
@@ -1,5 +1,3 @@
using Xunit; using Xunit;
using System; using System;
using QuanTAlib; using QuanTAlib;
@@ -120,5 +118,4 @@ public class PandasTA
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7)); Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
} }
*/ */
} }
-2
View File
@@ -3,7 +3,6 @@ using QuanTAlib;
using Skender.Stock.Indicators; using Skender.Stock.Indicators;
using Xunit; using Xunit;
namespace Validation; namespace Validation;
public class Skender_Stock public class Skender_Stock
{ {
@@ -177,7 +176,6 @@ public class Skender_Stock
Assert.Equal(Math.Round((double)SK.Last().ZScore!, 8), Math.Round(QL.Zscore.Last().v, 8)); Assert.Equal(Math.Round((double)SK.Last().ZScore!, 8), Math.Round(QL.Zscore.Last().v, 8));
} }
[Fact] [Fact]
public void RSI() public void RSI()
{ {
-5
View File
@@ -75,7 +75,6 @@ public class TA_LIB
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 8), Math.Round(QL.Last().v, 8)); Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 8), Math.Round(QL.Last().v, 8));
} }
[Fact] [Fact]
public void SMA() public void SMA()
{ {
@@ -215,11 +214,8 @@ public class TA_LIB
Assert.Equal(Math.Round(outUpper[outUpper.Length - outBegIdx - 1], 7), Math.Round(QL.Upper.Last().v, 7)); Assert.Equal(Math.Round(outUpper[outUpper.Length - outBegIdx - 1], 7), Math.Round(QL.Upper.Last().v, 7));
Assert.Equal(Math.Round(outMiddle[outMiddle.Length - outBegIdx - 1], 7), Math.Round(QL.Mid.Last().v, 7)); Assert.Equal(Math.Round(outMiddle[outMiddle.Length - outBegIdx - 1], 7), Math.Round(QL.Mid.Last().v, 7));
Assert.Equal(Math.Round(outLower[outLower.Length - outBegIdx - 1], 7), Math.Round(QL.Lower.Last().v, 7)); Assert.Equal(Math.Round(outLower[outLower.Length - outBegIdx - 1], 7), Math.Round(QL.Lower.Last().v, 7));
} }
[Fact] [Fact]
public void HL2() public void HL2()
{ {
@@ -255,5 +251,4 @@ public class TA_LIB
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 8), Math.Round(QL.Last().v, 8)); Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 8), Math.Round(QL.Last().v, 8));
} }
} }