mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-14 00:28:05 +00:00
Documentation update
This commit is contained in:
@@ -9,7 +9,7 @@ public class PVAR_Test
|
||||
public void Add_Test()
|
||||
{
|
||||
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);
|
||||
a.Add(5);
|
||||
Assert.Equal(a.Count, c.Count);
|
||||
@@ -21,7 +21,7 @@ public class PVAR_Test
|
||||
public void Edge_Test()
|
||||
{
|
||||
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);
|
||||
a.Add(double.NaN);
|
||||
Assert.Equal(a.Count, c.Count);
|
||||
|
||||
@@ -9,7 +9,7 @@ public class VAR_Test
|
||||
public void Add_Test()
|
||||
{
|
||||
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);
|
||||
a.Add(5);
|
||||
Assert.Equal(a.Count, c.Count);
|
||||
@@ -21,7 +21,7 @@ public class VAR_Test
|
||||
public void Edge_Test()
|
||||
{
|
||||
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);
|
||||
a.Add(double.NaN);
|
||||
Assert.Equal(a.Count, c.Count);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<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="Skender.Stock.Indicators" Version="2.4.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
|
||||
|
||||
using Xunit;
|
||||
using System;
|
||||
@@ -20,6 +20,8 @@ public class PandasTA
|
||||
this.bars = new(1000);
|
||||
this.period = this.rnd.Next(28) + 3;
|
||||
|
||||
Runtime.PythonDLL = @"python310.dll";
|
||||
Installer.InstallPath = Path.GetFullPath(".");
|
||||
Installer.SetupPython().Wait();
|
||||
Installer.TryInstallPip();
|
||||
Installer.PipInstallModule("numpy");
|
||||
@@ -34,91 +36,89 @@ public class PandasTA
|
||||
{
|
||||
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]
|
||||
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));
|
||||
}
|
||||
|
||||
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
void EMA()
|
||||
{
|
||||
EMA_Series QL = new(this.bars.Close, this.period, false);
|
||||
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));
|
||||
}
|
||||
[Fact]
|
||||
void EMA()
|
||||
{
|
||||
EMA_Series QL = new(this.bars.Close, this.period, false);
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
void TEMA()
|
||||
{
|
||||
TEMA_Series QL = new(this.bars.Close, this.period, false);
|
||||
var pta = this.ta.tema(close: this.df[0], length: this.period);
|
||||
[Fact]
|
||||
void TEMA()
|
||||
{
|
||||
TEMA_Series QL = new(this.bars.Close, this.period, false);
|
||||
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]
|
||||
void ENTP()
|
||||
{
|
||||
ENTP_Series QL = new(this.bars.Close, this.period, useNaN:false);
|
||||
var pta = this.ta.entropy(close: this.df[0], length: this.period);
|
||||
[Fact]
|
||||
void ENTP()
|
||||
{
|
||||
ENTP_Series QL = new(this.bars.Close, this.period, useNaN:false);
|
||||
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]
|
||||
void WMA()
|
||||
{
|
||||
WMA_Series QL = new(this.bars.Close, this.period, false);
|
||||
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);
|
||||
[Fact]
|
||||
void WMA()
|
||||
{
|
||||
WMA_Series QL = new(this.bars.Close, this.period, false);
|
||||
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));
|
||||
}
|
||||
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);
|
||||
[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), 4), Math.Round(QL.Last().v, 4));
|
||||
}
|
||||
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
||||
}
|
||||
|
||||
[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);
|
||||
[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]
|
||||
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));
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -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]
|
||||
public void SDEV()
|
||||
{
|
||||
@@ -39,6 +75,7 @@ public class TA_LIB
|
||||
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 8), Math.Round(QL.Last().v, 8));
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void SMA()
|
||||
{
|
||||
@@ -112,9 +149,9 @@ public class TA_LIB
|
||||
}
|
||||
|
||||
[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 _);
|
||||
|
||||
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 8), Math.Round(QL.Last().v, 8));
|
||||
@@ -175,9 +212,9 @@ public class TA_LIB
|
||||
double[] outLower = new double[this.bars.Count];
|
||||
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);
|
||||
Assert.Equal(Math.Round(outUpper[outUpper.Length - outBegIdx - 1], 8), Math.Round(QL.Upper.Last().v, 8));
|
||||
Assert.Equal(Math.Round(outMiddle[outMiddle.Length - outBegIdx - 1], 8), Math.Round(QL.Mid.Last().v, 8));
|
||||
Assert.Equal(Math.Round(outLower[outLower.Length - outBegIdx - 1], 8), Math.Round(QL.Lower.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], 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));
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user