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);
}