예제 #1
0
        public void Standard()
        {
            int lookbackPeriod = 22;

            List <ChandelierResult> longResult =
                Indicator.GetChandelier(history, lookbackPeriod, 3.0m)
                .ToList();

            // assertions

            // proper quantities
            // should always be the same number of results as there is history
            Assert.AreEqual(502, longResult.Count);
            Assert.AreEqual(481, longResult.Where(x => x.ChandelierExit != null).Count());

            // sample values (long)
            ChandelierResult a = longResult[501];

            Assert.AreEqual(256.5860m, Math.Round((decimal)a.ChandelierExit, 4));

            ChandelierResult b = longResult[492];

            Assert.AreEqual(259.0480m, Math.Round((decimal)b.ChandelierExit, 4));

            // short
            List <ChandelierResult> shortResult =
                Indicator.GetChandelier(history, lookbackPeriod, 3.0m, ChandelierType.Short)
                .ToList();

            ChandelierResult c = shortResult[501];

            Assert.AreEqual(246.4240m, Math.Round((decimal)c.ChandelierExit, 4));
        }
예제 #2
0
        public void GetChandleierTest()
        {
            int lookbackPeriod = 22;
            IEnumerable <ChandelierResult> longResult = Indicator.GetChandelier(history, lookbackPeriod, 3.0m);

            // assertions

            // proper quantities
            // should always be the same number of results as there is history
            Assert.AreEqual(502, longResult.Count());
            Assert.AreEqual(502 - lookbackPeriod + 1, longResult.Where(x => x.ChandelierExit != null).Count());

            // sample values (long)
            ChandelierResult a = longResult.Where(x => x.Index == 502).FirstOrDefault();

            Assert.AreEqual(256.5860m, Math.Round((decimal)a.ChandelierExit, 4));

            ChandelierResult b = longResult.Where(x => x.Index == 493).FirstOrDefault();

            Assert.AreEqual(259.0480m, Math.Round((decimal)b.ChandelierExit, 4));

            // short
            IEnumerable <ChandelierResult> shortResult = Indicator.GetChandelier(history, lookbackPeriod, 3.0m, ChandelierType.Short);

            ChandelierResult c = shortResult.Where(x => x.Index == 502).FirstOrDefault();

            Assert.AreEqual(246.4240m, Math.Round((decimal)c.ChandelierExit, 4));
        }
예제 #3
0
    public void Removed()
    {
        List <ChandelierResult> longResult =
            quotes.GetChandelier(22, 3)
            .RemoveWarmupPeriods()
            .ToList();

        // assertions
        Assert.AreEqual(502 - 21, longResult.Count);

        ChandelierResult last = longResult.LastOrDefault();

        Assert.AreEqual(256.5860m, Math.Round((decimal)last.ChandelierExit, 4));
    }
예제 #4
0
        public void GetChandleierTest()
        {
            int lookbackPeriod = 22;
            IEnumerable <ChandelierResult> longResult = Indicator.GetChandelier(history, lookbackPeriod, 3.0m);

            // assertions

            // proper quantities
            // should always be the same number of results as there is history
            Assert.AreEqual(502, longResult.Count());
            Assert.AreEqual(502 - lookbackPeriod + 1, longResult.Where(x => x.ChandelierExit != null).Count());

            // sample values (long)
            ChandelierResult a = longResult.Where(x => x.Date == DateTime.Parse("12/31/2018")).FirstOrDefault();

            Assert.AreEqual((decimal)256.5860, Math.Round((decimal)a.ChandelierExit, 4));
            Assert.AreEqual(false, a.IsExitCross);
            Assert.AreEqual(true, a.IsCrossed);

            ChandelierResult b = longResult.Where(x => x.Date == DateTime.Parse("12/6/2018")).FirstOrDefault();

            Assert.AreEqual(false, b.IsExitCross);
            Assert.AreEqual(false, b.IsCrossed);

            ChandelierResult c = longResult.Where(x => x.Date == DateTime.Parse("12/7/2018")).FirstOrDefault();

            Assert.AreEqual(true, c.IsExitCross);
            Assert.AreEqual(true, c.IsCrossed);

            ChandelierResult d = longResult.Where(x => x.Date == DateTime.Parse("12/17/2018")).FirstOrDefault();

            Assert.AreEqual((decimal)259.0480, Math.Round((decimal)d.ChandelierExit, 4));
            Assert.AreEqual(false, d.IsExitCross);
            Assert.AreEqual(true, d.IsCrossed);

            // short
            IEnumerable <ChandelierResult> shortResult = Indicator.GetChandelier(history, lookbackPeriod, 3.0m, "short");

            ChandelierResult e = shortResult.Where(x => x.Date == DateTime.Parse("12/31/2018")).FirstOrDefault();

            Assert.AreEqual((decimal)246.4240, Math.Round((decimal)e.ChandelierExit, 4));
            Assert.AreEqual(false, e.IsExitCross);
            Assert.AreEqual(false, e.IsCrossed);
        }