This commit is contained in:
Miha Kralj
2022-11-17 21:59:49 -08:00
parent 73e3420379
commit cfa10c79e8
7 changed files with 161 additions and 10 deletions
+1 -1
View File
@@ -157,7 +157,7 @@ public class PandasTA : IDisposable
[Fact]
void TRIMA()
{
//TODO: return length to variable length (period) when Pandas-TA fixes trima
// TODO: return length to variable length (period) when Pandas-TA fixes trima
TRIMA_Series QL = new(bars.Close, 11);
var pta = df.ta.trima(close: df.close, length: 11);
Assert.Equal(Math.Round((double)pta.tail(1), 4), Math.Round(QL.Last().v, 4));
+10 -1
View File
@@ -71,7 +71,16 @@ public class Skender_Stock
Assert.Equal(Math.Round((double)SK.Last().Tema!, 6), Math.Round(QL.Last().v, 6));
}
[Fact]
[Fact]
public void MAMA() {
MAMA_Series QL = new(bars.HL2, fastlimit: 0.5, slowlimit: 0.05);
var SK = quotes.GetMama(fastLimit: 0.5, slowLimit: 0.05);
Assert.Equal(Math.Round((double)SK.Last().Mama!, 6), Math.Round(QL.Last().v, 6));
}
[Fact]
public void MAD()
{
MAD_Series QL = new(bars.Close, period, false);
+12 -1
View File
@@ -10,6 +10,7 @@ public class TA_LIB
private readonly Random rnd = new();
private readonly int period;
private readonly double[] TALIB;
private readonly double[] TALIB2;
private readonly double[] inopen;
private readonly double[] inhigh;
private readonly double[] inlow;
@@ -21,6 +22,7 @@ public class TA_LIB
bars = new(5000);
period = rnd.Next(28) + 3;
TALIB = new double[bars.Count];
TALIB2 = new double[bars.Count];
inopen = bars.Open.v.ToArray();
inhigh = bars.High.v.ToArray();
inlow = bars.Low.v.ToArray();
@@ -130,7 +132,16 @@ public class TA_LIB
Assert.Equal(Math.Round(TALIB[TALIB.Length - outBegIdx - 1], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
}
[Fact]
[Fact]
public void MAMA() {
MAMA_Series QL = new(bars.Close, fastlimit: 0.5, slowlimit: 0.05);
Core.Mama(inReal: inclose, startIdx: 0, endIdx: bars.Count - 1, outMama: TALIB, outFama: TALIB2, outBegIdx: out int outBegIdx, outNbElement: out _, optInFastLimit: 0.5, optInSlowLimit: 0.05);
Assert.Equal(Math.Round(TALIB[TALIB.Length - outBegIdx - 1], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
}
[Fact]
public void TRIMA()
{
TRIMA_Series QL = new(bars.Close, period, false);