Esempio n. 1
0
        public void ResetsProperly()
        {
            var mfi = new MoneyFlowIndex(3);

            foreach (var data in TestHelper.GetDataStream(4))
            {
                var tradeBar = new TradeBar
                {
                    Open   = data.Value,
                    Close  = data.Value,
                    High   = data.Value,
                    Low    = data.Value,
                    Volume = Decimal.ToInt64(data.Value)
                };
                mfi.Update(tradeBar);
            }
            Assert.IsTrue(mfi.IsReady);
            Assert.IsTrue(mfi.PositiveMoneyFlow.IsReady);
            Assert.IsTrue(mfi.NegativeMoneyFlow.IsReady);
            Assert.AreNotEqual(mfi.PreviousTypicalPrice, 0.0m);

            mfi.Reset();

            Assert.AreEqual(mfi.PreviousTypicalPrice, 0.0m);
            TestHelper.AssertIndicatorIsInDefaultState(mfi);
            TestHelper.AssertIndicatorIsInDefaultState(mfi.PositiveMoneyFlow);
            TestHelper.AssertIndicatorIsInDefaultState(mfi.NegativeMoneyFlow);
        }
Esempio n. 2
0
        public void TestWithStream()
        {
            var aps = new AugenPriceSpike(22);

            foreach (var data in TestHelper.GetDataStream(50))
            {
                aps.Update(data.Time, data.Value);
            }
        }
Esempio n. 3
0
        public void ComputesCorrectly()
        {
            var mom = new Momentum(5);

            foreach (var data in TestHelper.GetDataStream(5))
            {
                mom.Update(data);
                Assert.AreEqual(data.Value, mom.Current.Value);
            }
        }
Esempio n. 4
0
        public void WarmsUpProperly()
        {
            var mom        = new Momentum(5);
            var period     = ((IIndicatorWarmUpPeriodProvider)mom).WarmUpPeriod;
            var dataStream = TestHelper.GetDataStream(period).ToArray();

            for (var i = 0; i < period; i++)
            {
                mom.Update(dataStream[i]);
                Assert.AreEqual(i == period - 1, mom.IsReady);
            }
        }
Esempio n. 5
0
        public void WarmsUpProperly(int?minPeriod, int fullPeriod)
        {
            var momersion  = new MomersionIndicator(minPeriod, fullPeriod);
            var period     = ((IIndicatorWarmUpPeriodProvider)momersion).WarmUpPeriod;
            var dataStream = TestHelper.GetDataStream(period).ToArray();

            for (var i = 0; i < period; i++)
            {
                momersion.Update(dataStream[i]);
                Assert.AreEqual(i == period - 1, momersion.IsReady);
            }
        }
Esempio n. 6
0
        public void WarmsUpProperly()
        {
            var delay     = new Delay(20);
            var count     = ((IIndicatorWarmUpPeriodProvider)delay).WarmUpPeriod;
            var dataArray = TestHelper.GetDataStream(count).ToArray();

            for (var i = 0; i < count; i++)
            {
                delay.Update(dataArray[i]);
                Assert.AreEqual(i == count - 1, delay.IsReady);
            }
        }
        public void ResetsProperly()
        {
            var roc = new RateOfChange(50);

            foreach (var data in TestHelper.GetDataStream(51))
            {
                roc.Update(data);
            }
            Assert.IsTrue(roc.IsReady);

            roc.Reset();

            TestHelper.AssertIndicatorIsInDefaultState(roc);
        }
Esempio n. 8
0
        public void ResetsProperly()
        {
            var sma = new SimpleMovingAverage(3);

            foreach (var data in TestHelper.GetDataStream(4))
            {
                sma.Update(data);
            }
            Assert.IsTrue(sma.IsReady);

            sma.Reset();

            TestHelper.AssertIndicatorIsInDefaultState(sma);
        }
Esempio n. 9
0
        public void ResetsProperly()
        {
            var momp = new MomentumPercent(50);

            foreach (var data in TestHelper.GetDataStream(51))
            {
                momp.Update(data);
            }
            Assert.IsTrue(momp.IsReady);

            momp.Reset();

            TestHelper.AssertIndicatorIsInDefaultState(momp);
        }
