Exemplo n.º 1
0
        public void LOGRComputesCorrectly()
        {
            var period = 4;
            var logr   = new LogReturn(period);
            var data   = new[] { 1, 10, 100, 1000, 10000, 1234, 56789 };
            var seen   = new List <int>();
            var time   = DateTime.Now;

            for (var i = 0; i < data.Length; i++)
            {
                var datum  = data[i];
                var value0 = 0.0;

                if (seen.Count >= 0 && seen.Count < period)
                {
                    value0 = data[0];
                }
                else if (seen.Count >= period)
                {
                    value0 = data[i - period];
                }

                var expected = (decimal)Math.Log(datum / value0);

                seen.Add(datum);
                logr.Update(time.AddSeconds(i), datum);
                Assert.AreEqual(expected, logr.Current.Value);
            }
        }
        public void LOGRComputesCorrectly()
        {
            int period = 4;
            var logr   = new LogReturn(period);
            var data   = new[] { 1m, 10m, 100m, 1000m, 10000m, 1234m, 56789m };

            var seen = new List <decimal>();

            for (int i = 0; i < data.Length; i++)
            {
                var datum  = data[i];
                var value0 = 0m;

                if (seen.Count >= 0 && seen.Count < period)
                {
                    value0 = data[0];
                }
                else if (seen.Count >= period)
                {
                    value0 = data[i - period];
                }

                var expected = (decimal)Math.Log((double)datum / (double)value0);

                seen.Add(datum);
                logr.Update(new IndicatorDataPoint(DateTime.Now.AddSeconds(i), datum));
                Assert.AreEqual(expected, logr.Current.Value);
            }
        }
Exemplo n.º 3
0
        public void LOGRComputesCorrectly()
        {
            int period = 4;
            var logr = new LogReturn(period);
            var data = new[] { 1m, 10m, 100m, 1000m, 10000m, 1234m, 56789m };

            var seen = new List<decimal>();
            for (int i = 0; i < data.Length; i++)
            {
                var datum = data[i];
                var value0 = 0m;

                if (seen.Count >= 0 && seen.Count < period)
                    value0 = data[0];
                else if (seen.Count >= period)
                    value0 = data[i - period];

                var expected = (decimal)Math.Log((double)datum / (double)value0);

                seen.Add(datum);
                logr.Update(new IndicatorDataPoint(DateTime.Now.AddSeconds(i), datum));
                Assert.AreEqual(expected, logr.Current.Value);
            }
        }