mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-12 23:58:04 +00:00
Documentation update
This commit is contained in:
@@ -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