Tests and QT cleanup

This commit is contained in:
Miha Kralj
2022-12-21 16:39:58 -08:00
parent 798d9b424d
commit 242c7fac9c
2 changed files with 57 additions and 58 deletions
+57 -57
View File
@@ -1,57 +1,57 @@
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using TradingPlatform.BusinessLayer; using TradingPlatform.BusinessLayer;
namespace QuanTAlib; namespace QuanTAlib;
public class AAA_chart : Indicator { public class AAA_chart : Indicator {
#region Parameters #region Parameters
[InputParameter("Smoothing period", 0, 1, 999, 1, 1)] [InputParameter("Smoothing period", 0, 1, 999, 1, 1)]
private readonly int Period = 10; private readonly int Period = 10;
#endregion Parameters #endregion Parameters
private TBars bars; private TBars bars;
private JMA_Series ind_a; private JMA_Series ind_a;
private DWMA_Series ind_b; private DWMA_Series ind_b;
public override string ShortName => $"AAA ({this.Period})"; public override string ShortName => $"AAA ({this.Period})";
public AAA_chart() : base() public AAA_chart() : base()
{ {
this.SeparateWindow = false; this.SeparateWindow = false;
this.Name = "AAA - Test indicator"; this.Name = "AAA - Test indicator";
this.Description = "Test indicator"; this.Description = "Test indicator";
this.AddLineSeries("JMA", Color.RoyalBlue, 3, LineStyle.Solid); this.AddLineSeries("JMA", Color.RoyalBlue, 3, LineStyle.Solid);
this.AddLineSeries("DWMA", Color.OrangeRed, 3, LineStyle.Solid); this.AddLineSeries("DWMA", Color.OrangeRed, 3, LineStyle.Solid);
this.SeparateWindow = false; this.SeparateWindow = false;
} }
protected override void OnInit() protected override void OnInit()
{ {
this.bars = new(); this.bars = new();
this.ind_a = new(source: bars.Close, 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); this.ind_b = new(source: bars.OHLC4, period: this.Period, useNaN: false);
} }
protected override void OnUpdate(UpdateArgs args) 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.bars.Add(this.Time(),
this.GetPrice(PriceType.Open), this.GetPrice(PriceType.Open),
this.GetPrice(PriceType.High), this.GetPrice(PriceType.High),
this.GetPrice(PriceType.Low), this.GetPrice(PriceType.Low),
this.GetPrice(PriceType.Close), this.GetPrice(PriceType.Close),
this.GetPrice(PriceType.Volume), this.GetPrice(PriceType.Volume),
update); update);
this.SetValue(this.ind_a.v.Last(), 0); this.SetValue(this.ind_a.v.Last(), 0);
this.SetValue(this.ind_b.v.Last(), 1); this.SetValue(this.ind_b.v.Last(), 1);
} }
} }
-1
View File
@@ -33,7 +33,6 @@ public class Skender
[Fact] [Fact]
public void ADL() public void ADL()
{ {
// TODO: check precision of ADL()
ADL_Series QL = new(bars, false); ADL_Series QL = new(bars, false);
var SK = quotes.GetAdl().Select(i => i.Adl); var SK = quotes.GetAdl().Select(i => i.Adl);
for (int i = QL.Length; i > skip; i--) for (int i = QL.Length; i > skip; i--)