mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-25 22:08:05 +00:00
OBV, TRIMA
This commit is contained in:
@@ -13,7 +13,7 @@ public class Skender_Stock
|
||||
|
||||
public Skender_Stock()
|
||||
{
|
||||
this.bars = new(1000);
|
||||
this.bars = new(Bars: 1, Volatility:0.7, Drift:0.0);
|
||||
this.period = this.rnd.Next(28) + 3;
|
||||
this.quotes = this.bars.Select(
|
||||
q => new Quote
|
||||
@@ -33,7 +33,7 @@ public class Skender_Stock
|
||||
SMA_Series QL = new(this.bars.Close, this.period, false);
|
||||
var SK = this.quotes.GetSma(this.period);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Sma!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Sma!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -42,7 +42,7 @@ public class Skender_Stock
|
||||
EMA_Series QL = new(this.bars.Close, this.period, false);
|
||||
var SK = this.quotes.GetEma(this.period);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Ema!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Ema!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
[Fact]
|
||||
public void WMA()
|
||||
@@ -50,7 +50,7 @@ public class Skender_Stock
|
||||
WMA_Series QL = new(this.bars.Close, this.period, false);
|
||||
var SK = this.quotes.GetWma(this.period);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Wma!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Wma!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -59,7 +59,7 @@ public class Skender_Stock
|
||||
DEMA_Series QL = new(this.bars.Close, this.period, false);
|
||||
var SK = this.quotes.GetDema(this.period);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Dema!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Dema!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -68,7 +68,7 @@ public class Skender_Stock
|
||||
TEMA_Series QL = new(this.bars.Close, this.period, false);
|
||||
var SK = this.quotes.GetTema(this.period);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Tema!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Tema!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -77,7 +77,7 @@ public class Skender_Stock
|
||||
MAD_Series QL = new(this.bars.Close, this.period, false);
|
||||
var SK = this.quotes.GetSmaAnalysis(this.period);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Mad!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Mad!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -86,7 +86,7 @@ public class Skender_Stock
|
||||
MAPE_Series QL = new(this.bars.Close, this.period, false);
|
||||
var SK = this.quotes.GetSmaAnalysis(this.period);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Mape!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Mape!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -95,7 +95,18 @@ public class Skender_Stock
|
||||
ATR_Series QL = new(this.bars, this.period, false);
|
||||
var SK = this.quotes.GetAtr(this.period);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Atr!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Atr!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OBV()
|
||||
{
|
||||
OBV_Series QL = new(this.bars, this.period, false);
|
||||
var SK = this.quotes.GetObv(this.period);
|
||||
|
||||
// adding volume[0] to OBV to pass the test and keep compatibility with TA-LIB
|
||||
Assert.Equal(Math.Round((double)SK.Last().Obv!, 6) + Math.Round((double)this.quotes.First().Volume!, 6),
|
||||
Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -104,7 +115,7 @@ public class Skender_Stock
|
||||
ADL_Series QL = new(this.bars, false);
|
||||
var SK = this.quotes.GetAdl();
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Adl!, 6), Math.Round(QL.Last().v, 6));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Adl!, 5), Math.Round(QL.Last().v, 5));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -113,7 +124,7 @@ public class Skender_Stock
|
||||
CCI_Series QL = new(this.bars, this.period, false);
|
||||
var SK = this.quotes.GetCci(this.period);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Cci!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Cci!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -122,7 +133,7 @@ public class Skender_Stock
|
||||
ATRP_Series QL = new(this.bars, this.period, false);
|
||||
var SK = this.quotes.GetAtr(this.period);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Atrp!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Atrp!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -131,7 +142,7 @@ public class Skender_Stock
|
||||
KAMA_Series QL = new(this.bars.Close, this.period, useNaN: false);
|
||||
var SK = this.quotes.GetKama(this.period);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Kama!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Kama!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -140,7 +151,7 @@ public class Skender_Stock
|
||||
HMA_Series QL = new(this.bars.Close, this.period, useNaN: false);
|
||||
var SK = this.quotes.GetHma(this.period);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Hma!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Hma!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -149,7 +160,7 @@ public class Skender_Stock
|
||||
SMMA_Series QL = new(this.bars.Close, this.period, useNaN: false);
|
||||
var SK = this.quotes.GetSmma(this.period);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Smma!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Smma!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -158,8 +169,8 @@ public class Skender_Stock
|
||||
MACD_Series QL = new(this.bars.Close, 26,12,9, useNaN: false);
|
||||
var SK = this.quotes.GetMacd(12,26,9);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Macd!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Signal!, 8), Math.Round(QL.Signal.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Macd!, 6), Math.Round(QL.Last().v, 6));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Signal!, 6), Math.Round(QL.Signal.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -168,12 +179,12 @@ public class Skender_Stock
|
||||
BBANDS_Series QL = new(this.bars.Close, this.period, 2.0, useNaN: false);
|
||||
var SK = this.quotes.GetBollingerBands(this.period, 2.0);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Sma!, 8), Math.Round(QL.Mid.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().UpperBand!, 8), Math.Round(QL.Upper.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().LowerBand!, 8), Math.Round(QL.Lower.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Width!, 8), Math.Round(QL.Bandwidth.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().PercentB!, 8), Math.Round(QL.PercentB.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().ZScore!, 8), Math.Round(QL.Zscore.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Sma!, 6), Math.Round(QL.Mid.Last().v, 6));
|
||||
Assert.Equal(Math.Round((double)SK.Last().UpperBand!, 6), Math.Round(QL.Upper.Last().v, 6));
|
||||
Assert.Equal(Math.Round((double)SK.Last().LowerBand!, 6), Math.Round(QL.Lower.Last().v, 6));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Width!, 6), Math.Round(QL.Bandwidth.Last().v, 6));
|
||||
Assert.Equal(Math.Round((double)SK.Last().PercentB!, 6), Math.Round(QL.PercentB.Last().v, 6));
|
||||
Assert.Equal(Math.Round((double)SK.Last().ZScore!, 6), Math.Round(QL.Zscore.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -182,7 +193,7 @@ public class Skender_Stock
|
||||
RSI_Series QL = new(this.bars.Close, this.period, useNaN: false);
|
||||
var SK = this.quotes.GetRsi(this.period);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Rsi!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Rsi!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -191,7 +202,7 @@ public class Skender_Stock
|
||||
ALMA_Series QL = new(this.bars.Close, this.period, useNaN: false);
|
||||
var SK = this.quotes.GetAlma(this.period);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Alma!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Alma!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -200,7 +211,7 @@ public class Skender_Stock
|
||||
SDEV_Series QL = new(this.bars.Close, this.period, useNaN: false);
|
||||
var SK = this.quotes.GetStdDev(this.period);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().StdDev!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().StdDev!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -209,10 +220,10 @@ public class Skender_Stock
|
||||
LINREG_Series QL = new(this.bars.Close, this.period, useNaN: false);
|
||||
var SK = this.quotes.GetSlope(this.period);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Slope!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Intercept!, 8), Math.Round(QL.Intercept.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().RSquared!, 8), Math.Round(QL.RSquared.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().StdDev!, 8), Math.Round(QL.StdDev.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Slope!, 6), Math.Round(QL.Last().v, 6));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Intercept!, 6), Math.Round(QL.Intercept.Last().v, 6));
|
||||
Assert.Equal(Math.Round((double)SK.Last().RSquared!, 6), Math.Round(QL.RSquared.Last().v, 6));
|
||||
Assert.Equal(Math.Round((double)SK.Last().StdDev!, 6), Math.Round(QL.StdDev.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -221,7 +232,7 @@ public class Skender_Stock
|
||||
TR_Series QL = new(this.bars, useNaN: false);
|
||||
var SK = this.quotes.GetTr();
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Tr!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Tr!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -230,7 +241,7 @@ public class Skender_Stock
|
||||
TSeries QL = this.bars.HL2;
|
||||
var SK = this.quotes.GetBaseQuote(CandlePart.HL2);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Value!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Value!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -239,7 +250,7 @@ public class Skender_Stock
|
||||
TSeries QL = this.bars.OC2;
|
||||
var SK = this.quotes.GetBaseQuote(CandlePart.OC2);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Value!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Value!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -248,7 +259,7 @@ public class Skender_Stock
|
||||
TSeries QL = this.bars.HLC3;
|
||||
var SK = this.quotes.GetBaseQuote(CandlePart.HLC3);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Value!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Value!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -257,7 +268,7 @@ public class Skender_Stock
|
||||
TSeries QL = this.bars.OHL3;
|
||||
var SK = this.quotes.GetBaseQuote(CandlePart.OHL3);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Value!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Value!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -266,6 +277,6 @@ public class Skender_Stock
|
||||
TSeries QL = this.bars.OHLC4;
|
||||
var SK = this.quotes.GetBaseQuote(CandlePart.OHLC4);
|
||||
|
||||
Assert.Equal(Math.Round((double)SK.Last().Value!, 8), Math.Round(QL.Last().v, 8));
|
||||
Assert.Equal(Math.Round((double)SK.Last().Value!, 6), Math.Round(QL.Last().v, 6));
|
||||
}
|
||||
}
|
||||
|
||||
+47
-29
@@ -18,7 +18,7 @@ public class TA_LIB
|
||||
|
||||
public TA_LIB()
|
||||
{
|
||||
this.bars = new(1000);
|
||||
this.bars = new(5000);
|
||||
this.period = this.rnd.Next(28) + 3;
|
||||
this.TALIB = new double[this.bars.Count];
|
||||
this.inopen = this.bars.Open.v.ToArray();
|
||||
@@ -36,7 +36,7 @@ public class TA_LIB
|
||||
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));
|
||||
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -45,7 +45,7 @@ public class TA_LIB
|
||||
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));
|
||||
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -54,7 +54,7 @@ public class TA_LIB
|
||||
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));
|
||||
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -63,7 +63,7 @@ public class TA_LIB
|
||||
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));
|
||||
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -72,7 +72,7 @@ public class TA_LIB
|
||||
SDEV_Series QL = new(this.bars.Close, this.period, false);
|
||||
Core.StdDev(this.inclose, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _, this.period);
|
||||
|
||||
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], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -81,7 +81,16 @@ public class TA_LIB
|
||||
SMA_Series QL = new(this.bars.Close, this.period, false);
|
||||
Core.Sma(this.inclose, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _, this.period);
|
||||
|
||||
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], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TRIMA()
|
||||
{
|
||||
TRIMA_Series QL = new(this.bars.Close, this.period, false);
|
||||
Core.Trima(this.inclose, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _, this.period);
|
||||
|
||||
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -90,7 +99,7 @@ public class TA_LIB
|
||||
EMA_Series QL = new(this.bars.Close, this.period, false);
|
||||
Core.Ema(this.inclose, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _, this.period);
|
||||
|
||||
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], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -98,8 +107,8 @@ public class TA_LIB
|
||||
{
|
||||
WMA_Series QL = new(this.bars.Close, this.period, false);
|
||||
Core.Wma(this.inclose, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _, this.period);
|
||||
|
||||
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], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -108,7 +117,7 @@ public class TA_LIB
|
||||
DEMA_Series QL = new(this.bars.Close, this.period, false);
|
||||
Core.Dema(this.inclose, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _, this.period);
|
||||
|
||||
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], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -117,7 +126,7 @@ public class TA_LIB
|
||||
TEMA_Series QL = new(this.bars.Close, this.period, false);
|
||||
Core.Tema(this.inclose, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _, this.period);
|
||||
|
||||
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], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -126,7 +135,7 @@ public class TA_LIB
|
||||
MAX_Series QL = new(this.bars.Close, this.period, false);
|
||||
Core.Max(this.inclose, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _, this.period);
|
||||
|
||||
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], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -135,7 +144,7 @@ public class TA_LIB
|
||||
MIN_Series QL = new(this.bars.Close, this.period, false);
|
||||
Core.Min(this.inclose, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _, this.period);
|
||||
|
||||
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], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -144,7 +153,16 @@ public class TA_LIB
|
||||
ADL_Series QL = new(this.bars, false);
|
||||
Core.Ad(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], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OBV()
|
||||
{
|
||||
OBV_Series QL = new(this.bars, this.period, false);
|
||||
Core.Obv(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], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -153,7 +171,7 @@ public class TA_LIB
|
||||
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));
|
||||
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -162,7 +180,7 @@ public class TA_LIB
|
||||
ATR_Series QL = new(this.bars, this.period, false);
|
||||
Core.Atr(this.inhigh, this.inlow, this.inclose, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _, this.period);
|
||||
|
||||
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], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -171,7 +189,7 @@ public class TA_LIB
|
||||
CCI_Series QL = new(this.bars, this.period, false);
|
||||
Core.Cci(this.inhigh, this.inlow, this.inclose, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _, this.period);
|
||||
|
||||
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], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -180,7 +198,7 @@ public class TA_LIB
|
||||
RSI_Series QL = new(this.bars.Close, this.period, false);
|
||||
Core.Rsi(this.inclose, 0, this.bars.Count - 1, this.TALIB, out int outBegIdx, out _, this.period);
|
||||
|
||||
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], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -189,7 +207,7 @@ public class TA_LIB
|
||||
TR_Series QL = new(this.bars, false);
|
||||
Core.TRange(this.inhigh, this.inlow, 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));
|
||||
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -199,8 +217,8 @@ public class TA_LIB
|
||||
double[] macdHist = new double[this.bars.Count];
|
||||
MACD_Series QL = new(this.bars.Close, slow: 26, fast: 12, signal: 9, false);
|
||||
Core.Macd(this.inclose, 0, this.bars.Count - 1, outMacd: this.TALIB, outMacdSignal: macdSignal, outMacdHist: macdHist, 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(macdSignal[macdSignal.Length - outBegIdx - 1], 8), Math.Round(QL.Signal.Last().v, 8));
|
||||
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
Assert.Equal(Math.Round(macdSignal[macdSignal.Length - outBegIdx - 1], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Signal.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -211,9 +229,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], 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));
|
||||
Assert.Equal(Math.Round(outUpper[outUpper.Length - outBegIdx - 1], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Upper.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
Assert.Equal(Math.Round(outMiddle[outMiddle.Length - outBegIdx - 1], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Mid.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
Assert.Equal(Math.Round(outLower[outLower.Length - outBegIdx - 1], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Lower.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -222,7 +240,7 @@ public class TA_LIB
|
||||
TSeries QL = this.bars.HL2;
|
||||
Core.MedPrice(this.inhigh, this.inlow, 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], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -231,7 +249,7 @@ public class TA_LIB
|
||||
TSeries QL = this.bars.HLC3;
|
||||
Core.TypPrice(this.inhigh, this.inlow, 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));
|
||||
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -240,7 +258,7 @@ public class TA_LIB
|
||||
TSeries QL = this.bars.OHLC4;
|
||||
Core.AvgPrice(this.inopen, this.inhigh, this.inlow, 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));
|
||||
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -249,6 +267,6 @@ public class TA_LIB
|
||||
TSeries QL = this.bars.HLCC4;
|
||||
Core.WclPrice( this.inhigh, this.inlow, 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));
|
||||
Assert.Equal(Math.Round(this.TALIB[this.TALIB.Length - outBegIdx - 1], 6, MidpointRounding.AwayFromZero), Math.Round(QL.Last().v, 6, MidpointRounding.AwayFromZero));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user