Esempio n. 10
0
        public void ResetsProperly()
        {
            var delay = new Delay(2);

            foreach (var data in TestHelper.GetDataStream(3))
            {
                delay.Update(data);
            }
            Assert.IsTrue(delay.IsReady);
            Assert.AreEqual(3, delay.Samples);

            delay.Reset();

            TestHelper.AssertIndicatorIsInDefaultState(delay);
        }
Esempio n. 11
0
        public void ResetsProperly()
        {
            var sak = new SwissArmyKnife(4, 0.1, SwissArmyKnifeTool.BandPass);

            foreach (var data in TestHelper.GetDataStream(5))
            {
                sak.Update(data);
            }
            Assert.IsTrue(sak.IsReady);
            Assert.AreNotEqual(0m, sak.Current.Value);
            Assert.AreNotEqual(0, sak.Samples);

            sak.Reset();

            TestHelper.AssertIndicatorIsInDefaultState(sak);
        }
        public void ResetsProperly()
        {
            var indicator = new WindowIdentity(3);

            foreach (var data in TestHelper.GetDataStream(4))
            {
                indicator.Update(data);
            }
            Assert.IsTrue(indicator.IsReady);

            indicator.Reset();

            TestHelper.AssertIndicatorIsInDefaultState(indicator);
            indicator.Update(DateTime.UtcNow, 2.0m);
            Assert.AreEqual(indicator.Current.Value, 2.0m);
        }
Esempio n. 13
0
        public void ResetsProperly()
        {
            var macd = new MovingAverageConvergenceDivergence("macd", 3, 5, 3);

            foreach (var data in TestHelper.GetDataStream(30))
            {
                macd.Update(data);
            }
            Assert.IsTrue(macd.IsReady);

            macd.Reset();

            TestHelper.AssertIndicatorIsInDefaultState(macd);
            TestHelper.AssertIndicatorIsInDefaultState(macd.Fast);
            TestHelper.AssertIndicatorIsInDefaultState(macd.Signal);
            TestHelper.AssertIndicatorIsInDefaultState(macd.Signal);
        }
Esempio n. 14
0
        public void TestTradeBarsWithVolume()
        {
            var emv = new EaseOfMovementValue();

            foreach (var data in TestHelper.GetDataStream(4))
            {
                var tradeBar = new TradeBar
                {
                    Open   = data.Value,
                    Close  = data.Value,
                    High   = data.Value,
                    Low    = data.Value,
                    Volume = data.Value
                };
                emv.Update(tradeBar);
            }
        }
        public override void ResetsProperly()
        {
            // ema reset is just setting the value and samples back to 0
            var ema = new ExponentialMovingAverage(3);

            foreach (var data in TestHelper.GetDataStream(5))
            {
                ema.Update(data);
            }
            Assert.IsTrue(ema.IsReady);
            Assert.AreNotEqual(0m, ema.Current.Value);
            Assert.AreNotEqual(0, ema.Samples);

            ema.Reset();

            TestHelper.AssertIndicatorIsInDefaultState(ema);
        }
        public void ResetsProperly()
        {

            FractalAdaptiveMovingAverage frama = new FractalAdaptiveMovingAverage("", 6, 198);

            foreach (var data in TestHelper.GetDataStream(7))
            {
                frama.Update(new TradeBar { High = data, Low = data });
            }
            Assert.IsTrue(frama.IsReady);
            Assert.AreNotEqual(0m, frama.Current.Value);
            Assert.AreNotEqual(0, frama.Samples);

            frama.Reset();

            TestHelper.AssertIndicatorIsInDefaultState(frama);
        }
