Exemplo n.º 1
0
        private static void TestPipesData(SequentialIndicator <IndicatorDataPoint> sequential)
        {
            var data1 = new IndicatorDataPoint(DateTime.UtcNow, 1m);
            var data2 = new IndicatorDataPoint(DateTime.UtcNow, 2m);
            var data3 = new IndicatorDataPoint(DateTime.UtcNow, 3m);
            var data4 = new IndicatorDataPoint(DateTime.UtcNow, 4m);
            var data5 = new IndicatorDataPoint(DateTime.UtcNow, 5m);

            // sma has one item
            sequential.Update(data1);
            Assert.IsFalse(sequential.IsReady);
            Assert.AreEqual(0m, sequential.Current.Value);

            // sma has two items
            sequential.Update(data2);
            Assert.IsFalse(sequential.IsReady);
            Assert.AreEqual(0m, sequential.Current.Value);

            // sma is ready, delay will repeat this value
            sequential.Update(data3);
            Assert.IsFalse(sequential.IsReady);
            Assert.AreEqual(2.5m, sequential.Current.Value);

            // delay is ready, and repeats its first input
            sequential.Update(data4);
            Assert.IsTrue(sequential.IsReady);
            Assert.AreEqual(2.5m, sequential.Current.Value);

            // now getting the delayed data
            sequential.Update(data5);
            Assert.IsTrue(sequential.IsReady);
            Assert.AreEqual(3.5m, sequential.Current.Value);
        }
Exemplo n.º 2
0
        private static void TestPipesData(SequentialIndicator<IndicatorDataPoint> sequential)
        {
            var data1 = new IndicatorDataPoint(DateTime.UtcNow, 1m);
            var data2 = new IndicatorDataPoint(DateTime.UtcNow, 2m);
            var data3 = new IndicatorDataPoint(DateTime.UtcNow, 3m);
            var data4 = new IndicatorDataPoint(DateTime.UtcNow, 4m);
            var data5 = new IndicatorDataPoint(DateTime.UtcNow, 5m);

            // sma has one item
            sequential.Update(data1);
            Assert.IsFalse(sequential.IsReady);
            Assert.AreEqual(0m, sequential.Current.Value);

            // sma has two items
            sequential.Update(data2);
            Assert.IsFalse(sequential.IsReady);
            Assert.AreEqual(0m, sequential.Current.Value);

            // sma is ready, delay will repeat this value
            sequential.Update(data3);
            Assert.IsFalse(sequential.IsReady);
            Assert.AreEqual(2.5m, sequential.Current.Value);

            // delay is ready, and repeats its first input
            sequential.Update(data4);
            Assert.IsTrue(sequential.IsReady);
            Assert.AreEqual(2.5m, sequential.Current.Value);

            // now getting the delayed data
            sequential.Update(data5);
            Assert.IsTrue(sequential.IsReady);
            Assert.AreEqual(3.5m, sequential.Current.Value);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }