Tests and QT cleanup

This commit is contained in:
Miha Kralj
2022-12-21 12:31:29 -08:00
parent 9ad467cd5a
commit 5844547a79
31 changed files with 188 additions and 243 deletions
+13 -15
View File
@@ -13,47 +13,45 @@ public class AAA_chart : Indicator {
#endregion Parameters
private TBars bars;
private TSeries series;
private JMA_Series jma;
private DWMA_Series dwma;
private JMA_Series ind_a;
private DWMA_Series ind_b;
public override string ShortName => $"AAA ({this.Period})";
public AAA_chart() : base()
{
this.SeparateWindow = true;
this.SeparateWindow = false;
this.Name = "AAA - Test indicator";
this.Description = "Test indicator";
this.AddLineSeries("JMA", Color.RoyalBlue, 3, LineStyle.Solid);
this.AddLineSeries("DWMA", Color.OrangeRed, 3, LineStyle.Solid);
this.SeparateWindow = false;
}
protected override void OnInit()
{
this.ShortName = "AAA (" + this.Period + ")";
this.bars = new();
this.series = new();
this.jma = new(source: bars.HLC3, period: this.Period, useNaN: false);
this.dwma = new(source: bars.HLC3, period: this.Period, useNaN: false);
this.ind_a = new(source: bars.Close, period: this.Period, useNaN: false);
this.ind_b = new(source: bars.OHLC4, period: this.Period, useNaN: false);
}
protected override void OnUpdate(UpdateArgs args)
{
Debug.WriteLine($"{args.Reason}");
bool update = !(args.Reason == UpdateReason.NewBar || args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(),
this.bars.Add(this.Time(),
this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High),
this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume),
this.GetPrice(PriceType.Volume),
update);
//this.series.Add(0.25*(this.GetPrice(PriceType.Open)+ this.GetPrice(PriceType.High)+ this.GetPrice(PriceType.Low)+ this.GetPrice(PriceType.Close)), update);
this.SetValue(this.jma.v.Last(), 0);
this.SetValue(this.dwma.v.Last(), 1);
this.SetValue(this.ind_a.v.Last(), 0);
this.SetValue(this.ind_b.v.Last(), 1);
}
}
-1
View File
@@ -27,7 +27,6 @@ public class ATR_chart : Indicator
protected override void OnInit()
{
this.ShortName = "ATR (" + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars, period: this.Period, useNaN: false);
}
-1
View File
@@ -32,7 +32,6 @@ public class BIAS_chart : Indicator
protected override void OnInit()
{
this.ShortName = "BIAS (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource), period: this.Period);
}
+2 -2
View File
@@ -28,10 +28,10 @@ public class CCI_chart : Indicator
protected override void OnInit()
{
this.ShortName = "CCI (" + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars, period: this.Period, useNaN: false);
}
}
protected override void OnUpdate(UpdateArgs args)
{
bool update = (args.Reason != UpdateReason.NewBar && args.Reason != UpdateReason.HistoricalBar);
-2
View File
@@ -32,8 +32,6 @@ public class DEMA_chart : Indicator
protected override void OnInit()
{
this.ShortName =
"DEMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
-1
View File
@@ -32,7 +32,6 @@ public class EMA_chart : Indicator
protected override void OnInit()
{
this.ShortName = "EMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
}
-1
View File
@@ -32,7 +32,6 @@ public class ENTP_chart : Indicator
protected override void OnInit()
{
this.ShortName = "ENTP (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource), period: this.Period, useNaN: true);
}
-2
View File
@@ -32,8 +32,6 @@ public class HEMA_chart : Indicator
protected override void OnInit()
{
this.ShortName =
"HEMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
-2
View File
@@ -33,8 +33,6 @@ public class HMA_chart : Indicator
protected override void OnInit()
{
this.ShortName =
"HMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
+5 -7
View File
@@ -1,4 +1,5 @@
using System.Drawing;
using System.Linq;
using TradingPlatform.BusinessLayer;
namespace QuanTAlib;
@@ -32,21 +33,18 @@ public class JMA_chart : Indicator
protected override void OnInit()
{
this.ShortName =
"JMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
this.indicator = new(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
}
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
args.Reason == UpdateReason.HistoricalBar);
bool update = !(args.Reason == UpdateReason.NewBar || args.Reason == UpdateReason.HistoricalBar);
this.bars.Add(this.Time(), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), update);
double result = this.indicator[this.indicator.Count - 1].v;
double result = this.indicator.v.Last();
this.SetValue(result);
}
}
-1
View File
@@ -37,7 +37,6 @@ public class KAMA_chart : Indicator
protected override void OnInit()
{
this.ShortName = "KAMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ":" + this.Fast + ":" + this.Slow + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource), period: this.Period, fast: this.Fast, slow: this.Slow, useNaN: false);
}
-2
View File
@@ -32,8 +32,6 @@ public class KURT_chart : Indicator
protected override void OnInit()
{
this.ShortName =
"KURT (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
-2
View File
@@ -32,8 +32,6 @@ public class MAD_chart : Indicator
protected override void OnInit()
{
this.ShortName =
"MAD (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
+1 -3
View File
@@ -32,9 +32,7 @@ public class MAPE_chart : Indicator
protected override void OnInit()
{
this.bars = new();
this.ShortName =
"MAPE (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
+1 -3
View File
@@ -32,9 +32,7 @@ public class MAX_chart : Indicator
protected override void OnInit()
{
this.bars = new();
this.ShortName =
"MAX (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator =
new(source: bars.Select(this.DataSource), period: this.Period);
}
+1 -3
View File
@@ -32,9 +32,7 @@ public class MED_chart : Indicator
protected override void OnInit()
{
this.bars = new();
this.ShortName =
"MED (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator =
new(source: bars.Select(this.DataSource), period: this.Period);
}
-2
View File
@@ -33,8 +33,6 @@ public class MIN_chart : Indicator
protected override void OnInit()
{
this.bars = new();
this.ShortName =
"MIN (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.indicator =
new(source: bars.Select(this.DataSource), period: this.Period);
}
+1 -3
View File
@@ -32,9 +32,7 @@ public class MSE_chart : Indicator
protected override void OnInit()
{
this.bars = new();
this.ShortName =
"MSE (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
+1 -3
View File
@@ -32,9 +32,7 @@ public class RMA_chart : Indicator
protected override void OnInit()
{
this.bars = new();
this.ShortName =
"RMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
+1 -3
View File
@@ -32,9 +32,7 @@ public class RSI_chart : Indicator
protected override void OnInit()
{
this.bars = new();
this.ShortName =
"RSI (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
+1 -3
View File
@@ -32,9 +32,7 @@ public class SDEV_chart : Indicator
protected override void OnInit()
{
this.bars = new();
this.ShortName =
"SDEV (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
+1 -3
View File
@@ -32,9 +32,7 @@ public class SMAPE_chart : Indicator
protected override void OnInit()
{
this.bars = new();
this.ShortName =
"SMAPE (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
+3 -5
View File
@@ -32,13 +32,11 @@ public class SMA_chart : Indicator
protected override void OnInit()
{
this.bars = new();
this.ShortName =
"SMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
}
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
-1
View File
@@ -32,7 +32,6 @@ public class SMMA_chart : Indicator
protected override void OnInit()
{
this.ShortName = "SMMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource), period: this.Period, useNaN: false);
}
+1 -3
View File
@@ -32,9 +32,7 @@ public class TEMA_chart : Indicator
protected override void OnInit()
{
this.bars = new();
this.ShortName =
"TEMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
+2 -4
View File
@@ -32,13 +32,11 @@ public class VAR_chart : Indicator
protected override void OnInit()
{
this.bars = new();
this.ShortName =
"VAR (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: true);
}
protected override void OnUpdate(UpdateArgs args)
{
bool update = !(args.Reason == UpdateReason.NewBar ||
+1 -2
View File
@@ -41,8 +41,7 @@ public class WMAPE_chart : Indicator
protected override void OnInit()
{
this.bars = new();
this.ShortName = "WMAPE (" + QuanTAlib.TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: this.bars.Select(this.DataSource), period: this.Period, useNaN: true);
}
protected override void OnUpdate(UpdateArgs args)
+1 -3
View File
@@ -32,9 +32,7 @@ public class WMA_chart : Indicator
protected override void OnInit()
{
this.bars = new();
this.ShortName =
"WMA (" + TBars.SelectStr(this.DataSource) + ", " + this.Period + ")";
this.bars = new();
this.indicator = new(source: bars.Select(this.DataSource),
period: this.Period, useNaN: false);
}
+43 -48
View File
@@ -1,52 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<LangVersion>preview</LangVersion>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<Platforms>AnyCPU</Platforms>
<AlgoType>Indicator</AlgoType>
<AssemblyName>Quantower_QTAlib</AssemblyName>
<RootNamespace>QuanTAlib</RootNamespace>
<DebugType>embedded</DebugType>
<LangVersion>preview</LangVersion>
<PlatformTarget>AnyCPU</PlatformTarget>
<Nullable>disable</Nullable>
<SignAssembly>False</SignAssembly>
<CodeAnalysisRuleSet>..\.sonarlint\mihakralj_quantalibcsharp.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>True</Optimize>
<WarningLevel>3</WarningLevel>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<PlatformTarget>anycpu</PlatformTarget>
<DebugType>full</DebugType>
<OutputPath>C:\Quantower\TradingPlatform\v1.128.18\..\..\Settings\Scripts\Indicators\Quantower</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>embedded</DebugType>
<Optimize>True</Optimize>
<WarningLevel>3</WarningLevel>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<PlatformTarget>anycpu</PlatformTarget>
<OutputPath>C:\Quantower\TradingPlatform\v1.128.18\..\..\Settings\Scripts\Indicators\Quantower</OutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Source\**\*.cs" Exclude="..\Source\obj\**;..\Source\Feeds\**">
<Link>QuanTAlib\%(RecursiveDir)%(Filename)%(Extension)</Link>
</Compile>
</ItemGroup>
<!--
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<LangVersion>preview</LangVersion>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<Platforms>AnyCPU</Platforms>
<AlgoType>Indicator</AlgoType>
<AssemblyName>Quantower_QTAlib</AssemblyName>
<RootNamespace>QuanTAlib</RootNamespace>
<DebugType>embedded</DebugType>
<LangVersion>preview</LangVersion>
<PlatformTarget>AnyCPU</PlatformTarget>
<Nullable>disable</Nullable>
<SignAssembly>False</SignAssembly>
<CodeAnalysisRuleSet>..\.sonarlint\mihakralj_quantalibcsharp.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Optimize>True</Optimize>
<WarningLevel>3</WarningLevel>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<PlatformTarget>anycpu</PlatformTarget>
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>embedded</DebugType>
<Optimize>True</Optimize>
<WarningLevel>3</WarningLevel>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<PlatformTarget>anycpu</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Source\**\*.cs" Exclude="..\Source\obj\**;..\Source\Feeds\**">
<Link>QuanTAlib\%(RecursiveDir)%(Filename)%(Extension)</Link>
</Compile>
</ItemGroup>
<Target Name="CopyCustomContent" AfterTargets="AfterBuild">
<Copy SourceFiles=".\bin\$(Configuration)\net48\Quantower_QTAlib.dll" DestinationFolder="\Quantower\Settings\Scripts\Indicators\QuanTAlib" />
</Target>
-->
<ItemGroup>
<AdditionalFiles Include="..\.sonarlint\mihakralj_quantalib\CSharp\SonarLint.xml" Link="SonarLint.xml" />
</ItemGroup>
<ItemGroup>
<Reference Include="TradingPlatform.BusinessLayer">
<HintPath>C:\Quantower\TradingPlatform\v1.128.18\bin\TradingPlatform.BusinessLayer.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Include="TradingPlatform.BusinessLayer">
<HintPath>C:\Quantower\TradingPlatform\v1.128.20\bin\TradingPlatform.BusinessLayer.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
Binary file not shown.
+109 -112
View File
@@ -16,8 +16,8 @@ public class Skender
{
bars = new(Bars: 10000, Volatility: 0.5, Drift: 0.0, Precision: 2);
period = rnd.Next(30) + 5;
digits = 2; //minimizing rounding errors in type conversions
skip = 300;
digits = 6; //minimizing rounding errors in type conversions
skip = 200;
quotes = bars.Select(q => new Quote
{
@@ -33,15 +33,14 @@ public class Skender
[Fact]
public void ADL()
{
// TODO: check precision of ADL()
ADL_Series QL = new(bars, false);
var SK = quotes.GetAdl().Select(i => i.Adl);
for (int i = QL.Length; i > skip; i--)
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round(SK.ElementAt(i - 1)!, digits: digits);
Assert.Equal(SK_item!, QL_item);
}
double QL_item = QL[i - 1].v;
double SK_item = SK.ElementAt(i - 1)!;
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
public void ALMA()
@@ -50,10 +49,10 @@ public class Skender
var SK = quotes.GetAlma(period).Select(i => i.Alma.Null2NaN()!);
for (int i = QL.Length; i > skip; i--)
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round((double)SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
}
double QL_item = QL[i - 1].v;
double SK_item = SK.ElementAt(i - 1);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits));
}
}
[Fact]
public void ATR()
@@ -62,10 +61,10 @@ public class Skender
var SK = quotes.GetAtr(period).Select(i => i.Atr.Null2NaN()!);
for (int i = QL.Length; i > skip; i--)
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round((double)SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
}
double QL_item = QL[i - 1].v;
double SK_item = SK.ElementAt(i - 1);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits));
}
}
[Fact]
public void ATRP()
@@ -74,10 +73,10 @@ public class Skender
var SK = quotes.GetAtr(period).Select(i => i.Atrp.Null2NaN()!);
for (int i = QL.Length; i > skip; i--)
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round((double)SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
}
double QL_item = QL[i - 1].v;
double SK_item = SK.ElementAt(i - 1);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits));
}
}
[Fact]
public void BBANDS()
@@ -86,25 +85,25 @@ public class Skender
var SK = quotes.GetBollingerBands(period, 2.0);
for (int i = QL.Length; i > skip; i--)
{
double QL_item = Math.Round(QL.Mid[i - 1].v, digits: digits);
double SK_item = Math.Round((double)SK.ElementAt(i - 1).Sma!.Value, digits: digits);
Assert.Equal(SK_item!, QL_item);
QL_item = Math.Round(QL.Upper[i - 1].v, digits: digits);
SK_item = Math.Round((double)SK.ElementAt(i - 1).UpperBand!.Value, digits: digits);
Assert.Equal(SK_item!, QL_item);
QL_item = Math.Round(QL.Lower[i - 1].v, digits: digits);
SK_item = Math.Round((double)SK.ElementAt(i - 1).LowerBand!.Value, digits: digits);
Assert.Equal(SK_item!, QL_item);
QL_item = Math.Round(QL.Bandwidth[i - 1].v, digits: digits);
SK_item = Math.Round((double)SK.ElementAt(i - 1).Width!.Value, digits: digits);
Assert.Equal(SK_item!, QL_item);
QL_item = Math.Round(QL.PercentB[i - 1].v, digits: digits);
SK_item = Math.Round((double)SK.ElementAt(i - 1).PercentB!.Value, digits: digits);
Assert.Equal(SK_item!, QL_item);
QL_item = Math.Round(QL.Zscore[i - 1].v, digits: digits);
SK_item = Math.Round((double)SK.ElementAt(i - 1).ZScore!.Value, digits: digits);
Assert.Equal(SK_item!, QL_item);
}
double QL_item = QL.Mid[i - 1].v;
double SK_item = SK.ElementAt(i - 1).Sma!.Value;
Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits));
QL_item = QL.Upper[i - 1].v;
SK_item = SK.ElementAt(i - 1).UpperBand!.Value;
Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits));
QL_item = QL.Lower[i - 1].v;
SK_item = SK.ElementAt(i - 1).LowerBand!.Value;
Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits));
QL_item = QL.Bandwidth[i - 1].v;
SK_item = SK.ElementAt(i - 1).Width!.Value;
Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits));
QL_item = QL.PercentB[i - 1].v;
SK_item = SK.ElementAt(i - 1).PercentB!.Value;
Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits));
QL_item = QL.Zscore[i - 1].v;
SK_item = SK.ElementAt(i - 1).ZScore!.Value;
Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits));
}
}
[Fact]
public void CCI()
@@ -113,10 +112,10 @@ public class Skender
var SK = quotes.GetCci(period).Select(i => i.Cci.Null2NaN()!);
for (int i = QL.Length; i > skip; i--)
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round((double)SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
}
double QL_item = QL[i - 1].v;
double SK_item = SK.ElementAt(i - 1);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits));
}
}
[Fact]
public void CMO()
@@ -125,10 +124,10 @@ public class Skender
var SK = quotes.GetCmo(period).Select(i => i.Cmo.Null2NaN()!);
for (int i = QL.Length; i > skip; i--)
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round((double)SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
}
double QL_item = QL[i - 1].v;
double SK_item = SK.ElementAt(i - 1);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits));
}
}
[Fact]
public void CORR()
@@ -137,10 +136,10 @@ public class Skender
var SK = quotes.Use(CandlePart.High).GetCorrelation(quotes.Use(CandlePart.Low), period).Select(i => i.Correlation.Null2NaN()!);
for (int i = QL.Length; i > skip; i--)
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round((double)SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
}
double QL_item = QL[i - 1].v;
double SK_item = SK.ElementAt(i - 1);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits));
}
}
[Fact]
public void COVAR()
@@ -149,9 +148,9 @@ public class Skender
var SK = quotes.Use(CandlePart.High).GetCorrelation(quotes.Use(CandlePart.Low), period).Select(i => i.Covariance.Null2NaN()!);
for (int i = QL.Length; i > skip; i--)
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round((double)SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
double QL_item = QL[i - 1].v;
double SK_item = SK.ElementAt(i - 1);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -161,9 +160,9 @@ public class Skender
var SK = quotes.GetDema(period).Select(i => i.Dema.Null2NaN()!);
for (int i = QL.Length; i > skip; i--)
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round((double)SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
double QL_item = QL[i - 1].v;
double SK_item = SK.ElementAt(i - 1);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -173,48 +172,46 @@ public class Skender
var SK = quotes.GetEma(period).Select(i => i.Ema.Null2NaN()!);
for (int i = QL.Length; i > skip; i--)
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round((double)SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
double QL_item = QL[i - 1].v;
double SK_item = SK.ElementAt(i - 1);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
/*
[Fact]
public void HL2()
{
TSeries QL = bars.HL2;
var SK = quotes.GetBaseQuote(CandlePart.HL2).Select(i => i.Value);
var SK = quotes.GetBaseQuote(CandlePart.HL2);
for (int i = QL.Length; i > skip; i--)
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round((double)SK.ElementAt(i - 1)!, digits: digits);
Assert.Equal(SK_item!, QL_item);
}
double QL_item = QL[i - 1].v;
double SK_item = SK.ElementAt(i - 1).Value;
Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits));
}
}
[Fact]
public void HLC3()
{
TSeries QL = bars.HLC3;
var SK = quotes.GetBaseQuote(CandlePart.HLC3).Select(i => i.Value);
for (int i = QL.Length; i > skip; i--)
var SK = quotes.GetBaseQuote(CandlePart.HLC3);
for (int i = QL.Length; i > skip; i--)
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round((double)SK.ElementAt(i - 1)!, digits: digits);
Assert.Equal(SK_item!, QL_item);
}
double QL_item = QL[i - 1].v;
double SK_item = SK.ElementAt(i - 1).Value;
Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits));
}
}
*/
[Fact]
[Fact]
public void HMA()
{
HMA_Series QL = new(bars.Close, period, useNaN: false);
var SK = quotes.GetHma(period).Select(i => i.Hma.Null2NaN()!);
for (int i = QL.Length; i > skip; i--)
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
}
double QL_item = QL[i - 1].v;
double SK_item = SK.ElementAt(i - 1);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10, -digits), Math.Pow(10, -digits));
}
}
[Fact]
public void KAMA()
@@ -224,9 +221,9 @@ public class Skender
var SK = quotes.GetKama(period).Select(i => i.Kama.Null2NaN()!);
for (int i = QL.Length; i > skip; i--)
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
double QL_item = QL[i - 1].v;
double SK_item = SK.ElementAt(i - 1);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -236,18 +233,18 @@ public class Skender
var SK = quotes.GetSlope(period);
for (int i = QL.Length; i > skip; i--)
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round((double)SK.ElementAt(i - 1).Slope!, digits: digits);
Assert.Equal(SK_item!, QL_item);
QL_item = Math.Round(QL.Intercept[i - 1].v, digits: digits);
SK_item = Math.Round((double)SK.ElementAt(i - 1).Intercept!, digits: digits);
Assert.Equal(SK_item!, QL_item);
QL_item = Math.Round(QL.RSquared[i - 1].v, digits: digits);
SK_item = Math.Round((double)SK.ElementAt(i - 1).RSquared!, digits: digits);
Assert.Equal(SK_item!, QL_item);
QL_item = Math.Round(QL.StdDev[i - 1].v, digits: digits);
SK_item = Math.Round((double)SK.ElementAt(i - 1).StdDev!, digits: digits);
Assert.Equal(SK_item!, QL_item);
double QL_item = QL[i - 1].v;
double SK_item = (double)SK.ElementAt(i - 1).Slope!;
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
QL_item = QL.Intercept[i - 1].v;
SK_item = (double)SK.ElementAt(i - 1).Intercept!;
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
QL_item = QL.RSquared[i - 1].v;
SK_item = (double)SK.ElementAt(i - 1).RSquared!;
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
QL_item = QL.StdDev[i - 1].v;
SK_item = (double)SK.ElementAt(i - 1).StdDev!;
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -259,10 +256,10 @@ public class Skender
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round(SK.ElementAt(i - 1).Macd.Null2NaN()!, digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
QL_item = Math.Round(QL.Signal[i - 1].v, digits: digits);
SK_item = Math.Round(SK.ElementAt(i - 1).Signal.Null2NaN()!, digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -274,7 +271,7 @@ public class Skender
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -286,10 +283,10 @@ public class Skender
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round(SK.ElementAt(i - 1).Mama.Null2NaN()!, digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
QL_item = Math.Round(QL.Fama[i - 1].v, digits: digits);
SK_item = Math.Round(SK.ElementAt(i - 1).Fama.Null2NaN()!, digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -301,7 +298,7 @@ public class Skender
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -313,7 +310,7 @@ public class Skender
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -326,7 +323,7 @@ public class Skender
{
double QL_item = Math.Round(QL.Last().v, digits: digits);
double SK_item = Math.Round(SK.Last()! + (double)quotes.First().Volume!, digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
/*
@@ -339,7 +336,7 @@ public class Skender
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round((double)SK.ElementAt(i - 1)!, digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -351,7 +348,7 @@ public class Skender
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round((double)SK.ElementAt(i - 1)!, digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -363,7 +360,7 @@ public class Skender
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round((double)SK.ElementAt(i - 1)!, digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
*/
@@ -376,7 +373,7 @@ public class Skender
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -388,7 +385,7 @@ public class Skender
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -400,7 +397,7 @@ public class Skender
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -412,7 +409,7 @@ public class Skender
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -424,7 +421,7 @@ public class Skender
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -436,7 +433,7 @@ public class Skender
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -448,7 +445,7 @@ public class Skender
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -460,7 +457,7 @@ public class Skender
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}
[Fact]
@@ -472,7 +469,7 @@ public class Skender
{
double QL_item = Math.Round(QL[i - 1].v, digits: digits);
double SK_item = Math.Round(SK.ElementAt(i - 1), digits: digits);
Assert.Equal(SK_item!, QL_item);
Assert.InRange(SK_item! - QL_item, -Math.Pow(10,-digits), Math.Pow(10,-digits));
}
}