Esempio n. 17
0
        public override void ResetsProperly()
        {
            var sma = new SimpleMovingAverage(3);

            foreach (var data in TestHelper.GetDataStream(4))
            {
                sma.Update(data);
            }
            Assert.IsTrue(sma.IsReady);

            sma.Reset();

            TestHelper.AssertIndicatorIsInDefaultState(sma);
            TestHelper.AssertIndicatorIsInDefaultState(sma.RollingSum);
            sma.Update(DateTime.UtcNow, 2.0m);
            Assert.AreEqual(sma.Current.Value, 2.0m);
        }
        public void TestTradeBarsWithNoVolume()
        {
            var mfi = new MoneyFlowIndex(3);

            foreach (var data in TestHelper.GetDataStream(4))
            {
                var tradeBar = new TradeBar
                {
                    Open   = data.Value,
                    Close  = data.Value,
                    High   = data.Value,
                    Low    = data.Value,
                    Volume = 0
                };
                mfi.Update(tradeBar);
            }
            Assert.AreEqual(mfi.Current.Value, 100.0m);
        }
Esempio n. 19
0
        public void ResetsProperly()
        {
            var identity = new Identity("test");

            Assert.IsFalse(identity.IsReady);
            Assert.AreEqual(0m, identity.Current.Value);

            foreach (var data in TestHelper.GetDataStream(2))
            {
                identity.Update(data);
            }
            Assert.IsTrue(identity.IsReady);
            Assert.AreEqual(2, identity.Samples);

            identity.Reset();

            Assert.IsFalse(identity.IsReady);
            Assert.AreEqual(0, identity.Samples);
        }
Esempio n. 20
0
        public void TestDivByZero()
        {
            var cmf = new ChaikinMoneyFlow("CMF", 3);

            foreach (var data in TestHelper.GetDataStream(4))
            {
                // Should handle High = Low case by returning 0m.
                var tradeBar = new TradeBar
                {
                    Open   = data.Value,
                    Close  = data.Value,
                    High   = 1,
                    Low    = 1,
                    Volume = 1
                };
                cmf.Update(tradeBar);
            }
            Assert.AreEqual(cmf.Current.Value, 0m);
        }
Esempio n. 21
0
        public void TestTradeBarsWithNoVolume()
        {
            // As volume is a multiplier in numerator, should return default value 0m.
            var cmf = new ChaikinMoneyFlow("CMF", 3);

            foreach (var data in TestHelper.GetDataStream(4))
            {
                var tradeBar = new TradeBar
                {
                    Open   = data.Value,
                    Close  = data.Value,
                    High   = data.Value,
                    Low    = data.Value,
                    Volume = 0
                };
                cmf.Update(tradeBar);
            }
            Assert.AreEqual(cmf.Current.Value, 0m);
        }
Esempio n. 22
0
        public void TestDivByZero()
        {
            var dem = new DeMarkerIndicator("DEM", 3);

            foreach (var data in TestHelper.GetDataStream(4))
            {
                // Should handle High = Low case by returning 0m.
                var tradeBar = new TradeBar
                {
                    Open   = data.Value,
                    Close  = data.Value,
                    High   = 1,
                    Low    = 1,
                    Volume = 1
                };
                dem.Update(tradeBar);
            }
            Assert.AreEqual(dem.Current.Value, 0m);
        }
        public override void ResetsProperly()
        {
            var rma = new RelativeMovingAverage(5);

            foreach (var data in TestHelper.GetDataStream(5 * 3))
            {
                Assert.IsFalse(rma.IsReady);
                rma.Update(data);
            }
            Assert.IsTrue(rma.IsReady);

            rma.Reset();

            TestHelper.AssertIndicatorIsInDefaultState(rma);
            TestHelper.AssertIndicatorIsInDefaultState(rma.ShortAverage);
            TestHelper.AssertIndicatorIsInDefaultState(rma.MediumAverage);
            TestHelper.AssertIndicatorIsInDefaultState(rma.LongAverage);
            rma.Update(DateTime.UtcNow, 2.0m);
            Assert.AreEqual(rma.Current.Value, 2.0m);
        }
