public void ComputesDelegateCorrectly()
        {
            var func = new FunctionalIndicator<IndicatorDataPoint>("f", data => data.Value, @this => @this.Samples > 1, () => {/*no reset action required*/});
            func.Update(DateTime.Today, 1m);
            Assert.IsFalse(func.IsReady);
            Assert.AreEqual(1m, func.Current.Value);

            func.Update(DateTime.Today.AddSeconds(1), 2m);
            Assert.IsTrue(func.IsReady);
            Assert.AreEqual(2m, func.Current.Value);
        }
Beispiel #2
0
        public void ComputesDelegateCorrectly()
        {
            var func = new FunctionalIndicator <IndicatorDataPoint>("f", data => data.Price, @this => @this.Samples > 1, () => { /*no reset action required*/ });

            func.Update(DateTime.Today, TimeZone.Utc, 1m);
            Assert.False(func.IsReady);
            Assert.Equal(1m, func.Current.Price);

            func.Update(DateTime.Today.AddSeconds(1), TimeZone.Utc, 2m);
            Assert.True(func.IsReady);
            Assert.Equal(2m, func.Current.Price);
        }
        public void ComputesDelegateCorrectly()
        {
            var func = new FunctionalIndicator <IndicatorDataPoint>("f", data => data.Value, @this => @this.Samples > 1, () => {});

            func.Update(DateTime.Today, 1m);
            Assert.IsFalse(func.IsReady);
            Assert.AreEqual(1m, func.Current.Value);

            func.Update(DateTime.Today.AddSeconds(1), 2m);
            Assert.IsTrue(func.IsReady);
            Assert.AreEqual(2m, func.Current.Value);
        }
        public void ComputesDelegateCorrectly()
        {
            var func = new FunctionalIndicator("f", (time, data) => data.Value, @this => @this.Samples > 1, () => {
                /*no reset action required*/
            });

            func.Update(DateTime.Today, 1d);
            Assert.IsFalse(func.IsReady);
            Assert.AreEqual(1d, func.Current.Value);

            func.Update(DateTime.Today.AddSeconds(1), 2d);
            Assert.IsTrue(func.IsReady);
            Assert.AreEqual(2d, func.Current.Value);
        }
        public void ResetsProperly()
        {
            var inner = new SimpleMovingAverage(2);
            var func  = new FunctionalIndicator("f", (time, data) => {
                inner.Update(time, data);
                return(inner.Current.Value * 2);
            },
                                                @this => inner.IsReady,
                                                () => inner.Reset()
                                                );

            func.Update(DateTime.Today, 1d);
            func.Update(DateTime.Today.AddSeconds(1), 2d);
            Assert.IsTrue(func.IsReady);

            func.Reset();
            TestHelper.AssertIndicatorIsInDefaultState(inner);
            TestHelper.AssertIndicatorIsInDefaultState(func);
        }
        public void ResetsProperly()
        {
            var inner = new SimpleMovingAverage(2);
            var func = new FunctionalIndicator<IndicatorDataPoint>("f", data =>
            {
                inner.Update(data);
                return inner.Current.Value*2;
            },
            @this => inner.IsReady,
            () => inner.Reset()
            );

            func.Update(DateTime.Today, 1m);
            func.Update(DateTime.Today.AddSeconds(1), 2m);
            Assert.IsTrue(func.IsReady);

            func.Reset();
            TestHelper.AssertIndicatorIsInDefaultState(inner);
            TestHelper.AssertIndicatorIsInDefaultState(func);
        }
Beispiel #7
0
        public void ResetsProperly()
        {
            var inner = new SimpleMovingAverage(2);
            var func  = new FunctionalIndicator <IndicatorDataPoint>("f", data =>
            {
                inner.Update(data);
                return(inner.Current.Price * 2);
            },
                                                                     @this => inner.IsReady,
                                                                     () => inner.Reset()
                                                                     );

            func.Update(DateTime.Today, TimeZone.Utc, 1m);
            func.Update(DateTime.Today.AddSeconds(1), TimeZone.Utc, 2m);
            Assert.True(func.IsReady);

            func.Reset();
            TestHelper.AssertIndicatorIsInDefaultState(inner);
            TestHelper.AssertIndicatorIsInDefaultState(func);
        }