dotcover

s1

.sln

s1

s1

s2

s3

s4

s5

s1

s2

x

x2

x3

x4

x5

x6

x1

sonarcube cleanup1

sonarcube cleanup2

sonarcube cleanup 3

fixes

q

q

q

q

q

q

q

q

q1

q2

q

q1

codacy 1
This commit is contained in:
Miha Kralj
2024-09-23 22:08:40 -07:00
parent 846429eccf
commit 58d72c06ca
244 changed files with 621 additions and 14397 deletions
+10 -2
View File
@@ -4,7 +4,15 @@
<RootNamespace>QuanTAlib.Tests</RootNamespace>
<AssemblyName>QuanTAlib.Tests</AssemblyName>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
@@ -12,11 +20,11 @@
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="System.Text.Json" Version="9.0.0-rc.1.24431.7" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Skender.Stock.Indicators" Version="2.5.0" />
<PackageReference Include="TALib.NETCore" Version="0.4.4" />
<PackageReference Include="Tulip.NETCore" Version="0.8.0.1" />
+1 -1
View File
@@ -2,7 +2,7 @@ using Xunit;
using Trady.Analysis.Indicator;
using Trady.Core;
using Trady.Core.Infrastructure;
using QuanTAlib;
namespace QuanTAlib;
public class TradyTests
{
+3 -4
View File
@@ -1,6 +1,6 @@
using Xunit;
using Tulip;
using QuanTAlib;
namespace QuanTAlib;
public class TulipTests
{
@@ -23,7 +23,7 @@ public class TulipTests
iterations = 3;
skip = 500;
data = feed.Close.v.ToArray();
outdata = new double[data.Count()];
outdata = new double[data.Length];
}
[Fact]
@@ -66,12 +66,11 @@ public class TulipTests
double[][] arrout = [outdata];
Tulip.Indicators.ema.Run(inputs: arrin, options: [period], outputs: arrout);
Assert.Equal(QL.Length, arrout[0].Count());
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
{
double QL_item = QL[i].Value;
double TU = arrout[0][i];
//Assert.InRange(TU - QL_item, -range, range);
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}");
}
+2 -28
View File
@@ -1,5 +1,5 @@
using Xunit;
using QuanTAlib;
namespace QuanTAlib;
public class Consistency
{
@@ -312,31 +312,6 @@ public class Consistency
}
}
/*
[Fact]
public void Jma_isNew()
{
int p = (int)rnd.Next(2, 100);
Jma ma1 = new(p);
Jma ma2 = new(p);
for (int i = 0; i < series_len; i++)
{
TValue item1 = new(Time: DateTime.Now, Value: rnd.Next(-100, 100), IsNew: true);
ma1.Calc(item1);
for (int j = 0; j < corrections; j++)
{
item1 = new(Time: DateTime.Now, Value: rnd.Next(-100, 100), IsNew: false);
ma1.Calc(item1);
}
ma2.Calc(new TValue(item1.Time, item1.Value, IsNew: true));
//Assert.Equal(ma1.Value, ma2.Value);
Assert.True(ma1.Value == ma2.Value, $"Assertion failed at p={p}, Value={item1.Value}. ma1.Value={ma1.Value}, ma2.Value={ma2.Value}");
}
}
*/
[Fact]
public void Kama_isNew()
{
@@ -442,7 +417,6 @@ public class Consistency
[Fact]
public void Qema_isNew()
{
int p = (int)rnd.Next(2, 100);
Qema ma1 = new();
Qema ma2 = new();
for (int i = 0; i < series_len; i++)
@@ -683,7 +657,7 @@ public class Consistency
[Fact]
public void Kurtosis_isNew()
{
int p = (int)rnd.Next(2, 100);
int p = (int)rnd.Next(5, 100);
Kurtosis ma1 = new(p);
Kurtosis ma2 = new(p);
for (int i = 0; i < series_len; i++)
+1 -2
View File
@@ -1,6 +1,6 @@
using Xunit;
using Skender.Stock.Indicators;
using QuanTAlib;
namespace QuanTAlib;
public class SkenderTests
{
@@ -284,7 +284,6 @@ public class SkenderTests
{
for (int run = 0; run < iterations; run++)
{
//period = rnd.Next(50) + 5;
Mama ma = new(fastLimit: 0.5, slowLimit: 0.05);
TSeries QL = new();
foreach (TBar item in feed)
+8 -31
View File
@@ -1,6 +1,6 @@
using Xunit;
using TALib;
using QuanTAlib;
namespace QuanTAlib;
public class TAlibTests
{
@@ -22,7 +22,7 @@ public class TAlibTests
feed.Add(10000);
iterations = 3;
data = feed.Close.v.ToArray();
TALIB = new double[data.Count()];
TALIB = new double[data.Length];
}
@@ -37,11 +37,11 @@ public class TAlibTests
foreach (TBar item in feed)
{ QL.Add(ma.Calc(new TValue(item.Time, item.Close))); }
Core.Sma(data, 0, QL.Length - 1, TALIB, out int outBegIdx, out _, period);
Assert.Equal(QL.Length, TALIB.Count());
Assert.Equal(QL.Length, TALIB.Length);
for (int i = QL.Length - 1; i > period; i--)
{
double TL = i < outBegIdx ? double.NaN : TALIB[i - outBegIdx];
Assert.InRange(TALIB[i - outBegIdx] - QL[i].Value, -range, range);
Assert.InRange(TL - QL[i].Value, -range, range);
}
}
}
@@ -57,7 +57,7 @@ public class TAlibTests
foreach (TBar item in feed)
{ QL.Add(ma.Calc(new TValue(item.Time, item.Close))); }
Core.Ema(data, 0, QL.Length - 1, TALIB, out int outBegIdx, out _, period);
Assert.Equal(QL.Length, TALIB.Count());
Assert.Equal(QL.Length, TALIB.Length);
for (int i = QL.Length - 1; i > period; i--)
{
double TL = i < outBegIdx ? double.NaN : TALIB[i - outBegIdx];
@@ -77,7 +77,7 @@ public class TAlibTests
foreach (TBar item in feed)
{ 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.Count());
Assert.Equal(QL.Length, TALIB.Length);
for (int i = QL.Length - 1; i > period*20; i--)
{
double TL = i < outBegIdx ? double.NaN : TALIB[i - outBegIdx];
@@ -97,7 +97,7 @@ public class TAlibTests
foreach (TBar item in feed)
{ 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.Count());
Assert.Equal(QL.Length, TALIB.Length);
for (int i = QL.Length - 1; i > period*20; i--)
{
double TL = i < outBegIdx ? double.NaN : TALIB[i - outBegIdx];
@@ -106,29 +106,6 @@ public class TAlibTests
}
}
//TODO fix WMA
/*
[Fact]
public void WMA()
{
for (int run = 0; run < iterations; run++)
{
period = rnd.Next(50) + 5;
Wma ma = new(period);
TSeries QL = new();
foreach (TBar item in feed)
{ QL.Add(ma.Calc(new TValue(item.Time, item.Close))); }
Core.Wma(data, 0, QL.Length - 1, TALIB, out int outBegIdx, out _, period);
Assert.Equal(QL.Length, TALIB.Count());
for (int i = QL.Length - 1; i > period*3; i--)
{
double TL = i < outBegIdx ? double.NaN : TALIB[i - outBegIdx];
Assert.InRange(TALIB[i - outBegIdx] - QL[i].Value, -range, range);
}
}
}
*/
[Fact]
public void T3()
{
@@ -140,7 +117,7 @@ public class TAlibTests
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);
Assert.Equal(QL.Length, TALIB.Count());
Assert.Equal(QL.Length, TALIB.Length);
for (int i = QL.Length - 1; i > period*20; i--)
{
double TL = i < outBegIdx ? double.NaN : TALIB[i - outBegIdx];