示例#1
0
        public void TestAddSameExtremum()
        {
            var repo = new ExtremumsRepository();

            repo.AddExtremum(new Extremum(50, 2, new DateTime(10, 10, 11), false));
            Assert.That(repo.FirstMaximums.Count == 1);
            repo.AddExtremum(new Extremum(30, 4, new DateTime(10, 10, 11), false));
            Assert.That(repo.FirstMaximums.Count == 1);
        }
示例#2
0
        public SearchState(RobotContext context)
        {
            context.Logger.Debug("Change state to Search");

            ExtremumsRepo = new ExtremumsRepository();
            searchTree = new LinkedList<CandleNode>();

            for (int i = 0; i < context.Candles.Count; ++i)
            {
                AppendToTree(context.Candles[i], i);
            }

            pegTopSize = context.PegtopSize;
        }
示例#3
0
        public void TestAddExtremum()
        {
            var repo = new ExtremumsRepository();

            var secondMin = repo.AddExtremum(new Extremum(100, 1, new DateTime(10, 10, 10), true));
            Assert.IsNull(secondMin);
            secondMin = repo.AddExtremum(new Extremum(50, 2, new DateTime(10, 10, 11), true));
            Assert.IsNull(secondMin);
            secondMin = repo.AddExtremum(new Extremum(100, 3, new DateTime(10, 10, 12), true));
            Assert.IsNotNull(secondMin);
            Assert.That(secondMin.Value == 50 && secondMin.IsMinimum && secondMin.DateTime == new DateTime(10, 10, 11) && secondMin.CheckerIndex == 3);

            var secondMax = repo.AddExtremum(new Extremum(100, 1, new DateTime(10, 10, 10), false));
            Assert.IsNull(secondMax);
            secondMax = repo.AddExtremum(new Extremum(50, 2, new DateTime(10, 10, 11), false));
            Assert.IsNull(secondMax);
            secondMax = repo.AddExtremum(new Extremum(30, 4, new DateTime(10, 10, 11), false));
            Assert.IsNull(secondMax);
            secondMax = repo.AddExtremum(new Extremum(100, 3, new DateTime(10, 10, 12), false));
            Assert.IsNull(secondMax);
            secondMax = repo.AddExtremum(new Extremum(80, 5, new DateTime(10, 10, 14), false));
            Assert.IsNotNull(secondMax);
            Assert.That(secondMax.Value == 100 && !secondMax.IsMinimum && secondMax.DateTime == new DateTime(10, 10, 12) && secondMax.CheckerIndex == 5);
        }