mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-07-28 01:37:43 +00:00
Sonarcloud fixes
This commit is contained in:
+4
-4
@@ -8,11 +8,11 @@ public class TradyTests
|
||||
{
|
||||
private readonly TBarSeries bars;
|
||||
private readonly GbmFeed feed;
|
||||
private Random rnd;
|
||||
private readonly Random rnd;
|
||||
private readonly double range;
|
||||
private int period, iterations;
|
||||
private int skip;
|
||||
private IEnumerable<IOhlcv> Candles;
|
||||
private readonly int period, iterations;
|
||||
private readonly int skip;
|
||||
private readonly IEnumerable<IOhlcv> Candles;
|
||||
|
||||
public TradyTests()
|
||||
{
|
||||
|
||||
+8
-7
@@ -6,12 +6,13 @@ public class TulipTests
|
||||
{
|
||||
private readonly TBarSeries bars;
|
||||
private readonly GbmFeed feed;
|
||||
private Random rnd;
|
||||
private readonly Random rnd;
|
||||
private readonly double range;
|
||||
private int period, iterations;
|
||||
private int period;
|
||||
private int readonly iterations;
|
||||
private readonly double[] data;
|
||||
private readonly double[] outdata;
|
||||
private int skip;
|
||||
private readonly int skip;
|
||||
|
||||
public TulipTests()
|
||||
{
|
||||
@@ -44,7 +45,7 @@ public class TulipTests
|
||||
for (int i = QL.Length - 1; i > skip; i--)
|
||||
{
|
||||
double QL_item = QL[i].Value;
|
||||
double TU = i<period-1?double.NaN:arrout[0][i-period+1];
|
||||
double TU = i < period - 1 ? double.NaN : arrout[0][i - period + 1];
|
||||
Assert.InRange(TU - QL_item, -range, range);
|
||||
}
|
||||
}
|
||||
@@ -60,18 +61,18 @@ public class TulipTests
|
||||
Ema ma = new(period, useSma: false);
|
||||
TSeries QL = new();
|
||||
foreach (TBar item in feed)
|
||||
{ QL.Add(ma.Calc(new TValue(item.Time, item.Close))); }
|
||||
{ QL.Add(ma.Calc(new TValue(item.Time, item.Close))); }
|
||||
|
||||
double[][] arrin = [data];
|
||||
double[][] arrout = [outdata];
|
||||
Tulip.Indicators.ema.Run(inputs: arrin, options: [period], outputs: arrout);
|
||||
|
||||
Assert.Equal(QL.Length, arrout[0].Length);
|
||||
for (int i = QL.Length - 1; i > skip*2; i--) //Initial Tulip Ema value is (wrongly) set to the first input value - therefore large skip
|
||||
for (int i = QL.Length - 1; i > skip * 2; i--) //Initial Tulip Ema value is (wrongly) set to the first input value - therefore large skip
|
||||
{
|
||||
double QL_item = QL[i].Value;
|
||||
double TU = arrout[0][i];
|
||||
Assert.True(Math.Abs(TU - QL_item) <= range, $"Assertion failed at index {i} for period {period}: TU = {TU}, QL_item = {QL_item}, delta = {TU-QL_item}");
|
||||
Assert.True(Math.Abs(TU - QL_item) <= range, $"Assertion failed at index {i} for period {period}: TU = {TU}, QL_item = {QL_item}, delta = {TU - QL_item}");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ namespace QuanTAlib
|
||||
{
|
||||
public class BarIndicatorTests
|
||||
{
|
||||
private Random rnd;
|
||||
private readonly Random rnd;
|
||||
private const int SeriesLen = 1000;
|
||||
private const int Corrections = 100;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace QuanTAlib
|
||||
{
|
||||
public class IndicatorTests
|
||||
{
|
||||
private Random rnd;
|
||||
private readonly Random rnd;
|
||||
private const int SeriesLen = 1000;
|
||||
private const int Corrections = 100;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ public class SkenderTests
|
||||
{
|
||||
private readonly TBarSeries bars;
|
||||
private readonly GbmFeed feed;
|
||||
private Random rnd;
|
||||
private readonly Random rnd;
|
||||
private readonly double range;
|
||||
private int period, iterations;
|
||||
private readonly IEnumerable<Quote> quotes;
|
||||
|
||||
+7
-6
@@ -6,9 +6,10 @@ public class TAlibTests
|
||||
{
|
||||
private readonly TBarSeries bars;
|
||||
private readonly GbmFeed feed;
|
||||
private Random rnd;
|
||||
private readonly Random rnd;
|
||||
private readonly double range;
|
||||
private int period, iterations;
|
||||
private int period;
|
||||
private int readonly iterations;
|
||||
private readonly double[] data;
|
||||
private readonly double[] TALIB;
|
||||
|
||||
@@ -78,7 +79,7 @@ public class TAlibTests
|
||||
{ QL.Add(ma.Calc(new TValue(item.Time, item.Close))); }
|
||||
Core.Dema(data, 0, QL.Length - 1, TALIB, out int outBegIdx, out _, period);
|
||||
Assert.Equal(QL.Length, TALIB.Length);
|
||||
for (int i = QL.Length - 1; i > period*20; i--)
|
||||
for (int i = QL.Length - 1; i > period * 20; i--)
|
||||
{
|
||||
double TL = i < outBegIdx ? double.NaN : TALIB[i - outBegIdx];
|
||||
Assert.InRange(TALIB[i - outBegIdx] - QL[i].Value, -range, range);
|
||||
@@ -98,7 +99,7 @@ public class TAlibTests
|
||||
{ QL.Add(ma.Calc(new TValue(item.Time, item.Close))); }
|
||||
Core.Tema(data, 0, QL.Length - 1, TALIB, out int outBegIdx, out _, period);
|
||||
Assert.Equal(QL.Length, TALIB.Length);
|
||||
for (int i = QL.Length - 1; i > period*20; i--)
|
||||
for (int i = QL.Length - 1; i > period * 20; i--)
|
||||
{
|
||||
double TL = i < outBegIdx ? double.NaN : TALIB[i - outBegIdx];
|
||||
Assert.InRange(TALIB[i - outBegIdx] - QL[i].Value, -range, range);
|
||||
@@ -116,9 +117,9 @@ public class TAlibTests
|
||||
TSeries QL = new();
|
||||
foreach (TBar item in feed)
|
||||
{ QL.Add(ma.Calc(new TValue(item.Time, item.Close))); }
|
||||
Core.T3(data, 0, QL.Length - 1, TALIB, out int outBegIdx, out _, optInTimePeriod: period, optInVFactor: 0.7);
|
||||
Core.T3(data, 0, QL.Length - 1, TALIB, out int outBegIdx, out _, optInTimePeriod: period, optInVFactor: 0.7);
|
||||
Assert.Equal(QL.Length, TALIB.Length);
|
||||
for (int i = QL.Length - 1; i > period*20; i--)
|
||||
for (int i = QL.Length - 1; i > period * 20; i--)
|
||||
{
|
||||
double TL = i < outBegIdx ? double.NaN : TALIB[i - outBegIdx];
|
||||
Assert.InRange(TALIB[i - outBegIdx] - QL[i].Value, -range, range);
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Linq;
|
||||
// Shannon's Entropy calculation
|
||||
public class Entropy : AbstractBase
|
||||
{
|
||||
public readonly int Period;
|
||||
private readonly int Period;
|
||||
private readonly CircularBuffer _buffer;
|
||||
|
||||
public Entropy(int period)
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace QuanTAlib;
|
||||
// Excess kurtosis calculated with Sheskin Algorithm
|
||||
public class Kurtosis : AbstractBase
|
||||
{
|
||||
public readonly int Period;
|
||||
private readonly int Period;
|
||||
private readonly CircularBuffer _buffer;
|
||||
|
||||
public Kurtosis(int period)
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace QuanTAlib
|
||||
{
|
||||
public class Max : AbstractBase
|
||||
{
|
||||
public readonly int Period;
|
||||
private readonly int Period;
|
||||
private readonly CircularBuffer _buffer;
|
||||
private readonly double _halfLife;
|
||||
private double _currentMax, _p_currentMax;
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace QuanTAlib
|
||||
{
|
||||
public class Median : AbstractBase
|
||||
{
|
||||
public readonly int Period;
|
||||
private readonly int Period;
|
||||
private readonly CircularBuffer _buffer;
|
||||
|
||||
public Median(int period)
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace QuanTAlib
|
||||
{
|
||||
public class Min : AbstractBase
|
||||
{
|
||||
public readonly int Period;
|
||||
private readonly int Period;
|
||||
private readonly CircularBuffer _buffer;
|
||||
private readonly double _halfLife;
|
||||
private double _currentMin, _p_currentMin;
|
||||
|
||||
@@ -2,7 +2,7 @@ namespace QuanTAlib;
|
||||
|
||||
public class Mode : AbstractBase
|
||||
{
|
||||
public readonly int Period;
|
||||
private readonly int Period;
|
||||
private readonly CircularBuffer _buffer;
|
||||
|
||||
public Mode(int period)
|
||||
|
||||
@@ -5,8 +5,8 @@ using System.Linq;
|
||||
|
||||
public class Percentile : AbstractBase
|
||||
{
|
||||
public readonly int Period;
|
||||
public readonly double Percent;
|
||||
private readonly int Period;
|
||||
private readonly double Percent;
|
||||
private readonly CircularBuffer _buffer;
|
||||
|
||||
public Percentile(int period, double percent)
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
|
||||
public class Skew : AbstractBase
|
||||
{
|
||||
public readonly int Period;
|
||||
private readonly int Period;
|
||||
private readonly CircularBuffer _buffer;
|
||||
|
||||
public Skew(int period)
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace QuanTAlib
|
||||
{
|
||||
public class Stddev : AbstractBase
|
||||
{
|
||||
public readonly int Period;
|
||||
public readonly bool IsPopulation;
|
||||
private readonly int Period;
|
||||
private readonly bool IsPopulation;
|
||||
private readonly CircularBuffer _buffer;
|
||||
|
||||
public Stddev(int period, bool isPopulation = false)
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace QuanTAlib
|
||||
{
|
||||
public class Variance : AbstractBase
|
||||
{
|
||||
public readonly int Period;
|
||||
public readonly bool IsPopulation;
|
||||
private readonly int Period;
|
||||
private readonly bool IsPopulation;
|
||||
private readonly CircularBuffer _buffer;
|
||||
|
||||
public Variance(int period, bool isPopulation = false)
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
|
||||
public class Zscore : AbstractBase
|
||||
{
|
||||
public readonly int Period;
|
||||
private readonly int Period;
|
||||
private readonly CircularBuffer _buffer;
|
||||
|
||||
public Zscore(int period)
|
||||
|
||||
Reference in New Issue
Block a user