Documentation update

This commit is contained in:
Miha Kralj
2022-11-09 14:00:47 -08:00
parent 43a0f13dfb
commit 274c5d18da
12 changed files with 358 additions and 316 deletions
@@ -13,7 +13,7 @@ Sources:
</summary> */ </summary> */
public class ADO_Series : Single_TBars_Indicator public class ADOSC_Series : Single_TBars_Indicator
{ {
private readonly ADL_Series _TSadl; private readonly ADL_Series _TSadl;
@@ -21,7 +21,7 @@ public class ADO_Series : Single_TBars_Indicator
private readonly EMA_Series _TSfast; private readonly EMA_Series _TSfast;
private readonly SUB_Series _TSado; private readonly SUB_Series _TSado;
public ADO_Series(TBars source, bool useNaN = false) : base(source, period: 0, useNaN) public ADOSC_Series(TBars source, bool useNaN = false) : base(source, period: 0, useNaN)
{ {
_TSadl = new(source: source, useNaN: false); _TSadl = new(source: source, useNaN: false);
_TSslow = new(source: _TSadl, period: 10, useNaN: false); _TSslow = new(source: _TSadl, period: 10, useNaN: false);
+11 -12
View File
@@ -2,31 +2,28 @@
using System; using System;
/* <summary> /* <summary>
ATR: wildeR Moving Average ATRP: Average True Range Percent
The average true range (ATR) is a price volatility indicator Average True Range Percent is (ATR/Close Price)*100.
showing the average price variation of assets within a given time period. This normalizes so it can be compared to other stocks.
Sources: Sources:
https://en.wikipedia.org/wiki/Average_true_range https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/atrp
https://www.tradingview.com/wiki/Average_True_Range_(ATR)
https://www.investopedia.com/terms/a/atr.asp
</summary> */ </summary> */
public class ATRP_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();
private readonly double _k, _k1m; private readonly double _k, _k1m;
private double _lastema, _lastlastema, _lastcm1; private double _lastema, _lastlastema, _lastcm1;
private double _cm1 = double.NaN; private double _cm1 = double.NaN;
public ATR_Series(TBars source, int period, bool useNaN = false) : base(source, period, useNaN) public ATRP_Series(TBars source, int period, bool useNaN = false) : base(source, period, useNaN)
{ {
this._k = 1.0 / (double)(this._p); this._k = 1.0 / (double)(this._p);
this._k1m = 1.0 - this._k; this._k1m = 1.0 - this._k;
this._lastema = this._lastlastema = double.NaN; this._lastema = this._lastlastema = double.NaN;
if (this._bars.Count > 0) { base.Add(this._bars); } 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) public override void Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update)
@@ -36,7 +33,7 @@ public class ATR_Series : Single_TBars_Indicator
this._cm1 = this._lastcm1; this._cm1 = this._lastcm1;
} }
if (this._cm1 is double.NaN) { this._cm1 = TBar.c; } if (_cm1 is double.NaN) { _cm1 = TBar.c; }
double d1 = Math.Abs(TBar.h - TBar.l); double d1 = Math.Abs(TBar.h - TBar.l);
double d2 = Math.Abs(_cm1 - TBar.h); double d2 = Math.Abs(_cm1 - TBar.h);
double d3 = Math.Abs(_cm1 - TBar.l); double d3 = Math.Abs(_cm1 - TBar.l);
@@ -58,7 +55,9 @@ public class ATR_Series : Single_TBars_Indicator
this._lastlastema = this._lastema; this._lastlastema = this._lastema;
this._lastema = _ema; this._lastema = _ema;
var ret = (d.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _ema); double _atrp = 100 * (_ema / TBar.c);
var ret = (d.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _atrp);
base.Add(ret, update); base.Add(ret, update);
} }
} }
+12 -11
View File
@@ -2,28 +2,31 @@
using System; using System;
/* <summary> /* <summary>
ATRP: Average True Range Percent ATR: wildeR Moving Average
Average True Range Percent is (ATR/Close Price)*100. The average true range (ATR) is a price volatility indicator
This normalizes so it can be compared to other stocks. showing the average price variation of assets within a given time period.
Sources: Sources:
https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/atrp https://en.wikipedia.org/wiki/Average_true_range
https://www.tradingview.com/wiki/Average_True_Range_(ATR)
https://www.investopedia.com/terms/a/atr.asp
</summary> */ </summary> */
public class ATRP_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();
private readonly double _k, _k1m; private readonly double _k, _k1m;
private double _lastema, _lastlastema, _lastcm1; private double _lastema, _lastlastema, _lastcm1;
private double _cm1 = double.NaN; private double _cm1 = double.NaN;
public ATRP_Series(TBars source, int period, bool useNaN = false) : base(source, period, useNaN) public ATR_Series(TBars source, int period, bool useNaN = false) : base(source, period, useNaN)
{ {
this._k = 1.0 / (double)(this._p); this._k = 1.0 / (double)(this._p);
this._k1m = 1.0 - this._k; this._k1m = 1.0 - this._k;
this._lastema = this._lastlastema = double.NaN; 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) public override void Add((DateTime t, double o, double h, double l, double c, double v) TBar, bool update)
@@ -33,7 +36,7 @@ public class ATRP_Series : Single_TBars_Indicator
this._cm1 = this._lastcm1; 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 d1 = Math.Abs(TBar.h - TBar.l);
double d2 = Math.Abs(_cm1 - TBar.h); double d2 = Math.Abs(_cm1 - TBar.h);
double d3 = Math.Abs(_cm1 - TBar.l); double d3 = Math.Abs(_cm1 - TBar.l);
@@ -55,9 +58,7 @@ public class ATRP_Series : Single_TBars_Indicator
this._lastlastema = this._lastema; this._lastlastema = this._lastema;
this._lastema = _ema; this._lastema = _ema;
double _atrp = 100 * (_ema / TBar.c); var ret = (d.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _ema);
var ret = (d.t, this.Count < this._p - 1 && this._NaN ? double.NaN : _atrp);
base.Add(ret, update); base.Add(ret, update);
} }
} }
-43
View File
@@ -1,43 +0,0 @@
namespace QuanTAlib;
using System;
/* <summary>
PVAR: Population Variance
Population variance without Bessel's correction
Sources:
https://en.wikipedia.org/wiki/Variance
Bessel's correction: https://en.wikipedia.org/wiki/Bessel%27s_correction
Remark:
PVAR (Population Variance) is also known as a biased Sample Variance. For unbiased
sample variance use SVAR instead.
</summary> */
public class PVAR_Series : Single_TSeries_Indicator
{
public PVAR_Series(TSeries source, int period, bool useNaN = false) : base(source, period, useNaN)
{
if (base._data.Count > 0) { base.Add(base._data); }
}
private readonly System.Collections.Generic.List<double> _buffer = new();
public override void Add((System.DateTime t, double v) TValue, bool update)
{
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;
double _pvar = 0;
for (int i = 0; i < _buffer.Count; i++) { _pvar += (_buffer[i] - _sma) * (_buffer[i] - _sma); }
_pvar /= this._buffer.Count;
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _pvar);
base.Add(result, update);
}
}
+43
View File
@@ -0,0 +1,43 @@
namespace QuanTAlib;
using System;
/* <summary>
SVAR: Sample Variance
Sample variance uses Bessel's correction to correct the bias in the estimation of population variance.
Sources:
https://en.wikipedia.org/wiki/Variance
Bessel's correction: https://en.wikipedia.org/wiki/Bessel%27s_correction
Remark:
SVAR is also known as the Unbiased Sample Variance, while VAR (Population Variance) is known as
the Biased Sample Variance.
</summary> */
public class SVAR_Series : Single_TSeries_Indicator
{
public SVAR_Series(TSeries source, int period, bool useNaN = false) : base(source, period, useNaN)
{
if (base._data.Count > 0) { base.Add(base._data); }
}
private readonly System.Collections.Generic.List<double> _buffer = new();
public override void Add((System.DateTime t, double v) TValue, bool update)
{
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;
for (int i = 0; i < this._buffer.Count; i++) { _sma += this._buffer[i]; }
_sma /= this._buffer.Count;
double _svar = 0;
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 = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _svar);
base.Add(result, update);
}
}
+12 -12
View File
@@ -2,16 +2,16 @@
using System; using System;
/* <summary> /* <summary>
VAR: Sample Variance VAR: Population Variance
Sample variance uses Bessel's correction to correct the bias in the estimation of population variance. Population variance without Bessel's correction
Sources: Sources:
https://en.wikipedia.org/wiki/Variance https://en.wikipedia.org/wiki/Variance
Bessel's correction: https://en.wikipedia.org/wiki/Bessel%27s_correction Bessel's correction: https://en.wikipedia.org/wiki/Bessel%27s_correction
Remark: Remark:
VAR is also known as the Unbiased Sample Variance, while PVAR (Population Variance) is known as VAR (Population Variance) is also known as a biased Sample Variance. For unbiased
the Biased Sample Variance. sample variance use SVAR instead.
</summary> */ </summary> */
@@ -25,19 +25,19 @@ public class VAR_Series : Single_TSeries_Indicator
public override void Add((System.DateTime t, double v) TValue, bool update) public override void Add((System.DateTime t, double v) TValue, bool update)
{ {
if (update) { this._buffer[this._buffer.Count - 1] = TValue.v; } if (update) { _buffer[_buffer.Count - 1] = TValue.v; }
else { this._buffer.Add(TValue.v); } else { _buffer.Add(TValue.v); }
if (this._buffer.Count > this._p && this._p != 0) { this._buffer.RemoveAt(0); } if (_buffer.Count > this._p && this._p != 0) { _buffer.RemoveAt(0); }
double _sma = 0; double _sma = 0;
for (int i = 0; i < this._buffer.Count; i++) { _sma += this._buffer[i]; } for (int i = 0; i < _buffer.Count; i++) { _sma += _buffer[i]; }
_sma /= this._buffer.Count; _sma /= this._buffer.Count;
double _svar = 0; double _pvar = 0;
for (int i = 0; i < this._buffer.Count; i++) { _svar += (this._buffer[i] - _sma) * (this._buffer[i] - _sma); } for (int i = 0; i < _buffer.Count; i++) { _pvar += (_buffer[i] - _sma) * (_buffer[i] - _sma); }
_svar /= (this._buffer.Count > 1) ? this._buffer.Count - 1 : 1; // Bessel's correction _pvar /= this._buffer.Count;
var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _svar); var result = (TValue.t, (this.Count < this._p - 1 && this._NaN) ? double.NaN : _pvar);
base.Add(result, update); base.Add(result, update);
} }
} }
+2 -2
View File
@@ -9,7 +9,7 @@ public class PVAR_Test
public void Add_Test() public void Add_Test()
{ {
TSeries a = new() { 0, 1, 2, 3, 4, 5 }; TSeries a = new() { 0, 1, 2, 3, 4, 5 };
PVAR_Series c = new(a, 3); SVAR_Series c = new(a, 3);
Assert.Equal(6, c.Count); Assert.Equal(6, c.Count);
a.Add(5); a.Add(5);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
@@ -21,7 +21,7 @@ public class PVAR_Test
public void Edge_Test() public void Edge_Test()
{ {
TSeries a = new() { double.NaN, double.Epsilon, double.PositiveInfinity, double.MaxValue }; TSeries a = new() { double.NaN, double.Epsilon, double.PositiveInfinity, double.MaxValue };
PVAR_Series c = new(a, 3); SVAR_Series c = new(a, 3);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.NaN); a.Add(double.NaN);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
+2 -2
View File
@@ -9,7 +9,7 @@ public class VAR_Test
public void Add_Test() public void Add_Test()
{ {
TSeries a = new() { 0, 1, 2, 3, 4, 5 }; TSeries a = new() { 0, 1, 2, 3, 4, 5 };
VAR_Series c = new(a, 3); SVAR_Series c = new(a, 3);
Assert.Equal(6, c.Count); Assert.Equal(6, c.Count);
a.Add(5); a.Add(5);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
@@ -21,7 +21,7 @@ public class VAR_Test
public void Edge_Test() public void Edge_Test()
{ {
TSeries a = new() { double.NaN, double.Epsilon, double.PositiveInfinity, double.MaxValue }; TSeries a = new() { double.NaN, double.Epsilon, double.PositiveInfinity, double.MaxValue };
VAR_Series c = new(a, 3); SVAR_Series c = new(a, 3);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
a.Add(double.NaN); a.Add(double.NaN);
Assert.Equal(a.Count, c.Count); Assert.Equal(a.Count, c.Count);
+1
View File
@@ -33,6 +33,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0-preview-20221003-04" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0-preview-20221003-04" />
<PackageReference Include="Python.Included" Version="3.10.0-preview5" />
<PackageReference Include="TALib.NETCore" Version="0.4.4" /> <PackageReference Include="TALib.NETCore" Version="0.4.4" />
<PackageReference Include="Skender.Stock.Indicators" Version="2.4.0" /> <PackageReference Include="Skender.Stock.Indicators" Version="2.4.0" />
<PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit" Version="2.4.2" />
+74 -74
View File
@@ -1,4 +1,4 @@
/*
using Xunit; using Xunit;
using System; using System;
@@ -20,6 +20,8 @@ public class PandasTA
this.bars = new(1000); this.bars = new(1000);
this.period = this.rnd.Next(28) + 3; this.period = this.rnd.Next(28) + 3;
Runtime.PythonDLL = @"python310.dll";
Installer.InstallPath = Path.GetFullPath(".");
Installer.SetupPython().Wait(); Installer.SetupPython().Wait();
Installer.TryInstallPip(); Installer.TryInstallPip();
Installer.PipInstallModule("numpy"); Installer.PipInstallModule("numpy");
@@ -34,91 +36,89 @@ public class PandasTA
{ {
PythonEngine.Shutdown(); PythonEngine.Shutdown();
} }
/*
[Fact]
void SMA()
{
SMA_Series QL = new(this.bars.Close, this.period, false);
var pta = this.ta.sma(close: this.df[0], length: this.period);
[Fact] Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
void SMA() }
{
SMA_Series QL = new(this.bars.Close, this.period, false);
var pta = this.ta.sma(close: this.df[0], length: this.period);
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
}
[Fact] [Fact]
void EMA() void EMA()
{ {
EMA_Series QL = new(this.bars.Close, this.period, false); EMA_Series QL = new(this.bars.Close, this.period, false);
var pta = this.ta.ema(close: this.df[0], length: this.period); var pta = this.ta.ema(close: this.df[0], length: this.period);
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));
} }
[Fact] [Fact]
void TEMA() void TEMA()
{ {
TEMA_Series QL = new(this.bars.Close, this.period, false); TEMA_Series QL = new(this.bars.Close, this.period, false);
var pta = this.ta.tema(close: this.df[0], length: this.period); var pta = this.ta.tema(close: this.df[0], length: this.period);
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));
} }
[Fact] [Fact]
void ENTP() void ENTP()
{ {
ENTP_Series QL = new(this.bars.Close, this.period, useNaN:false); ENTP_Series QL = new(this.bars.Close, this.period, useNaN:false);
var pta = this.ta.entropy(close: this.df[0], length: this.period); var pta = this.ta.entropy(close: this.df[0], length: this.period);
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));
} }
[Fact] [Fact]
void WMA() void WMA()
{ {
WMA_Series QL = new(this.bars.Close, this.period, false); WMA_Series QL = new(this.bars.Close, this.period, false);
var pta = this.ta.wma(close: this.df[0], length: this.period); var pta = this.ta.wma(close: this.df[0], length: this.period);
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
}
[Fact]
void DEMA()
{
DEMA_Series QL = new(this.bars.Close, this.period, false);
var pta = this.ta.dema(close: this.df[0], length: this.period);
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
}
[Fact]
void BIAS()
{
BIAS_Series QL = new(this.bars.Close, this.period, false);
var pta = this.ta.bias(close: this.df[0], length: this.period);
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));
} }
[Fact] [Fact]
void KURT() void DEMA()
{ {
KURT_Series QL = new(this.bars.Close, this.period, useNaN: false); DEMA_Series QL = new(this.bars.Close, this.period, false);
var pta = this.ta.kurtosis(close: this.df[0], length: this.period); var pta = this.ta.dema(close: this.df[0], length: this.period);
Assert.Equal(System.Math.Round((double)pta.tail(1), 4), Math.Round(QL.Last().v, 4)); Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
} }
[Fact] [Fact]
void MAD() void BIAS()
{ {
MAD_Series QL = new(this.bars.Close, this.period, useNaN: false); BIAS_Series QL = new(this.bars.Close, this.period, false);
var pta = this.ta.mad(close: this.df[0], length: this.period); var pta = this.ta.bias(close: this.df[0], length: this.period);
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));
} }
}
*/ [Fact]
void KURT()
{
KURT_Series QL = new(this.bars.Close, this.period, useNaN: false);
var pta = this.ta.kurtosis(close: this.df[0], length: this.period);
Assert.Equal(System.Math.Round((double)pta.tail(1), 4), Math.Round(QL.Last().v, 4));
}
[Fact]
void MAD()
{
MAD_Series QL = new(this.bars.Close, this.period, useNaN: false);
var pta = this.ta.mad(close: this.df[0], length: this.period);
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
}
*/
}
+41 -5
View File
@@ -30,6 +30,42 @@ public class TA_LIB
///////////////////////////////////////// /////////////////////////////////////////
[Fact]
public void ADD()
{
ADD_Series QL = new(this.bars.Open, this.bars.Close);
Core.Add(this.inopen, this.inclose, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _);
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 8), Math.Round(QL.Last().v, 8));
}
[Fact]
public void SUB()
{
SUB_Series QL = new(this.bars.Open, this.bars.Close);
Core.Sub(this.inopen, this.inclose, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _);
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 8), Math.Round(QL.Last().v, 8));
}
[Fact]
public void MUL()
{
MUL_Series QL = new(this.bars.Open, this.bars.Close);
Core.Mult(this.inopen, this.inclose, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _);
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 8), Math.Round(QL.Last().v, 8));
}
[Fact]
public void DIV()
{
DIV_Series QL = new(this.bars.Open, this.bars.Close);
Core.Div(this.inopen, this.inclose, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _);
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 8), Math.Round(QL.Last().v, 8));
}
[Fact] [Fact]
public void SDEV() public void SDEV()
{ {
@@ -112,9 +148,9 @@ public class TA_LIB
} }
[Fact] [Fact]
public void ADO() public void ADOSC()
{ {
ADO_Series QL = new(this.bars, false); ADOSC_Series QL = new(this.bars, false);
Core.AdOsc(this.inhigh, this.inlow, this.inclose, this.involume, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _); Core.AdOsc(this.inhigh, this.inlow, this.inclose, this.involume, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _);
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));
@@ -175,9 +211,9 @@ public class TA_LIB
double[] outLower = new double[this.bars.Count]; double[] outLower = new double[this.bars.Count];
BBANDS_Series QL = new(this.bars.Close, period:26, multiplier:2.0, false); BBANDS_Series QL = new(this.bars.Close, period:26, multiplier:2.0, false);
Core.Bbands(this.inclose, 0, this.bars.Count - 1, outRealUpperBand: outUpper, outRealMiddleBand: outMiddle, outRealLowerBand: outLower, out int outBegIdx, out _, optInTimePeriod:26, optInNbDevUp:2.0, optInNbDevDn:2.0); Core.Bbands(this.inclose, 0, this.bars.Count - 1, outRealUpperBand: outUpper, outRealMiddleBand: outMiddle, outRealLowerBand: outLower, out int outBegIdx, out _, optInTimePeriod:26, optInNbDevUp:2.0, optInNbDevDn:2.0);
Assert.Equal(Math.Round(outUpper[outUpper.Length - outBegIdx - 1], 8), Math.Round(QL.Upper.Last().v, 8)); 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], 8), Math.Round(QL.Mid.Last().v, 8)); 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], 8), Math.Round(QL.Lower.Last().v, 8)); Assert.Equal(Math.Round(outLower[outLower.Length - outBegIdx - 1], 7), Math.Round(QL.Lower.Last().v, 7));
} }
+158 -153
View File
@@ -1,155 +1,160 @@
# Coverage of indicators # Coverage of indicators
| Indicator | QuanTAlib | TA-LIB | Skender | Pandas-TA | ✔️= Calculation exists in QuanTAlib
|--|:--:|:--:|:--:|:--:|
| **Basics** ||||| ⭐= Calculation is validated against other TA libraries
| OC2 - (Open+Close)/2 |✔️|||✔️|
| HL2 - (High+Low)/2 |✔️|||✔️| | **BASIC TRANSFORMS** | **QuanTAlib** | **TA-LIB** | **Skender** |
| HLC3 - Typical Price |✔️|||✔️| |--|:--:|:--:|:--:|
| OHL3 - (Open+High+Low)/3 |✔️|||✔️| | ✔️ OC2 - (Open+Close)/2 | .OC2 || GetBaseQuote |
| OHLC4 - (O+H+L+C)/4 |✔️|||✔️| | ⭐ HL2 - Median Price | .HL2 | MEDPRICE | GetBaseQuote |
| HLCC4 - Weighted Price |✔️||✔️|✔️| | HLC3 - Typical Price | .HLC3 | TYPPRICE ||
| ZL - Zero Lag - De-lagged price |✔️|||✔️| | ✔️ OHL3 - (Open+High+Low)/3 | .OHL3 |||
| ADD - Addition |✔️|✔️||| | ⭐ OHLC4 - Average Price | .OHLC4 | AVGPRICE | GetBaseQuote |
| SUB - Subtraction |✔️|✔️||| | ⭐ HLCC4 - Weighted Price | .HLCC4 | WCLPRICE ||
| MUL - Multiplication |✔️|✔️||| | ✔️ ZL - De-lagged price (Zero-Lag) | ZL_Series |||
| DIV - Division |✔️|✔️||| | ⭐ ADD - Addition | ADD_Series | ADD ||
|||||| | ⭐ SUB - Subtraction | SUB_Series | SUB ||
| **Statistics** ||||| | ⭐ MUL - Multiplication | MUL_Series | MUL ||
| BETA - Beta coefficient |||✔️|| | ⭐ DIV - Division | DIV_Series | DIV ||
| BIAS - Bias |✔️|||✔️| |||||
| ENTR - Entropy |✔️|||✔️| | **STATISTICS & NUMERICAL ANALYSIS** | **QuanTAlib** | **TA-LIB** | **Skender** |
| KUR - Kurtosis |✔️|||✔️| | ✔️ BIAS - Bias | BIAS_Series |||
| LINREG - Linear Regression |✔️|✔️|✔️|| | ✔️ ENTP - Entropy | ENTP_Series |||
| MAD - Mean Absolute Deviation |✔️||✔️|✔️| | ✔️ KURT - Kurtosis | KURT_Series |||
| MAPE - Mean Absolute Percent Error |✔️||✔️|| | ⭐ LINREG - Linear Regression | LINREG_Series |||
| MAX - Max value |✔️|✔️||| | MAD - Mean Absolute Deviation | MAD_Series |||
| MIN - Min value |✔️|✔️||| | ⭐ MAPE - Mean Absolute Percent Error | MAPE_Series |||
| MED - Median value |✔️|✔️||✔️| | ✔️ MED - Median value | MED_Series |||
| MSE - Mean Squared Error |✔️||✔️|| | ⭐ MAX - Max value | MAX_Series |||
| PSDEV - Population Standard Deviation |✔️|||| | ⭐ MIN - Min value | MIN_Series |||
| PVAR - Population Variance |✔️|||| | ✔️ MSE - Mean Squared Error | MSE_Series |||
| QUANTILE ||||✔️| | ⛔ SKEW - Skewness ||||
| SKEW - Skewness ||||✔️| | ⭐ SDEV - Standard Deviation (Volatility) | SDEV_Series |||
| SMAPE - Symmetric Mean Absolute Percent Error |✔️|||| | ✔️ SSDEV - Sample Standard Deviation | SSDEV_Series |||
| SDEV - Sample Standard Deviation |✔️|✔️|✔️|✔️| | ✔️ SMAPE - Symmetric Mean Absolute Percent Error | SMAPE_Series |||
| VAR - Sample Variance |✔️|||✔️| | ✔️ VAR - Population Variance | VAR_Series |||
| WMAPE - Weighted Mean Absolute Percent Error |✔️|||| | ✔️ SVAR - Sample Variance | SVAR_Series |||
| ZSCORE |||✔️|✔️| | ⛔ QUANT - Quantile ||||
|||||| | ✔️ WMAPE - Weighted Mean Absolute Percent Error | WMAPE_Series |||
| **Moving Averages** ||||| | ⛔ ZSCORE - Number of standard deviations from mean ||||
| AFIRMA - Autoregressive Finite Impulse Response Moving Average ||||| |||||
| ALMA - Arnaud Legoux Moving Average |✔️||✔️|✔️| | **TREND INDICATORS & AVERAGES** | **QuanTAlib** | **TA-LIB** | **Skender** |
| ARIMA - Autoregressive Integrated Moving Average ||||| | ⛔ AFIRMA - Autoregressive Finite Impulse Response Moving Average ||||
| ATR - Average True Range |✔️|✔️|✔️|✔️| | ⭐ ALMA - Arnaud Legoux Moving Average | ALMA_Series || GetAlma |
| ATRP - Average True Range Percent |✔️||✔️|| | ⛔ ARIMA - Autoregressive Integrated Moving Average ||||
| DEMA - Double EMA |✔️|✔️|✔️|✔️| | DEMA - Double EMA Average | DEMA_Series |||
| EMA - Exponential Moving Average |✔️|✔️|✔️|✔️| | EMA - Exponential Moving Average | EMA_Series |||
| EPMA - Endpoint Moving Average |||✔️|| | EPMA - Endpoint Moving Average ||||
| FWMA - Fibonacci's Weighted Moving Average ||||✔️| | FWMA - Fibonacci's Weighted Moving Average ||||
| HEMA - Hull Exponential Moving Average |✔️|||| | ✔️ HEMA - Hull/EMA Average | HEMA_Series |||
| HMA - Hull Moving Average |✔️||✔️|✔️| | HMA - Hull Moving Average | HMA_Series |||
| HWMA - Holt-Winter Moving Average ||||✔️| | HWMA - Holt-Winter Moving Average ||||
| JMA - Jurik Moving Average |✔️|||✔️| | ✔️ JMA - Jurik Moving Average | JMA_Series |||
| KAMA - Kaufman's Adaptive Moving Average |✔️|✔️|✔️|✔️| | KAMA - Kaufman's Adaptive Moving Average | KAMA_Series |||
| LSMA - Least Squares Moving Average |||✔️|| | LSMA - Least Squares Moving Average ||||
| MACD - Moving Average Convergence/Divergence |✔️|✔️|✔️|✔️| | MACD - Moving Average Convergence/Divergence | MACD_Series |||
| MAMA - MESA Adaptive Moving Average ||✔️|✔️|| | MAMA - MESA Adaptive Moving Average ||||
| MMA - Modified Moving Average |||✔️|| | MMA - Modified Moving Average ||||
| NATR - Normalized Average True Range ||✔️|✔️|✔️| | ⛔ PPMA - Pivot Point Moving Average ||||
| PPMA - Pivot Point Moving Average |||✔️|| | ⛔ PWMA - Pascal's Weighted Moving Average ||||
| PWMA - Pascal's Weighted Moving Average ||||✔️| | ✔️ RMA - WildeR's Moving Average | RMA__Series |||
| RMA - WildeR's Moving Average |✔️|||✔️| | ⛔ SINWMA - Sine Weighted Moving Average ||||
| SINWMA - Sine Weighted Moving Average ||||✔️| | ⭐ SMA - Simple Moving Average | SMA_Series |||
| SMA - Simple Moving Average |✔️|✔️|✔️|✔️| | ⭐ SMMA - Smoothed Moving Average | SMMA_Series |||
| SMMA - Smoothed Moving Average |✔️||✔️|| | ⛔ SSF - Ehler's Super Smoother Filter ||||
| STOCH - Stochastic Oscillator ||✔️|✔️|✔️| | ⛔ SUP - Supertrend ||||
| SSF - Ehler's Super Smoother Filter ||||✔️| | ⛔ SWMA - Symmetric Weighted Moving Average ||||
| SUP - Supertrend |||✔️|✔️| | ⛔ T3 - Tillson T3 Moving Average ||||
| SWMA - Symmetric Weighted Moving Average ||||✔️| | ⭐ TEMA - Triple EMA Average | TEMA_Series |||
| T3 - Tillson T3 Moving Average ||✔️|✔️|✔️| | ⛔ TRIMA - Triangular Moving Average ||||
| TEMA - Triple EMA |✔️|✔️|✔️|✔️| | ⛔ VIDYA - Variable Index Dynamic Average ||||
| TRIMA - Triangular Moving Average ||✔️||✔️| | ⭐ WMA - Weighted Moving Average | WMA_Series |||
| VIDYA - Variable Index Dynamic Average ||||✔️| | ✔️ ZLEMA - Zero Lag EMA Average | ZLEMA_Series |||
| VWAP - Volume Weighted Average Price |||✔️|✔️| |||||
| VWMA - Volume Weighted Moving Average |||✔️|✔️| | **VOLATILITY INDICATORS** | **QuanTAlib** | **TA-LIB** | **Skender** |
| WMA - Weighted Moving Average |✔️|✔️|✔️|✔️| | ⭐ ADL - Chaikin Accumulation Distribution Line | ADL_Series |||
| ZLEMA - Zero Lag EMA |✔️|||✔️| | ⭐ ADOSC - Chaikin Accumulation Distribution Oscillator | ADOSC_Series |||
|||||| | ⭐ ATR - Average True Range | ATR_Series | ATR | GetAtr |
| **Oscillators and Indices** ||||| | ⭐ ATRP - Average True Range Percent | ATRP_Series |||
| AC - Acceleration Oscillator ||||✔️| | ✔️ BETA - Beta coefficient ||||
| AD - Chaikin Accumulation Distribution ||✔️|✔️|✔️| | ⭐ BBANDS - Bollinger Bands® | BBANDS_Series | BBANDS | GetBollingerBands |
| ADOSC - Chaikin Accumulation Distribution Oscillator ||✔️|✔️|| | ⛔ CRSI - Connor RSI ||||
| ADX - Average Directional Movement Index ||✔️|✔️|✔️| | ⛔ DON - Donchian Channels ||||
| ADXR - Average Directional Movement Index Rating ||✔️|✔️|| | ⛔ FCB - Fractal Chaos Bands ||||
| AO - Awesome Oscillator |||✔️|✔️| | ⛔ HV - Historical Volatility ||||
| APO - Absolute Price Oscillator ||✔️||✔️| | ⛔ ICH - Ichimoku ||||
| AROON - Aroon oscillator ||✔️|✔️|✔️| | ⛔ KEL - Keltner Channels ||||
| BBANDS - Bollinger Bands ||✔️|✔️|✔️| | ⛔ NATR - Normalized Average True Range ||||
| BOP - Balance of Power ||✔️|✔️|✔️| | ⭐ RSI - Relative Strength Index | RSI_Series ||
| CCI - Commodity Channel Index |✔️|✔️|✔️|✔️| | ⛔ SRSI - Stochastic RSI ||||
| CFO - Chande Forcast Oscillator ||||✔️| | ⛔ STARC - Starc Bands ||||
| CMF - Chaikin Money Flow |||✔️|✔️| | ⭐ TR - True Range | TR_Series |||
| CMO - Chande Momentum Oscillator ||✔️||✔️| | ⛔ UI - Ulcer Index ||||
| COG - Center of Gravity ||||✔️| | ⛔ VSTOP - Volatility Stop ||||
| CRSI - Connor RSI |||✔️|| |||||
| CTI - Ehler's Correlation Trend Indicator ||||✔️| | **MOMENTUM INDICATORS & OSCILLATORS** | **QuanTAlib** | **TA-LIB** | **Skender** |
| DMI - Directional Movement Index ||✔️|✔️|✔️| | ⛔ AC - Acceleration Oscillator ||||
| EFI - Elder Ray's Force Index |||✔️|✔️| | ⛔ ADX - Average Directional Movement Index ||||
| GAT - Alligator oscillator |||✔️|| | ⛔ ADXR - Average Directional Movement Index Rating ||||
| KRI - Kairi Relative Index ||||| | ⛔ AO - Awesome Oscillator ||||
| KVO - Klinger Volume Oscillator |||✔️|✔️| | ⛔ APO - Absolute Price Oscillator ||||
| MFI - Money Flow Index ||✔️|✔️|✔️| | ⛔ AROON - Aroon oscillator ||||
| MOM - Momentum |||✔️|✔️| | ⛔ BOP - Balance of Power ||||
| NVI - Negative Volume Index ||||✔️| | ⭐ CCI - Commodity Channel Index | CCI_Series |||
| PO - Price Oscillator ||||✔️| | ⛔ CFO - Chande Forcast Oscillator ||||
| PPO - Percentage Price Oscillator ||✔️||✔️| | ⛔ CMF - Chaikin Money Flow ||||
| PVI - Positive Volume Index ||||✔️| | ⛔ CMO - Chande Momentum Oscillator ||||
| RSI - Relative Strength Index |✔️|✔️|✔️|✔️| | ⛔ COG - Center of Gravity ||||
| RVGI - Relative Vigor Index ||||✔️| | ⛔ CTI - Ehler's Correlation Trend Indicator ||||
| SRSI - Stochastic RSI |||✔️|✔️| | ⛔ DPO - De-trended Price Oscillator ||||
| TRIX - 1-day ROC of TEMA ||✔️|✔️|✔️| | ⛔ DMI - Directional Movement Index ||||
| TSI - True Strength Index |||✔️|✔️| | ⛔ EFI - Elder Ray's Force Index ||||
| UI - Ulcer Index |||✔️|✔️| | ⛔ GAT - Alligator oscillator ||||
| UO - Ultimate Oscillator ||✔️|✔️|✔️| | ⛔ KRI - Kairi Relative Index ||||
| WGAT - Williams Alligator |||✔️|| | ⛔ KVO - Klinger Volume Oscillator ||||
|||||| | ⛔ MFI - Money Flow Index ||||
| **Volume** ||||| | ⛔ MOM - Momentum ||||
| AOBV - Archer On-Balance Volume ||||✔️| | ⛔ NVI - Negative Volume Index ||||
| OBV - On-Balance Volume ||✔️|✔️|✔️| | ⛔ PO - Price Oscillator ||||
| PRS - Price Relative Strength |||✔️|| | ⛔ PPO - Percentage Price Oscillator ||||
| PVOL - Price-Volume ||||| | ⛔ PMO - Price Momentum Oscillator ||||
| PVR - Price Volume Rank ||||✔️| | PVI - Positive Volume Index ||||
| PVT - Price Volume Trend ||||✔️| | ⛔ RVGI - Relative Vigor Index ||||
| VP - Volume Profile ||||✔️| | ⛔ SMI - Stochastic Momentum Index ||||
|||||| | ⛔ STOCH - Stochastic Oscillator ||||
|**Unsorted**||||| | ⛔ TRIX - 1-day ROC of TEMA ||||
| CHN - Price Channel |||✔️|| | ⛔ TSI - True Strength Index ||||
| COPPOCK - Coppock Curve ||||✔️| | ⛔ UO - Ultimate Oscillator ||||
| CORREL - Pearson's Correlation Coefficient ||✔️|✔️|| | ⛔ WGAT - Williams Alligator ||||
| EOM - Ease of Movement ||||✔️| |||||
| HILO - Gann High-Low Activator ||||✔️| | **VOLUME INDICATORS** | **QuanTAlib** | **TA-LIB** | **Skender** |
| HV - Historical Volatility |||✔️|| | ⛔ AOBV - Archer On-Balance Volume ||||
| HT - HT Trendline |||✔️|| | ⛔ OBV - On-Balance Volume ||||
| ICH - Ichimoku |||✔️|✔️| | ⛔ PRS - Price Relative Strength |||
| MCGD - McGinley Dynamic ||||✔️| | ⛔ PVOL - Price-Volume ||||
| ROC - Rate of Change ||✔️|✔️|✔️| | ⛔ PVO - Percentage Volume Oscillator ||||
| SAR - Parabolic Stop and Reverse ||✔️|✔️|✔️| | ⛔ PVR - Price Volume Rank ||||
| STC - Schaff Trend Cycle |||✔️|✔️| | ⛔ PVT - Price Volume Trend ||||
| TR - True Range ||✔️|✔️|✔️| | ⛔ VP - Volume Profile ||||
| WILLR - Larry Williams' %R ||✔️|✔️|✔️| | ⛔ VWAP - Volume Weighted Average Price ||||
| HURST - Hurst Exponent |||✔️|| | ⛔ VWMA - Volume Weighted Moving Average ||||
| VOR - Vortex Indicator |||✔️|✔️| |||||
| DON - Donchian Channels |||✔️|✔️| |**Unsorted** | **QuanTAlib** | **TA-LIB** | **Skender** |
| FCB - Fractal Chaos Bands |||✔️|| | ⛔ CHN - Price Channel ||||
| KEL - Keltner Channels |||✔️|✔️| | ⛔ COPPOCK - Coppock Curve ||||
| PVT - Pivot Points |||✔️|| | ⛔ CORREL - Pearson's Correlation Coefficient ||||
| STARC - Starc Bands |||✔️|| | ⛔ EOM - Ease of Movement ||||
| DPO - De-trended Price Oscillator |||✔️|✔️| | ⛔ HILO - Gann High-Low Activator ||||
| KDJ - KDJ Index |||✔️|✔️| | ⛔ HT - HT Trendline ||||
| SMI - Stochastic Momentum Index |||✔️|✔️| | ⛔ MCGD - McGinley Dynamic ||||
| CHAND - Chandelier Exit |||✔️|| | ⛔ ROC - Rate of Change ||||
| VSTOP - Volatility Stop |||✔️|| | ⛔ SAR - Parabolic Stop and Reverse ||||
| PVO - Percentage Volume Oscillator |||✔️|✔️| | ⛔ STC - Schaff Trend Cycle ||||
| Hilbert Transform Instantaneous Trendline ||||| | ⛔ WILLR - Larry Williams' %R ||||
| PMO - Price Momentum Oscillator |||✔️|| | ⛔ HURST - Hurst Exponent ||||
| ⛔ VOR - Vortex Indicator ||||
| ⛔ PVT - Pivot Points ||||
| ⛔ KDJ - KDJ Index ||||
| ⛔ CHAND - Chandelier Exit ||||
| ⛔ Hilbert Transform Instantaneous Trendline ||||