Esempio n. 24
0
        public void ResetsProperly()
        {
            // ema reset is just setting the value and samples back to 0
            var ema = new ExponentialMovingAverage(3);

            foreach (var data in TestHelper.GetDataStream(5))
            {
                ema.Update(data);
            }
            Assert.IsTrue(ema.IsReady);
            Assert.AreNotEqual(0m, ema.Current.Value);
            Assert.AreNotEqual(0, ema.Samples);

            ema.Reset();

            Assert.IsFalse(ema.IsReady);
            Assert.AreEqual(0, ema.Samples);
            Assert.AreEqual(0m, ema.Current.Value);
            Assert.AreEqual(DateTime.MinValue, ema.Current.Time);
        }
Esempio n. 25
0
        public void ComputesCorrectly()
        {
            var fast   = new SimpleMovingAverage(3);
            var slow   = new SimpleMovingAverage(5);
            var signal = new SimpleMovingAverage(3);
            var macd   = new MovingAverageConvergenceDivergence("macd", 3, 5, 3, MovingAverageType.Simple);

            foreach (var data in TestHelper.GetDataStream(7))
            {
                fast.Update(data);
                slow.Update(data);
                macd.Update(data);
                Assert.AreEqual(fast - slow, macd);
                if (fast.IsReady && slow.IsReady)
                {
                    signal.Update(new IndicatorDataPoint(data.Time, macd));
                    Assert.AreEqual(signal.Current.Value, macd.Current.Value);
                }
            }
        }
Esempio n. 26
0
        public void ResetsProperly()
        {
            var first      = new Delay(1);
            var second     = new Delay(1);
            var sequential = new SequentialIndicator <IndicatorDataPoint>(first, second);

            foreach (var data in TestHelper.GetDataStream(3))
            {
                sequential.Update(data);
            }
            Assert.IsTrue(first.IsReady);
            Assert.IsTrue(second.IsReady);
            Assert.IsTrue(sequential.IsReady);

            sequential.Reset();

            TestHelper.AssertIndicatorIsInDefaultState(first);
            TestHelper.AssertIndicatorIsInDefaultState(second);
            TestHelper.AssertIndicatorIsInDefaultState(sequential);
        }
Esempio n. 27
0
        public override void ResetsProperly()
        {
            var STR = new SuperTrend(10, 3);

            foreach (var data in TestHelper.GetDataStream(100))
            {
                var tradeBar = new TradeBar
                {
                    Open   = data.Value,
                    Close  = data.Value,
                    High   = data.Value,
                    Low    = data.Value,
                    Volume = data.Value
                };
                STR.Update(tradeBar);
            }
            Assert.IsTrue(STR.IsReady);

            STR.Reset();
            TestHelper.AssertIndicatorIsInDefaultState(STR);
        }
Esempio n. 28
0
        public void Getters()
        {
            var STR = new SuperTrend(10, 3);

            foreach (var data in TestHelper.GetDataStream(100))
            {
                var tradeBar = new TradeBar
                {
                    Open   = data.Value,
                    Close  = data.Value,
                    High   = data.Value,
                    Low    = data.Value,
                    Volume = data.Value
                };
                STR.Update(tradeBar);
            }
            Assert.IsTrue(STR.IsReady);
            Assert.AreNotEqual(0, STR.BasicUpperBand);
            Assert.AreNotEqual(0, STR.BasicLowerBand);
            Assert.AreNotEqual(0, STR.CurrentTrailingUpperBand);
            Assert.AreNotEqual(0, STR.CurrentTrailingLowerBand);
        }
Esempio n. 29
0
        public void ComputesCorrectly()
        {
            var delay = new Delay(3);
            var sma   = new SimpleMovingAverage(3);
            var momp  = new MomentumPercent(3);

            foreach (var data in TestHelper.GetDataStream(4))
            {
                delay.Update(data);
                sma.Update(data);
                momp.Update(data);

                if (sma == 0m)
                {
                    Assert.AreEqual(0m, momp.Current.Value);
                }
                else
                {
                    decimal abs  = data - delay;
                    decimal perc = abs / sma;
                    Assert.AreEqual(perc, momp.Current.Value);
                }
            }
        }