コード例 #1
0
        public void AccumulationDistribution()
        {
            var          now   = new LocalDateTime();
            IList <Tick> ticks = new List <Tick>();

            ticks.Add(GenerateTick.From(now, 0d, 10d, 12d, 8d, 0d, 200d, 0));            //2-2 * 200 / 4
            ticks.Add(GenerateTick.From(now, 0d, 8d, 10d, 7d, 0d, 100d, 0));             //1-2 *100 / 3
            ticks.Add(GenerateTick.From(now, 0d, 9d, 15d, 6d, 0d, 300d, 0));             //3-6 *300 /9
            ticks.Add(GenerateTick.From(now, 0d, 20d, 40d, 5d, 0d, 50d, 0));             //15-20 *50 / 35
            ticks.Add(GenerateTick.From(now, 0d, 30d, 30d, 3d, 0d, 600d, 0));            //27-0 *600 /27

            TimeSeries series = GenerateTimeSeries.From(ticks);
            var        ac     = new AccumulationDistributionIndicator(series);

            TaTestsUtils.AssertDecimalEquals(ac.GetValue(0), 0);
            TaTestsUtils.AssertDecimalEquals(ac.GetValue(1), -100d / 3);
            TaTestsUtils.AssertDecimalEquals(ac.GetValue(2), -100d - (100d / 3));
            TaTestsUtils.AssertDecimalEquals(ac.GetValue(3), (-250d / 35) + (-100d - (100d / 3)));
            TaTestsUtils.AssertDecimalEquals(ac.GetValue(4), 600d + ((-250d / 35) + (-100d - (100d / 3))));
        }
コード例 #2
0
        public void accumulationDistribution()
        {
            DateTime    now  = DateTime.Now;
            List <IBar> bars = new List <IBar>();

            bars.Add(new MockBar(now, 0M, 10, 12, 8, 0, 200, 0)); //2-2 * 200 / 4
            bars.Add(new MockBar(now, 0M, 8, 10, 7, 0, 100, 0));  //1-2 *100 / 3
            bars.Add(new MockBar(now, 0M, 9, 15, 6, 0, 300, 0));  //3-6 *300 /9
            bars.Add(new MockBar(now, 0M, 20, 40, 5, 0, 50, 0));  //15-20 *50 / 35
            bars.Add(new MockBar(now, 0M, 30, 30, 3, 0, 600, 0)); //27-0 *600 /27

            ITimeSeries series = new MockTimeSeries(bars);
            AccumulationDistributionIndicator ac = new AccumulationDistributionIndicator(series);

            Assert.AreEqual(ac.GetValue(0), 0);
            Assert.AreEqual(ac.GetValue(1), -33.333333333333333333333333330M);
            Assert.AreEqual(ac.GetValue(2), -133.33333333333333333333333332M);
            Assert.AreEqual(ac.GetValue(3), -140.47619047619047619047619046M);
            Assert.AreEqual(ac.GetValue(4), 459.52380952380952380952380954M);
        }