public void Standard() { int erPeriod = 10; int fastPeriod = 2; int slowPeriod = 30; List <KamaResult> results = Indicator.GetKama(history, erPeriod, fastPeriod, slowPeriod) .ToList(); // assertions // proper quantities // should always be the same number of results as there is history Assert.AreEqual(502, results.Count); Assert.AreEqual(492, results.Where(x => x.ER != null).Count()); Assert.AreEqual(493, results.Where(x => x.Kama != null).Count()); // sample values KamaResult r1 = results[8]; Assert.AreEqual(null, r1.ER); Assert.AreEqual(null, r1.Kama); KamaResult r2 = results[9]; Assert.AreEqual(null, r2.ER); Assert.AreEqual(213.75m, r2.Kama); KamaResult r3 = results[10]; Assert.AreEqual(0.2465m, Math.Round((decimal)r3.ER, 4)); Assert.AreEqual(213.7713m, Math.Round((decimal)r3.Kama, 4)); KamaResult r4 = results[24]; Assert.AreEqual(0.2136m, Math.Round((decimal)r4.ER, 4)); Assert.AreEqual(214.7423m, Math.Round((decimal)r4.Kama, 4)); KamaResult r5 = results[149]; Assert.AreEqual(0.3165m, Math.Round((decimal)r5.ER, 4)); Assert.AreEqual(235.5510m, Math.Round((decimal)r5.Kama, 4)); KamaResult r6 = results[249]; Assert.AreEqual(0.3182m, Math.Round((decimal)r6.ER, 4)); Assert.AreEqual(256.0898m, Math.Round((decimal)r6.Kama, 4)); KamaResult r7 = results[501]; Assert.AreEqual(0.2214m, Math.Round((decimal)r7.ER, 4)); Assert.AreEqual(240.1138m, Math.Round((decimal)r7.Kama, 4)); }
public void Convergence() { foreach (int qty in convergeQuantities) { IEnumerable <Quote> h = History.GetHistoryLong(105 + qty); IEnumerable <KamaResult> r = Indicator.GetKama(h, 10); KamaResult l = r.LastOrDefault(); Console.WriteLine("KAMA on {0:d} with {1,4} periods: {2:N8}", l.Date, h.Count(), l.Kama); } }
public void Kama() { foreach (int qty in QuotesQuantities) { IEnumerable <Quote> quotes = TestData.GetLongish(qty); IEnumerable <KamaResult> r = quotes.GetKama(10); KamaResult l = r.LastOrDefault(); Console.WriteLine( "KAMA(10) on {0:d} with {1,4} periods: {2:N8}", l.Date, quotes.Count(), l.Kama); } }
public void Removed() { int erPeriods = 10; int fastPeriods = 2; int slowPeriods = 30; List <KamaResult> results = quotes.GetKama(erPeriods, fastPeriods, slowPeriods) .RemoveWarmupPeriods() .ToList(); // assertions Assert.AreEqual(502 - Math.Max(erPeriods + 100, erPeriods * 10), results.Count); KamaResult last = results.LastOrDefault(); Assert.AreEqual(0.2214, Math.Round((double)last.ER, 4)); Assert.AreEqual(240.1138m, Math.Round((decimal)last.Kama, 4)); }